X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=portal%2Factions.py;h=b9a07378b1ed607af4ba4695656273b4e2d9f04d;hb=d04f3fd85686bee03a961494bdb4a68d6fb07ad4;hp=c3695e3673f178262f0a15819972ce24fdff74cd;hpb=530ac0c2257be4ef2e22b5d607bb9670f04b98c9;p=unfold.git diff --git a/portal/actions.py b/portal/actions.py index c3695e36..b9a07378 100644 --- a/portal/actions.py +++ b/portal/actions.py @@ -6,9 +6,9 @@ import json from django.contrib.auth.models import User from django.template.loader import render_to_string -from django.core.mail import EmailMultiAlternatives +from django.core.mail import EmailMultiAlternatives, send_mail -from myslice.theme import ThemeView +from myslice.theme import ThemeView theme = ThemeView() @@ -37,10 +37,12 @@ def authority_get_pi_emails(request, authority_hrn): print "pi_users = %s" % pi_users if any(d['pi_users'] == None for d in pi_users): - theme.template_name = 'email_default_recipients.txt' - default_email = render_to_string(theme.template, request) - default_email = default_email.replace('\n', '') - return default_email + #theme.template_name = 'email_default_recipients.txt' + #default_email = render_to_string(theme.template, request) + #default_email = default_email.replace('\n', '') + #return default_email + # the above doesn't work + return ['support@myslice.info'] else: pi_user_hrns = [ hrn for x in pi_users for hrn in x['pi_users'] ] query = Query.get('user').filter_by('user_hrn', 'included', pi_user_hrns).select('user_email') @@ -536,9 +538,26 @@ def create_pending_user(wsgi_request, request, user_detail): private_key = request['private_key'], user_hrn = request['user_hrn'], pi = '', # XXX Why not None ? + email_hash = request['email_hash'], + status = 'False', ) b.save() - + # sends email to user to activate the email + theme.template_name = 'activate_user.html' + html_content = render_to_string(theme.template, request) + theme.template_name = 'activate_user.txt' + text_content = render_to_string(theme.template, request) + theme.template_name = 'activate_user_email_subject.txt' + subject = render_to_string(theme.template, request) + subject = subject.replace('\n', '') + sender = 'support@myslice.info' + recipient = [request['email']] + #recipient = recipient.append(request['email']) + + msg = EmailMultiAlternatives(subject, text_content, sender, recipient) + msg.attach_alternative(html_content, "text/html") + msg.send() + # saves the user to django auth_user table [needed for password reset] user = User.objects.create_user(request['email'], request['email'], request['password'])