- # We shall use a form here
-
- #get_email = PendingUser.objects.get(email)
- reg_fname = request.POST.get('firstname', '')
- reg_lname = request.POST.get('lastname', '')
- #reg_aff = request.POST.get('affiliation','')
- reg_auth = request.POST.get('authority_hrn', '')
- reg_login = request.POST.get('login', '')
- reg_email = request.POST.get('email','').lower()
- #prepare user_hrn
- split_email = reg_email.split("@")[0]
+ reg_form = {}
+ # The form has been submitted
+
+ # get the domain url
+ current_site = Site.objects.get_current()
+ current_site = current_site.domain
+
+ print "############ BREAKPOINT 3 #################"
+
+ for authority in authorities:
+ if authority['name'] == wsgi_request.POST.get('org_name', ''):
+ authority_hrn = authority['authority_hrn']
+
+ # Handle the case when the template uses only hrn and not name
+ if authority_hrn is None:
+ authority_hrn = wsgi_request.POST.get('org_name', '')
+
+ print "############ BREAKPOINT 4 #################"
+
+ post_email = wsgi_request.POST.get('email','').lower()
+ salt = randint(1,100000)
+ email_hash = md5(str(salt)+post_email).hexdigest()
+ #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', ''),
+ 'organization' : wsgi_request.POST.get('org_name', ''),
+ 'authority_hrn' : authority_hrn,
+ 'email' : post_email,
+ 'password' : wsgi_request.POST.get('password', ''),
+ 'current_site' : current_site,
+ 'email_hash' : email_hash,
+ 'pi' : '',
+ 'validation_link': 'http://' + current_site + '/portal/email_activation/'+ email_hash
+ }
+
+ print "############ BREAKPOINT 5 #################"
+
+ # Construct user_hrn from email (XXX Should use common code)
+ split_email = user_request['email'].split("@")[0]