- user now chooses the username in the SignUp page
authorRezende & Pedro & Carlos & Raphael <rezende@land.ufrj.br>
Wed, 6 Aug 2014 23:00:26 +0000 (20:00 -0300)
committerRezende & Pedro & Carlos & Raphael <rezende@land.ufrj.br>
Wed, 6 Aug 2014 23:00:26 +0000 (20:00 -0300)
- 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

15 files changed:
portal/actions.py
portal/contactview.py
portal/homeview.py
portal/registrationview.py
portal/templates/fibre/fibre__widget-login-fed-manager.html
portal/templates/fibre/fibre__widget-topmenu.html
portal/templates/fibre/fibre_contact.html
portal/templates/fibre/fibre_home-view.html
portal/templates/fibre/fibre_institution.html
portal/templates/fibre/fibre_management-tab-requests.html
portal/templates/fibre/fibre_registration_view.html
portal/templates/fibre/fibre_slice-request-ack-view.html [new file with mode: 0644]
portal/templates/fibre/fibre_slice-request-done-view.html [new file with mode: 0644]
portal/templates/fibre/fibre_slicerequest_view.html
portal/templates/fibre/fibre_user_register_complete.html [new file with mode: 0644]

index 689e0f1..dcf51bc 100644 (file)
@@ -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:
index c41ee74..0cd940d 100644 (file)
@@ -102,5 +102,6 @@ class ContactView (FreeAccessView, ThemeView):
                 'theme' : self.theme,
                 'username': username,
                 'pi': pi,
-                'section': "Contact"
+                'section': "Contact",
+                'email': request.user.username
                 })
index ef46644..8bde68c 100644 (file)
@@ -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
index df3f2dc..5da9559 100644 (file)
@@ -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
index 638ff81..a67e2dd 100644 (file)
@@ -7,18 +7,18 @@
          {% if next %}
          <input type="hidden" name="next" value="{{ next }}" />
          {% endif %}
-       <div class="form-group" style="color:white;">
-       <label for="fed"></label>
-       <input type="radio" name="base" value="br" checked>
+        <div class="form-group" style="color:white;">
+       <!--<label for="fed"></label>
+       <input type="radio" name="base" value="br" checked>
                <img src="{{ STATIC_URL }}img/fibre/br.png" alt="Brazil" height="32" width="40" />
        <input type="radio" name="base" value="eu">
                <img src="{{ STATIC_URL }}img/fibre/eu.png" alt="Europe Union" height="32" width="32" />
-       <input type="radio" name="base" value="local">&nbsp;Local User
-       </div>
+       <input type="radio" name="base" value="local">&nbsp;Local User -->
+       </div> 
 
        <div class="form-group">
-       <label for="username">Email address / Username</label>
-       <input type="email" class="form-control" name="username" placeholder="Enter Email / username">
+       <label for="username">Email Username</label>
+       <input type="text" class="form-control" name="username" placeholder="Enter username">
        </div>
        <div class="form-group">
        <label for="password">Password</label>
index 2a73376..09d3acf 100644 (file)
                                <li><a target="_blank" href="http://www.fibre-ict.eu/">Public Website</a></li>
                        </ul>
                        {% if username %}
-                       <div class="account">You are logged in as &nbsp;<a href="/portal/account/">{{ username }}</a> &nbsp;&nbsp;|&nbsp;&nbsp; <a id="logout" style="cursor:pointer;" data-username="{{ username }}"><span class="glyphicon glyphicon-off"></span> Logout</a></div>
+                               {% if person.username %}
+                                       <div class="account">You are logged in as &nbsp;<a href="/portal/account/">{{ person.username }}</a> &nbsp;&nbsp;|&nbsp;&nbsp; <a id="logout" style="cursor:pointer;" data-username="{{ person.username }}"><span class="glyphicon glyphicon-off"></span> Logout</a></div>
+                               {% else %}
+                                       <div class="account"> You are logged in as &nbsp;<a href="/portal/account/">{{ email }}</a> &nbsp;&nbsp;|&nbsp;&nbsp; <a id="logout" style="cursor:pointer;" data-username="{{ email }}"><span class="glyphicon glyphicon-off"></span> Logout</a></div>
+                               {% endif %}
                        {% endif %}
                </div>
        </div>
index 21608da..3d4c183 100644 (file)
@@ -33,6 +33,7 @@
            </div>
            {% endfor %}
                <button type="submit" class="btn btn-onelab">Create ticket</button>
+                <button type="button" class="btn btn-onelab" onclick="window.location.href='/'">  Home  </button>
                </form>
        </div>
 </div>
index e8ec0ad..b04b911 100644 (file)
                                <a href="/portal/account/"><img src="{{ STATIC_URL }}img/icon_user_color.png" alt="" /></a>
                        </div>
                        <div>
-                               <button id="logoutbtn" type="button" class="btn btn-default" data-username="{{ username }}"><span class="glyphicon glyphicon-off"></span> Logout</button>
+                               <button id="logoutbtn" type="button" class="btn btn-default" data-username="{{ person.username }}"><span class="glyphicon glyphicon-off"></span> Logout</button>
                        </div>
                        <div>
                                {% if person.last_name %}
                                        {{person.first_name}} {{person.last_name}}<br />
                                {% endif %}
