Revision ebd369d0 snf-astakos-app/astakos/im/views.py
b/snf-astakos-app/astakos/im/views.py | ||
---|---|---|
50 | 50 |
from django.contrib.auth import logout as auth_logout |
51 | 51 |
from django.utils.http import urlencode |
52 | 52 |
from django.http import HttpResponseRedirect |
53 |
from django.db.utils import IntegrityError |
|
53 | 54 |
|
54 | 55 |
from astakos.im.models import AstakosUser, Invitation |
55 | 56 |
from astakos.im.backends import get_backend |
... | ... | |
116 | 117 |
formclass = 'LoginForm' |
117 | 118 |
kwargs = {} |
118 | 119 |
if request.user.is_authenticated(): |
119 |
template_name = profile_template_name |
|
120 |
formclass = 'ProfileForm' |
|
121 |
kwargs.update({'instance':request.user}) |
|
120 |
return HttpResponseRedirect(reverse('astakos.im.views.edit_profile')) |
|
122 | 121 |
return render_response(template_name, |
123 | 122 |
form = globals()[formclass](**kwargs), |
124 | 123 |
context_instance = get_context(request, extra_context)) |
... | ... | |
177 | 176 |
status = messages.ERROR |
178 | 177 |
message = getattr(e, 'strerror', '') |
179 | 178 |
transaction.rollback() |
179 |
except IntegrityError, e: |
|
180 |
status = messages.ERROR |
|
181 |
message = _('There is already invitation for %s' % username) |
|
182 |
transaction.rollback() |
|
180 | 183 |
else: |
181 | 184 |
status = messages.ERROR |
182 | 185 |
message = _('No invitations left') |
... | ... | |
261 | 264 |
Upon successful user creation if ``next`` url parameter is present the user is redirected there |
262 | 265 |
otherwise renders the same page with a success message. |
263 | 266 |
|
264 |
On unsuccessful creation, renders the same page with an error message.
|
|
267 |
On unsuccessful creation, renders ``on_failure`` with an error message.
|
|
265 | 268 |
|
266 | 269 |
**Arguments** |
267 | 270 |
|
... | ... | |
405 | 408 |
return HttpResponseBadRequest('No such user') |
406 | 409 |
|
407 | 410 |
user.is_active = True |
411 |
user.email_verified = True |
|
408 | 412 |
user.save() |
409 | 413 |
return prepare_response(request, user, next, renew=True) |
Also available in: Unified diff