Create project, user authority pre-selected
authorLoic Baron <loic.baron@lip6.fr>
Fri, 10 Apr 2015 09:30:14 +0000 (11:30 +0200)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Thu, 16 Apr 2015 08:53:25 +0000 (10:53 +0200)
portal/projectrequestview.py
portal/templates/fed4fire/fed4fire_projectrequest_view.html

index 8a48428..6b1bc7c 100644 (file)
@@ -20,8 +20,10 @@ class ProjectRequestView(LoginRequiredAutoLogoutView, ThemeView):
         authorities_query = Query.get('authority').select('name', 'authority_hrn')
         authorities = execute_admin_query(request, authorities_query)
         if authorities is not None:
-            authorities = sorted(authorities, key=lambda k: k['authority_hrn'])
-            authorities = sorted(authorities, key=lambda k: k['name'])
+            # 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'])
         return authorities
     
     def getUserAuthority(self, request):
index d5885a0..d002152 100644 (file)
@@ -82,9 +82,9 @@
                     {% if authorities %}
                         {% for authority in authorities %}
                             {% if authority.name %}
-                                <option value="{{ authority.authority_hrn }}">{{authority.name}}</option>
+                                <option value="{{ authority.authority_hrn }}" {% if authority.authority_hrn == authority_hrn %}selected{% endif %}>{{authority.name}}</option>
                             {% else %}
-                                <option value="{{ authority.authority_hrn }}">{{authority.authority_hrn}}</option>
+                                <option value="{{ authority.authority_hrn }}" {% if authority.authority_hrn == authority_hrn %}selected{% endif %}>{{authority.authority_hrn}}</option>
                             {% endif %}
                         {% endfor %} 
                     {% endif %}