Commit 76285354 authored by Sofia Papagiannaki's avatar Sofia Papagiannaki
Browse files

AstakosUser signed_terms property instead of function

parent fc839045
......@@ -98,7 +98,7 @@ def authenticate_old(request, user=None):
if (time() - mktime(user.auth_token_expires.timetuple())) > 0:
raise Unauthorized('Authentication expired')
if not user.signed_terms():
if not user.signed_terms:
raise Unauthorized('Pending approval terms')
response = HttpResponse()
......@@ -109,7 +109,7 @@ def authenticate_old(request, user=None):
'auth_token_created':user.auth_token_created.isoformat(),
'auth_token_expires':user.auth_token_expires.isoformat(),
'has_credits':user.has_credits,
'has_signed_terms':user.signed_terms(),
'has_signed_terms':user.signed_terms,
'groups':[g.name for g in user.groups.all()]}
response.content = json.dumps(user_info)
response['Content-Type'] = 'application/json; charset=UTF-8'
......@@ -133,7 +133,7 @@ def authenticate(request, user=None):
if (time() - mktime(user.auth_token_expires.timetuple())) > 0:
raise Unauthorized('Authentication expired')
if not user.signed_terms():
if not user.signed_terms:
raise Unauthorized('Pending approval terms')
response = HttpResponse()
......
......@@ -84,7 +84,7 @@ class Command(BaseCommand):
'resources' : user.quota
}
if get_latest_terms():
has_signed_terms = user.signed_terms()
has_signed_terms = user.signed_terms
kv['has_signed_terms'] = format_bool(has_signed_terms)
if has_signed_terms:
kv['date_signed_terms'] = format_date(user.date_signed_terms)
......
......@@ -149,10 +149,6 @@ class AstakosGroup(Group):
return False
return True
# @property
# def participants(self):
# return len(self.approved_members)
def enable(self):
if self.is_enabled:
return
......@@ -351,6 +347,7 @@ class AstakosUser(User):
if q.count() != 0:
raise ValidationError({'__all__':[_('Another account with the same email & is_active combination found.')]})
@property
def signed_terms(self):
term = get_latest_terms()
if not term:
......
......@@ -68,7 +68,7 @@ def login(request):
if request.user.is_authenticated():
# if user has not signed the approval terms
# redirect to approval terms with next the request path
if not request.user.signed_terms():
if not request.user.signed_terms:
# first build next parameter
parts = list(urlsplit(request.build_absolute_uri()))
params = dict(parse_qsl(parts[3], keep_blank_values=True))
......
......@@ -113,7 +113,7 @@ def signed_terms_required(func):
"""
@wraps(func)
def wrapper(request, *args, **kwargs):
if request.user.is_authenticated() and not request.user.signed_terms():
if request.user.is_authenticated() and not request.user.signed_terms:
params = urlencode({'next': request.build_absolute_uri(),
'show_form':''})
terms_uri = reverse('latest_terms') + '?' + params
......@@ -545,7 +545,7 @@ def approval_terms(request, term_id=None, template_name='im/approval_terms.html'
return HttpResponseRedirect(next)
else:
form = None
if request.user.is_authenticated() and not request.user.signed_terms():
if request.user.is_authenticated() and not request.user.signed_terms:
form = SignApprovalTermsForm(instance=request.user)
return render_response(template_name,
terms = terms,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment