Revision a0be6a0c snf-astakos-app/astakos/im/views.py
b/snf-astakos-app/astakos/im/views.py | ||
---|---|---|
59 | 59 |
from astakos.im.util import get_context, prepare_response, set_cookie, get_query |
60 | 60 |
from astakos.im.forms import * |
61 | 61 |
from astakos.im.functions import send_greeting, send_feedback, SendMailError, \ |
62 |
invite as invite_func, logout as auth_logout |
|
62 |
invite as invite_func, logout as auth_logout, send_helpdesk_notification
|
|
63 | 63 |
from astakos.im.settings import DEFAULT_CONTACT_EMAIL, DEFAULT_FROM_EMAIL, COOKIE_NAME, COOKIE_DOMAIN, IM_MODULES, SITENAME, LOGOUT_NEXT, LOGGING_LEVEL |
64 | 64 |
|
65 | 65 |
logger = logging.getLogger(__name__) |
... | ... | |
431 | 431 |
return response |
432 | 432 |
|
433 | 433 |
@transaction.commit_manually |
434 |
def activate(request, email_template_name='im/welcome_email.txt', on_failure='im/signup.html'): |
|
434 |
def activate(request, email_template_name='im/welcome_email.txt', on_failure='im/signup.html', |
|
435 |
helpdesk_email_template_name='im/helpdesk_notification.txt'): |
|
435 | 436 |
""" |
436 | 437 |
Activates the user identified by the ``auth`` request parameter, sends a welcome email |
437 | 438 |
and renews the user token. |
... | ... | |
451 | 452 |
messages.add_message(request, messages.ERROR, message) |
452 | 453 |
return render_response(on_failure) |
453 | 454 |
|
455 |
notify_helpdesk = False |
|
454 | 456 |
try: |
455 | 457 |
local_user = AstakosUser.objects.get(~Q(id = user.id), email=user.email, is_active=True) |
456 | 458 |
except AstakosUser.DoesNotExist: |
... | ... | |
460 | 462 |
user.save() |
461 | 463 |
except ValidationError, e: |
462 | 464 |
return HttpResponseBadRequest(e) |
465 |
notify_helpdesk = True |
|
463 | 466 |
else: |
464 | 467 |
# switch the existing account to shibboleth one |
465 | 468 |
if user.provider == 'shibboleth': |
... | ... | |
474 | 477 |
user = local_user |
475 | 478 |
|
476 | 479 |
try: |
480 |
if notify_helpdesk: |
|
481 |
send_helpdesk_notification(user, helpdesk_email_template_name) |
|
477 | 482 |
send_greeting(user, email_template_name) |
478 | 483 |
response = prepare_response(request, user, next, renew=True) |
479 | 484 |
transaction.commit() |
Also available in: Unified diff