Emails: use templates for all emails - To be tested !
[unfold.git] / portal / registrationview.py
index f79b1b5..9f5f39f 100644 (file)
@@ -2,7 +2,6 @@ import os.path, re
 import json
 from random import randint
 
-from django.core.mail           import send_mail
 from django.views.generic       import View
 from django.template.loader     import render_to_string
 from django.shortcuts           import render
@@ -63,7 +62,7 @@ class RegistrationView (FreeAccessView, ThemeView):
             split_email = user_request['email'].split("@")[0] 
             split_email = split_email.replace(".", "_")
             user_request['user_hrn'] = user_request['authority_hrn'] \
-                     + '.' + split_email + str(randint(1,1000000))
+                     + '.' + split_email
             
             # Validate input
             UserModel = get_user_model()
@@ -88,7 +87,11 @@ class RegistrationView (FreeAccessView, ThemeView):
             for user in user_details_sfa:
                 if user['user_email'] == user_request['email']:
                     errors.append('Email already registered in SFA registry. Please use another email.')
-
+                if user['user_hrn'] == user_request['user_hrn']:
+                    # add random number if user_hrn already exists in the registry
+                    user_request['user_hrn'] = user_request['authority_hrn'] \
+                            + '.' + split_email + str(randint(1,1000000))
+                
             # XXX TODO: Factorize with portal/accountview.py
             if 'generate' in wsgi_request.POST['question']:
                 user_request['auth_type'] = 'managed'