Revision 1ecda536 snf-astakos-app/astakos/im/views/im.py
b/snf-astakos-app/astakos/im/views/im.py | ||
---|---|---|
79 | 79 |
@require_http_methods(["GET", "POST"]) |
80 | 80 |
@cookie_fix |
81 | 81 |
@signed_terms_required |
82 |
def index(request, login_template_name='im/login.html', profile_template_name='im/profile.html', extra_context=None):
|
|
82 |
def login(request, template_name='im/login.html', extra_context=None):
|
|
83 | 83 |
""" |
84 |
If there is logged on user renders the profile page otherwise renders login page.
|
|
84 |
Renders login page.
|
|
85 | 85 |
|
86 | 86 |
**Arguments** |
87 | 87 |
|
88 |
``login_template_name``
|
|
88 |
``template_name`` |
|
89 | 89 |
A custom login template to use. This is optional; if not specified, |
90 | 90 |
this will default to ``im/login.html``. |
91 | 91 |
|
92 |
``profile_template_name`` |
|
93 |
A custom profile template to use. This is optional; if not specified, |
|
94 |
this will default to ``im/profile.html``. |
|
95 |
|
|
96 | 92 |
``extra_context`` |
97 | 93 |
An dictionary of variables to add to the template context. |
98 |
|
|
99 |
**Template:** |
|
100 |
|
|
101 |
im/profile.html or im/login.html or ``template_name`` keyword argument. |
|
102 |
|
|
103 | 94 |
""" |
95 |
|
|
104 | 96 |
extra_context = extra_context or {} |
105 |
template_name = login_template_name |
|
106 |
if request.user.is_authenticated(): |
|
107 |
return HttpResponseRedirect(reverse('landing')) |
|
108 | 97 |
|
109 | 98 |
third_party_token = request.GET.get('key', False) |
110 | 99 |
if third_party_token: |
111 | 100 |
messages.info(request, astakos_messages.AUTH_PROVIDER_LOGIN_TO_ADD) |
112 | 101 |
|
102 |
if request.user.is_authenticated(): |
|
103 |
return HttpResponseRedirect(reverse('landing')) |
|
104 |
|
|
113 | 105 |
return render_response( |
114 | 106 |
template_name, |
115 |
login_form = LoginForm(request=request),
|
|
116 |
context_instance = get_context(request, extra_context)
|
|
107 |
login_form=LoginForm(request=request),
|
|
108 |
context_instance=get_context(request, extra_context)
|
|
117 | 109 |
) |
118 | 110 |
|
119 | 111 |
|
112 |
@require_http_methods(["GET", "POST"]) |
|
113 |
@cookie_fix |
|
114 |
@signed_terms_required |
|
115 |
def index(request, authenticated_redirect='landing', |
|
116 |
anonymous_redirect='login', extra_context=None): |
|
117 |
""" |
|
118 |
If user is authenticated redirect to ``authenticated_redirect`` url. |
|
119 |
Otherwise redirects to ``anonymous_redirect`` url. |
|
120 |
|
|
121 |
""" |
|
122 |
if request.user.is_authenticated(): |
|
123 |
return HttpResponseRedirect(reverse(authenticated_redirect)) |
|
124 |
return HttpResponseRedirect(reverse(anonymous_redirect)) |
|
125 |
|
|
126 |
|
|
120 | 127 |
@require_http_methods(["POST"]) |
121 | 128 |
@cookie_fix |
122 | 129 |
@valid_astakos_user_required |
Also available in: Unified diff