-                       <span class="label">Username:</span> <a href='/portal/account/' title="Click here to see and edit your account details.">{{person.email}}</a>
+                       <span class="label">Email:</span> <a href='/portal/account/' title="Click here to see and edit your account details.">{{person.email}}</a>
                </div>
                </div>
        </div>
                                {% if person.last_name %}
                                        {{person.first_name}} {{person.last_name}}<br />
                                {% endif %}
-                       <span class="label">Username:</span> <a href='/portal/account/' title="Click here to see and edit your account details.">{{person.email}}</a>
+                       <span class="label">Email:</span> <a href='/portal/account/' title="Click here to see and edit your account details.">{{person.email}}</a>
                </div>
                </div>
        </div>
index c7d5c01..50cbd8c 100644 (file)
@@ -51,6 +51,9 @@
                        <div>
                                <button id="deleteusers" type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Delete selected users</button>
                        </div>
+                       <p></p>
+                        <p></p>
+                        <div> <button type="button" class="btn btn-onelab" onclick="window.location.href='/'">Home</button> </div>
                        {% endif %}
                </div>
        </div>
@@ -79,6 +82,9 @@
                        {% endif %}
             <button id="renewslices" type="button" class="btn btn-primary"><span class="glyphicon glyphicon-refresh"></span> Renew Slices</button>
             <button id="deleteslices" type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Delete Slices</button>
+           <p></p>
+           <p></p>
+           <div><button type="button" class="btn btn-onelab" onclick="window.location.href='/'">Home</button></div>
         </div>
                {% endif %} 
           </div>
index 488e63e..8023e7c 100644 (file)
 {% endif %}
 <div class="col-md-12">
        <button class="btn btn-onelab" type="button" id="portal__validate" onclick="on_click_event();"><span class="glyphicon glyphicon-ok"></span> Validate</button>
+       <button type="button" class="btn btn-onelab" onclick="window.location.href='/'">Home</button>
 </div>
index 4b57f8b..a33338c 100644 (file)
            <div class="form-group">
              <label for="password" class="control-label">Authentication</label>
                  <p></p>       
-             <input type="password"  id="password" name="password"   class="form-control" style="width:250px" minlength="4" value="{{ password }}" 
+                       <input type="text" name="username" size="25" class="form-control" style="width:350px" minlength="5" value="{{ username }}" placeholder="Username" required />
+           </div>
+            <div class="form-group">
+                       <input type="password"  id="password" name="password"   class="form-control" style="width:250px" minlength="4" value="{{ password }}" 
                        title="Your password allows you to log in to this portal."
-                       placeholder="Password" required />
+                       placeholder="Password" required />      
            </div>
            <div class="form-group">
                        <input type="password"  id="confirmpassword" name="confirmpassword" style="width:250px"  minlength="4" class="form-control" value="" 
