From: Rezende & Pedro & Carlos & Raphael Date: Wed, 6 Aug 2014 23:00:26 +0000 (-0300) Subject: - user now chooses the username in the SignUp page X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=ce9d7fe0417a2085c0e525f6f1f03a96fc42fc07;p=myslice.git - user now chooses the username in the SignUp page - button added to come back to the home page - authentication flags (BR,EU) removed - username in the top menu and email in the home page - slice request without organization (gotten from the username) - emails sent to the right PIs --- diff --git a/portal/actions.py b/portal/actions.py index 689e0f1d..dcf51bc0 100644 --- a/portal/actions.py +++ b/portal/actions.py @@ -230,6 +230,7 @@ def make_request_user(user): request['user_hrn'] = user.user_hrn request['public_key'] = user.public_key request['private_key'] = user.private_key + request['username'] = user.login return request def make_request_slice(slice): @@ -327,10 +328,6 @@ def portal_validate_request(wsgi_request, request_ids): if request['type'] == 'user': try: - split_email = request['email'].split("@")[0] - split_email = split_email.replace(".", "_") - split_authority = request['authority_hrn'].split(".")[1] - request['username'] = split_email + '@' + split_authority create_user(wsgi_request, request) request_status['SFA user'] = {'status': True } PendingUser.objects.get(id=request['id']).delete() @@ -750,6 +747,7 @@ def create_pending_user(wsgi_request, request, user_detail): last_name = request['last_name'], authority_hrn = request['authority_hrn'], email = request['email'], + login = request['username'], password = request['password'], public_key = request['public_key'], private_key = request['private_key'], @@ -760,11 +758,6 @@ def create_pending_user(wsgi_request, request, user_detail): ) b.save() - split_email = request['email'].split("@")[0] - split_email = split_email.replace(".", "_") - split_authority = request['authority_hrn'].split(".")[1] - request['username'] = split_email + '@' + split_authority - # sends email to user to activate the email theme.template_name = 'activate_user.html' html_content = render_to_string(theme.template, request) @@ -833,7 +826,20 @@ def create_pending_user(wsgi_request, request, user_detail): split_authority_hrn = request['authority_hrn'].split(".")[0] recipients = authority_get_pi_emails(wsgi_request, split_authority_hrn) - + + pis = authority_get_pis(request, split_authority_hrn) + pi_emails = [] + for x in pis: + for e in x['pi_users']: + try: + u = e.split(".")[1] + y = User.objects.get(username = u) + if y.username.count("@") != 0: + if y.username.split("@")[1] == request['username'].split("@")[1]: + pi_emails += [y.email] + except: + print "fail" + theme.template_name = 'user_request_email.html' html_content = render_to_string(theme.template, request) @@ -848,7 +854,8 @@ def create_pending_user(wsgi_request, request, user_detail): sender = render_to_string(theme.template, request) sender = sender.replace('\n', '') - msg = EmailMultiAlternatives(subject, text_content, sender, recipients) + msg = EmailMultiAlternatives(subject, text_content, sender, pi_emails) + msg.attach_alternative(html_content, "text/html") msg.send() except Exception, e: diff --git a/portal/contactview.py b/portal/contactview.py index c41ee74d..0cd940d9 100644 --- a/portal/contactview.py +++ b/portal/contactview.py @@ -102,5 +102,6 @@ class ContactView (FreeAccessView, ThemeView): 'theme' : self.theme, 'username': username, 'pi': pi, - 'section': "Contact" + 'section': "Contact", + 'email': request.user.username }) diff --git a/portal/homeview.py b/portal/homeview.py index ef466448..8bde68ca 100644 --- a/portal/homeview.py +++ b/portal/homeview.py @@ -32,7 +32,7 @@ class HomeView (FreeAccessView, ThemeView): env['theme'] = self.theme env['section'] = "Dashboard" - username = request.POST.get('username') + username = request.POST.get('username').lower() password = request.POST.get('password') # LDAP form - If FIBRE, then get the possibilite to authenticate using usernameldap diff --git a/portal/registrationview.py b/portal/registrationview.py index df3f2dc7..5da95598 100644 --- a/portal/registrationview.py +++ b/portal/registrationview.py @@ -17,6 +17,7 @@ from manifoldapi.manifoldapi import execute_admin_query from manifold.core.query import Query from portal.models import PendingUser +from django.contrib.auth.models import User #Pedro #from portal.actions import create_pending_user # Edelberto - LDAP from portal.actions import create_pending_user, ldap_create_user @@ -80,6 +81,7 @@ class RegistrationView (FreeAccessView, ThemeView): 'organization' : wsgi_request.POST.get('org_name', ''), 'authority_hrn' : authority_hrn, 'email' : post_email, + 'username' : wsgi_request.POST.get('username','').lower(), 'password' : wsgi_request.POST.get('password', ''), 'current_site' : current_site, 'email_hash' : email_hash, @@ -93,15 +95,16 @@ class RegistrationView (FreeAccessView, ThemeView): # user_request['user_hrn'] = user_request['authority_hrn'] \ # + '.' + split_email - split_email = user_request['email'].split("@")[0] - split_email = split_email.replace(".", "_") - # Replace + by _ => more convenient for testing and validate with a real email - split_email = split_email.replace("+", "_") + username = user_request['username'] - split_authority = user_request['authority_hrn'].split(".")[1] - username = split_email + '@' + split_authority - split_authority = user_request['authority_hrn'].split(".")[0] - user_request['user_hrn'] = split_authority + '.' + username + if user_request['authority_hrn'] == "fibre" : + user_request['username'] = user_request['username'] + "@" + "" # to be defined + else : + split_authority = user_request['authority_hrn'].split(".")[1] + user_request['username'] = user_request['username'] + '@' + split_authority + split_authority = user_request['authority_hrn'].split(".")[0] + + user_request['user_hrn'] = split_authority + '.' + user_request['username'] # Validate input UserModel = get_user_model() @@ -109,11 +112,15 @@ class RegistrationView (FreeAccessView, ThemeView): errors.append('First name may contain only letters, numbers, spaces and @/./+/-/_ characters.') if (re.search(r'^[\w+\s.@+-]+$', user_request['last_name']) == None): errors.append('Last name may contain only letters, numbers, spaces and @/./+/-/_ characters.') + if (re.search(r'^[\w,]+$' , username) == None): + errors.append('Username may contain only letters,numbers and -/_ characters.') # checking in django_db !! if PendingUser.objects.filter(email__iexact = user_request['email']): errors.append('Email is pending for validation. Please provide a new email address.') - if UserModel._default_manager.filter(email__iexact = user_request['email']): - errors.append('This email is not usable. Please contact the administrator or try with another email.') + # if UserModel._default_manager.filter(email__iexact = user_request['email']): + # errors.append('This email is not usable. Please contact the administrator or try with another email.') + if User.objects.filter(username__iexact = user_request['username']): + errors.append('This username is already in use, try another one') # Does the user exist in Manifold? user_query = Query().get('local:user').select('user_id','email') user_details = execute_admin_query(wsgi_request, user_query) @@ -126,13 +133,13 @@ class RegistrationView (FreeAccessView, ThemeView): user_query = Query().get('user').select('user_hrn','user_email').filter_by('user_hrn','==',user_request['user_hrn']) user_details_sfa = execute_admin_query(wsgi_request, user_query) - 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)) + # 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 # XXX TODO: Factorize with portal/registrationview.py diff --git a/portal/templates/fibre/fibre__widget-login-fed-manager.html b/portal/templates/fibre/fibre__widget-login-fed-manager.html index 638ff811..a67e2ddb 100644 --- a/portal/templates/fibre/fibre__widget-login-fed-manager.html +++ b/portal/templates/fibre/fibre__widget-login-fed-manager.html @@ -7,18 +7,18 @@ {% if next %} {% endif %} -
- - +
+ +
- - + +
diff --git a/portal/templates/fibre/fibre__widget-topmenu.html b/portal/templates/fibre/fibre__widget-topmenu.html index 2a73376e..09d3acfb 100644 --- a/portal/templates/fibre/fibre__widget-topmenu.html +++ b/portal/templates/fibre/fibre__widget-topmenu.html @@ -35,7 +35,11 @@
  • Public Website
  • {% if username %} - + {% if person.username %} + + {% else %} + + {% endif %} {% endif %}
    diff --git a/portal/templates/fibre/fibre_contact.html b/portal/templates/fibre/fibre_contact.html index 21608da4..3d4c183f 100644 --- a/portal/templates/fibre/fibre_contact.html +++ b/portal/templates/fibre/fibre_contact.html @@ -33,6 +33,7 @@ {% endfor %} + diff --git a/portal/templates/fibre/fibre_home-view.html b/portal/templates/fibre/fibre_home-view.html index e8ec0adc..b04b911d 100644 --- a/portal/templates/fibre/fibre_home-view.html +++ b/portal/templates/fibre/fibre_home-view.html @@ -61,13 +61,13 @@
    - +
    {% if person.last_name %} {{person.first_name}} {{person.last_name}}
    {% endif %} - Username: {{person.email}} + Email: {{person.email}}
    @@ -123,7 +123,7 @@ {% if person.last_name %} {{person.first_name}} {{person.last_name}}
    {% endif %} - Username: {{person.email}} + Email: {{person.email}} diff --git a/portal/templates/fibre/fibre_institution.html b/portal/templates/fibre/fibre_institution.html index c7d5c013..50cbd8c9 100644 --- a/portal/templates/fibre/fibre_institution.html +++ b/portal/templates/fibre/fibre_institution.html @@ -51,6 +51,9 @@
    +

    +

    +
    {% endif %} @@ -79,6 +82,9 @@ {% endif %} +

    +

    +
    {% endif %} diff --git a/portal/templates/fibre/fibre_management-tab-requests.html b/portal/templates/fibre/fibre_management-tab-requests.html index 488e63e0..8023e7c6 100644 --- a/portal/templates/fibre/fibre_management-tab-requests.html +++ b/portal/templates/fibre/fibre_management-tab-requests.html @@ -223,4 +223,5 @@ {% endif %}
    +
    diff --git a/portal/templates/fibre/fibre_registration_view.html b/portal/templates/fibre/fibre_registration_view.html index 4b57f8bb..a33338c3 100644 --- a/portal/templates/fibre/fibre_registration_view.html +++ b/portal/templates/fibre/fibre_registration_view.html @@ -63,9 +63,12 @@

    - +
    +
    + + placeholder="Password" required />
    Slice Slice request sent + +We will process your request and get back to you as soon as possible. +

    +

    + + +{% endblock %} + diff --git a/portal/templates/fibre/fibre_slice-request-done-view.html b/portal/templates/fibre/fibre_slice-request-done-view.html new file mode 100644 index 00000000..b4f4b78d --- /dev/null +++ b/portal/templates/fibre/fibre_slice-request-done-view.html @@ -0,0 +1,12 @@ +{% extends "layout-unfold1.html" %} + +{% block unfold_main %} + +

    Slice created !

    + +As you are a PI of the site, you slice has directly been created. +

    +

    + +{% endblock %} + diff --git a/portal/templates/fibre/fibre_slicerequest_view.html b/portal/templates/fibre/fibre_slicerequest_view.html index ef783464..c71e3a7a 100644 --- a/portal/templates/fibre/fibre_slicerequest_view.html +++ b/portal/templates/fibre/fibre_slicerequest_view.html @@ -35,10 +35,10 @@
    {%if 'is_pi' in pi %} - + {%else%} - {%endif%}
    @@ -51,6 +51,7 @@ title="Purpose of your experiment (informative)" required="required">{{ purpose }} + diff --git a/portal/templates/fibre/fibre_user_register_complete.html b/portal/templates/fibre/fibre_user_register_complete.html new file mode 100644 index 00000000..4141c006 --- /dev/null +++ b/portal/templates/fibre/fibre_user_register_complete.html @@ -0,0 +1,21 @@ +{% extends "layout.html" %} + +{% block content %} + +
    +

    User Registration User sign-up

    +
    +
    +

    Sign up information received.

    +

    You can now log in to the portal. You will have limited access.

    +

    To gain full access, two steps are required:

    + +

    +

    +
    +
    + +{% endblock %}