from urlparse import urlunsplit, urlsplit, urlparse, parse_qsl
from astakos.im.settings import COOKIE_NAME, COOKIE_DOMAIN
-from astakos.im.util import set_cookie, has_signed_terms
+from astakos.im.util import set_cookie
import logging
def login(request):
"""
- If there is no `next` request parameter redirects to astakos index page displaying an error
- message.
- If the request user is authenticated and has signed the approval terms, redirects to `next` request parameter. If not, redirects to approval terms in order to return back here after agreeing with the terms.
+ If there is no ``next`` request parameter redirects to astakos index page
+ displaying an error message.
+ If the request user is authenticated and has signed the approval terms,
+ redirects to `next` request parameter. If not, redirects to approval terms
+ in order to return back here after agreeing with the terms.
Otherwise, redirects to login in order to return back here after successful login.
"""
next = request.GET.get('next')
if request.user.is_authenticated():
# if user has not signed the approval terms
# redirect to approval terms with next the request path
- if not has_signed_terms(request.user):
+ 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))