@@ -165,10 +168,54 @@ $(document).ready(function(){
                 {value:"{{ authority.name }}",label:"{{authority.name}}"},
             {% else %}
                {% if authority.authority_hrn == "fibre.ufrj" %}
-                       {value:"{{ authority.authority_hrn }}",label:"UNIVERSIDADE FEDERAL DO RIO DE JANEIRO"},
-               {% else %}
-                       {value:"{{ authority.authority_hrn }}",label:"FIBRE"},
-               {% endif %}
+                        {value:"{{ authority.authority_hrn }}",label:"UNIVERSIDADE FEDERAL DO RIO DE JANEIRO"},
+                {% else %}
+                      {% if authority.authority_hrn == "fibre.ufg" %}
+                              {value:"{{ authority.authority_hrn }}",label:"UNIVERSIDADE FEDERAL DE GOIAS"},
+                      {% else %}
+                              {% if authority.authority_hrn == "fibre.uff" %}
+                                     {value:"{{ authority.authority_hrn }}",label:"UNIVERSIDADE FEDERAL FLUMINENSE"},
+                              {% else %}
+                                     {% if authority.authority_hrn == "fibre.ufpa" %}
+                                             {value:"{{ authority.authority_hrn }}",label:"UNIVERSIDADE FEDERAL DO PARA"},
+                                     {% else %}
+                                             {% if authority.authority_hrn == "fibre.ufpe" %}
+                                                     {value:"{{ authority.authority_hrn }}",label:"UNIVERSIDADE FEDERAL DE PERNAMBUCO"},
+                                             {% else %}
+                                                     {% if authority.authority_hrn == "fibre.ufscar" %}
+                                                            {value:"{{ authority.authority_hrn }}",label:"UNIVERSIDADE FEDERAL DE SAO CARLOS"},
+                                                     {% else %}
+                                                            {% if authority.authority_hrn == "fibre.unifacs" %}
+                                                                     {value:"{{ authority.authority_hrn }}",label:"UNIVERSIDADE SALVADOR"},
+                                                            {% else %}
+                                                                     {% if authority.authority_hrn == "fibre.usp" %}
+                                                                            {value:"{{ authority.authority_hrn }}",label:"UNIVERSIDADE DE SAO PAULO"},
+                                                                     {% else %}
+                                                                            {% if authority.authority_hrn == "fibre.cpqd" %}
+                                                                                    {value:"{{ authority.authority_hrn }}",label:"CENTRO DE PESQUISA E DESENVOLVIMENTO EM TELECOMUNICACOES"},
+                                                                            {% else %}
+                                                                               {% if authority.authority_hrn == "fibre.i2cat" %}
+                                                                                       {value:"{{ authority.authority_hrn }}",label:"FOUNDATION, RESEARCH AND INNOVATION IN THE INTERNET AREA"},
+                                                                               {% else %}
+                                                                                       {% if authority.authority_hrn == "fibre.uth" %}
+                                                                                               {value:"{{ authority.authority_hrn }}",label:"UNIVERSITY OF THESSALY"},
+                                                                                       {% else %}
+                                                                                               {% if authority.authority_hrn == "fibre.bristol" %}
+                                                                                                       {value:"{{ authority.authority_hrn }}",label:"UNIVERSITY OF BRISTOL"},
+                                                                                               {% else %}
+                                                                                                       {value:"{{ authority.authority_hrn }}",label:"FIBRE"},
+                                                                                               {% endif %}
+                                                                                       {% endif %}
+                                                                               {% endif %}
+                                                                            {% endif %}
+                                                                     {% endif %}
+                                                            {% endif %}
+                                                    {% endif %}
+                                             {% endif %}
+                                    {% endif %}
+                              {% endif %}
+                      {% endif %}
+                {% endif %}
             {% endif %}
         {% endfor %}    
     {% else %}
diff --git a/portal/templates/fibre/fibre_slice-request-ack-view.html b/portal/templates/fibre/fibre_slice-request-ack-view.html
new file mode 100644 (file)
index 0000000..083693b
--- /dev/null
@@ -0,0 +1,13 @@
+{% extends "layout.html" %}
+
+{% block content %}
+
+<h1><img src="{{ STATIC_URL }}icons/slices-xs.png" alt="Slice" /> Slice request sent</h1>
+
+We will process your request and get back to you as soon as possible.
+<p></p>
+<p></p>
+<button type="button" class="btn btn-onelab" onclick="window.location.href='/'">Home</button>
+
+{% 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 (file)
index 0000000..b4f4b78
--- /dev/null
@@ -0,0 +1,12 @@
+{% extends "layout-unfold1.html" %}
+
+{% block unfold_main %}
+
+  <h1>Slice created !</h1>
+
+As you are a PI of the site, you slice has directly been created.
+<p></p>
+<p></p>
+<button type="button" class="btn btn-onelab" onclick="window.location.href='/'">Home</button>
+{% endblock %}
+
index ef78346..c71e3a7 100644 (file)
                          </div>
                          <div class="form-group">
                                {%if 'is_pi'  in pi %}
-                               <input type="text" class="form-control" id="authority_hrn" name="org_name" style="width:300px" placeholder="Organization" 
-                               title="An authority responsible for vetting your slice" required="required">
+                               <input style='display:none' type="text" class="form-control" id="authority_hrn" name="org_name" style="width:300px" placeholder="Organization" 
+                               title="An authority responsible for vetting your slice" required="required" readonly>
                                {%else%}
-                           <input type="text" class="form-control" id="authority_hrn" name="org_name" placeholder="Organization" style="width:300px;" 
+                           <input style='display:none' type="text" class="form-control" display=none  id="authority_hrn" name="org_name" placeholder="Organization" style="width:300px;" 
                                title="An authority responsible for vetting your slice" required="required" readonly>
                                {%endif%}
                          </div>
@@ -51,6 +51,7 @@
                                title="Purpose of your experiment (informative)" required="required">{{ purpose }}</textarea>
                          </div>
                          <button type="submit" class="btn btn-onelab"><span class="glyphicon glyphicon-plus"></span> Request Slice</button>
+                         <button type="button" class="btn btn-onelab" onclick="window.location.href='/'">Home</button>
                        </form>
        
                </div>
diff --git a/portal/templates/fibre/fibre_user_register_complete.html b/portal/templates/fibre/fibre_user_register_complete.html
new file mode 100644 (file)
index 0000000..4141c00
--- /dev/null
@@ -0,0 +1,21 @@
+{% extends "layout.html" %}
+
+{% block content %}
+
+<div class="row">
+       <h1><img src="{{ STATIC_URL }}img/icon_user_small.png" alt="User Registration" /> User sign-up</h1>
+</div>
+<div class="row">
+  <h3>Sign up information received.</h3>
+  <p>You can now log in to the portal. You will have limited access. </p>
+  <p>To gain full access, two steps are required:</p>
+  <ul>
+       <li>1. You confirm your signup request by clicking on the link in the email that we have sent to your email address.</li>
+       <li>2. A manager from your organization validates your request. (We have sent email to your organisation's registered managers.)</li>
+  </ul>
+       <p></p>
+       <p></p>
+       <div><button type="button" class="btn btn-onelab" onclick="window.location.href='/'">Home</button></div>                
+</div>
+
+{% endblock %}