X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=portal%2Femailactivationview.py;h=2a3e6179e4531eddd7749c89ceba5a0f05a43f99;hb=33b8be6fd7245e0902e11137ed16ccbce2afe701;hp=dd3788ad3a4d34ec77ea24417cf8ddbfe7a0bdbc;hpb=d04f3fd85686bee03a961494bdb4a68d6fb07ad4;p=myslice.git diff --git a/portal/emailactivationview.py b/portal/emailactivationview.py index dd3788ad..2a3e6179 100644 --- a/portal/emailactivationview.py +++ b/portal/emailactivationview.py @@ -2,7 +2,7 @@ from unfold.loginrequired import FreeAccessView # from manifold.core.query import Query from manifoldapi.manifoldapi import execute_query, execute_admin_query -from portal.actions import manifold_update_user, manifold_update_account, manifold_add_account, manifold_delete_account, sfa_update_user +from portal.actions import manifold_update_user, manifold_update_account, manifold_add_account, manifold_delete_account, sfa_update_user, authority_get_pi_emails # from unfold.page import Page from ui.topmenu import topmenu_items_live, the_user @@ -12,6 +12,9 @@ from django.contrib import messages from django.contrib.auth.decorators import login_required from myslice.theme import ThemeView from portal.models import PendingUser +from django.core.mail import EmailMultiAlternatives, send_mail +from django.contrib.sites.models import Site + # import json, os, re, itertools @@ -33,15 +36,50 @@ class ActivateEmailView(FreeAccessView, ThemeView): if key == "hash_code": hash_code=value - if PendingUser.objects.filter(email_hash__iexact = hash_code): + if PendingUser.objects.filter(email_hash__iexact = hash_code): #get_user = PendingUser.objects.filter(email_hash__iexact = hash_code) #get_user.status= 'True' #get_user.save() + #for user in PendingUser.objects.all(): + # first_name = user.first_name + # last_name = user.last_name + # authority_hrn = user.authority_hrn + # public_key = user.public_key + # email = user.email + # user_hrn = user.user_hrn PendingUser.objects.filter(email_hash__iexact = hash_code).update(status='True') activation = 'success' + # sending email after activation success + #try: + # Send an email: the recipients are the PI of the authority + # If No PI is defined for this Authority, send to a default email (different for each theme) + # recipients = authority_get_pi_emails(wsgi_request, authority_hrn) + # theme.template_name = 'user_request_email.html' + # html_content = render_to_string(theme.template, request) + # theme.template_name = 'user_request_email.txt' + # text_content = render_to_string(theme.template, request) + # theme.template_name = 'user_request_email_subject.txt' + # subject = render_to_string(theme.template, request) + # subject = subject.replace('\n', '') + # theme.template_name = 'email_default_sender.txt' + # sender = render_to_string(theme.template, request) + # sender = sender.replace('\n', '') + # msg = EmailMultiAlternatives(subject, text_content, sender, recipients) + # msg.attach_alternative(html_content, "text/html") + # msg.send() + # except Exception, e: + # print "Failed to send email, please check the mail templates and the SMTP configuration of your server" + # import traceback + # traceback.print_exc() + else: activation = 'failed' + + # get the domain url + current_site = Site.objects.get_current() + current_site = current_site.domain + context = super(ActivateEmailView, self).get_context_data(**kwargs) context['activation_status'] = activation # XXX This is repeated in all pages @@ -51,6 +89,13 @@ class ActivateEmailView(FreeAccessView, ThemeView): context['topmenu_items'] = topmenu_items_live('My Account', page) # so we can sho who is logged context['username'] = the_user(self.request) + #context['first_name'] = first_name + #context['last_name'] = last_name + #context['authority_hrn'] = authority_hrn + #context['public_key'] = public_key + #context['email'] = email + #context['user_hrn'] = user_hrn + #context['current_site'] = current_site context['theme'] = self.theme # context ['firstname'] = config['firstname'] prelude_env = page.prelude_env()