disregard
[unfold.git] / portal / registrationview.py
index dade361..88bd5ae 100644 (file)
@@ -1,11 +1,13 @@
 import os.path, re
 import json
-from random import randint
+from random     import randint
+from hashlib    import md5
 
 from django.views.generic       import View
 from django.template.loader     import render_to_string
 from django.shortcuts           import render
 from django.contrib.auth        import get_user_model
+from django.contrib.sites.models import Site
 
 from unfold.page                import Page
 from unfold.loginrequired       import FreeAccessView
@@ -45,17 +47,26 @@ class RegistrationView (FreeAccessView, ThemeView):
         page = Page(wsgi_request)
         page.add_js_files  ( [ "js/jquery.validate.js", "js/my_account.register.js" ] )
         page.add_css_files ( [ "css/onelab.css", "css/registration.css" ] )
-        page.add_css_files ( [ "http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" ] )
+        page.add_css_files ( [ "https://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" ] )
 
         if method == 'POST':
             # The form has been submitted
+            
+            # get the domain url
+            current_site = Site.objects.get_current()
+            current_site = current_site.domain
 
+            post_email = wsgi_request.POST.get('email','').lower()
+            email_hash = md5(post_email).digest().encode('base64')[:-1]
             user_request = {
                 'first_name'    : wsgi_request.POST.get('firstname',     ''),
                 'last_name'     : wsgi_request.POST.get('lastname',      ''),
                 'authority_hrn' : wsgi_request.POST.get('authority_hrn', ''),
-                'email'         : wsgi_request.POST.get('email',         '').lower(),
+                'email'         : post_email,
                 'password'      : wsgi_request.POST.get('password',      ''),
+                'current_site'  : current_site,
+                'email_hash'    : email_hash,
+                'validation_link': 'https://' + current_site + '/portal/email_activation/'+ email_hash
             }
 
             # Construct user_hrn from email (XXX Should use common code)