X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=portal%2Fregistrationview.py;h=9032125f0d65ab4fc978f3973c56c377a4f32832;hb=a602b50342633d82a2e451759cf6f91867a1c503;hp=05e0207fc13111333e31ec14b3ee874fe315f62e;hpb=3767be0431acff930350879b9562688f31484163;p=unfold.git diff --git a/portal/registrationview.py b/portal/registrationview.py index 05e0207f..9032125f 100644 --- a/portal/registrationview.py +++ b/portal/registrationview.py @@ -1,4 +1,5 @@ -import os.path, re +import os.path +import re import json from random import randint from hashlib import md5 @@ -21,6 +22,7 @@ from portal.models import PendingUser from portal.actions import create_pending_user from myslice.theme import ThemeView +from myslice.settings import logger import activity.user @@ -44,14 +46,14 @@ class RegistrationView (FreeAccessView, ThemeView): # REGISTRY ONLY TO BE REMOVED WITH MANIFOLD-V2 authorities_query = Query.get('authority').select('name', 'authority_hrn') authorities = execute_admin_query(wsgi_request, authorities_query) - print "RegistrationView authorities = ", authorities + logger.info("RegistrationView authorities = {}".format(authorities)) if authorities is not None: # Remove the root authority from the list matching = [s for s in authorities if "." in s['authority_hrn']] authorities = sorted(matching, key=lambda k: k['authority_hrn']) authorities = sorted(matching, key=lambda k: k['name']) - print "############ BREAKPOINT 1 #################" + logger.debug("############ BREAKPOINT 1 #################") # Page rendering page = Page(wsgi_request) @@ -61,7 +63,7 @@ class RegistrationView (FreeAccessView, ThemeView): page.add_css_files ( [ "css/onelab.css", "css/registration.css", "css/jquery.qtip.min.css", "css/jquery.ui.combobox.css" ] ) page.expose_js_metadata() - print "############ BREAKPOINT 2 #################" + logger.debug("############ BREAKPOINT 2 #################") if method == 'POST': reg_form = {} # The form has been submitted @@ -70,7 +72,7 @@ class RegistrationView (FreeAccessView, ThemeView): current_site = Site.objects.get_current() current_site = current_site.domain - print "############ BREAKPOINT 3 #################" + logger.debug("############ BREAKPOINT 3 #################") post_email = wsgi_request.POST.get('email','').lower() salt = randint(1,100000) email_hash = md5(str(salt)+post_email).hexdigest() @@ -84,16 +86,16 @@ class RegistrationView (FreeAccessView, ThemeView): 'current_site' : current_site, 'email_hash' : email_hash, 'pi' : '', - 'validation_link': 'https://' + current_site + '/portal/email_activation/'+ email_hash + 'validation_link': current_site + '/portal/email_activation/'+ email_hash } - print "############ BREAKPOINT 4 #################" + logger.debug("############ BREAKPOINT 4 #################") auth = wsgi_request.POST.get('org_name', None) - if auth is None: + if auth is None or auth == "": errors.append('Organization required: please select one or request its addition') else: - print "############ BREAKPOINT 5 #################" + logger.debug("############ BREAKPOINT 5 #################") # Construct user_hrn from email (XXX Should use common code) split_email = user_request['email'].split("@")[0] @@ -183,7 +185,7 @@ class RegistrationView (FreeAccessView, ThemeView): return render(wsgi_request, self.template, {'theme': self.theme}) else: - print "############ BREAKPOINT A #################" + logger.debug("############ BREAKPOINT A #################") user_request = {} ## this is coming from onelab website onelab.eu reg_form = { @@ -193,7 +195,7 @@ class RegistrationView (FreeAccessView, ThemeView): } # log user activity activity.user.signup(self.request) - print "############ BREAKPOINT B #################" + logger.debug("############ BREAKPOINT B #################") template_env = { #'topmenu_items': topmenu_items_live('Register', page), @@ -204,5 +206,5 @@ class RegistrationView (FreeAccessView, ThemeView): template_env.update(user_request) template_env.update(reg_form) template_env.update(page.prelude_env ()) - print "############ BREAKPOINT C #################" + logger.debug("############ BREAKPOINT C #################") return render(wsgi_request, self.template,template_env)