From 2b16c15727efe54e24e788487193d4266da5762c Mon Sep 17 00:00:00 2001 From: Leonidas Poulopoulos Date: Sun, 3 Feb 2013 21:20:15 +0200 Subject: [PATCH] Minor change in the user activation procedure --- flowspec/views.py | 22 +++++++++++++++++-- .../registration/activation_email_peer_notify.txt | 23 ++++++++++++++++++++ .../activation_email_peer_notify_subject.txt | 1 + 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 templates/registration/activation_email_peer_notify.txt create mode 100644 templates/registration/activation_email_peer_notify_subject.txt diff --git a/flowspec/views.py b/flowspec/views.py index bb48d81..6ba6fa7 100644 --- a/flowspec/views.py +++ b/flowspec/views.py @@ -374,9 +374,14 @@ def user_login(request): def user_activation_notify(user): current_site = Site.objects.get_current() + peer = user.get_profile().peer + + + # Email subject *must not* contain newlines + # TechCs will be notified about new users. + # Platform admins will activate the users. subject = render_to_string('registration/activation_email_subject.txt', { 'site': current_site }) - # Email subject *must not* contain newlines subject = ''.join(subject.splitlines()) registration_profile = RegistrationProfile.objects.create_profile(user) message = render_to_string('registration/activation_email.txt', @@ -384,6 +389,20 @@ def user_activation_notify(user): 'expiration_days': settings.ACCOUNT_ACTIVATION_DAYS, 'site': current_site, 'user': user }) + if settings.NOTIFY_ADMIN_MAILS: + admin_mails = settings.NOTIFY_ADMIN_MAILS + send_new_mail(settings.EMAIL_SUBJECT_PREFIX + subject, + message, settings.SERVER_EMAIL, + admin_mails, []) + + # Mail to domain techCs plus platform admins (no activation hash sent) + subject = render_to_string('registration/activation_email_peer_notify_subject.txt', + { 'site': current_site, + 'peer': peer }) + subject = ''.join(subject.splitlines()) + message = render_to_string('registration/activation_email_peer_notify.txt', + { 'user': user, + 'peer': peer }) send_new_mail(settings.EMAIL_SUBJECT_PREFIX + subject, message, settings.SERVER_EMAIL, get_peer_techc_mails(user), []) @@ -495,7 +514,6 @@ def get_peer_techc_mails(user): techmails_list.append(techmail.email) if settings.NOTIFY_ADMIN_MAILS: additional_mail = settings.NOTIFY_ADMIN_MAILS -# mail.extend(user_mail) mail.extend(additional_mail) mail.extend(techmails_list) return mail diff --git a/templates/registration/activation_email_peer_notify.txt b/templates/registration/activation_email_peer_notify.txt new file mode 100644 index 0000000..b9087d4 --- /dev/null +++ b/templates/registration/activation_email_peer_notify.txt @@ -0,0 +1,23 @@ +Ο/H {{ user.get_full_name }} έκανε αίτηση για νεό λογαριασμό στην υπηρεσία Firewall On Demand +εκ μέρους του ιδρύματος/φορέα: {{peer}}. + +Όνομα χρήστη: {{ user.username }} +E-mail: {{ user.email }} + +Ο χρήστης θα ενημερωθεί για την ενεργοποίηση του λογαριασμού του μέσω e-mail. + +Σε περίπτωση που ο χρήστης δεν ανήκει στο ίδρυμα/φορέα σας ή χρησιμοποιεί την υπηρεσία ενάντια στον +εσωτερικό σας κανονισμό παρακαλούμε επικοινωνήστε άμεσα μαζί μας. + +----------------------------------------------------------------------------- + +{{ user.get_full_name }} has registered for a new Firewall on Demand account on behalf of your +institution: {{peer}}. + +Username: {{user.username}} +E-mail: {{user.email}} + +The user will be notified via mail about the account activation + +In case this user does not belong to your institution or attempts to use the service without being +compliant to your instututions' regulation please contact us. diff --git a/templates/registration/activation_email_peer_notify_subject.txt b/templates/registration/activation_email_peer_notify_subject.txt new file mode 100644 index 0000000..2f7f340 --- /dev/null +++ b/templates/registration/activation_email_peer_notify_subject.txt @@ -0,0 +1 @@ +GRNET Firewall on Demand new account registration at {{ site.name }} on behalf of {{peer}} -- 1.7.10.4