Create project, user authority pre-selected
[unfold.git] / portal / projectrequestview.py
index 8a48428..64dcbde 100644 (file)
@@ -1,3 +1,7 @@
+import json
+import time
+import re
+
 from django.shortcuts           import render
 from django.contrib.sites.models import Site
 
@@ -10,8 +14,7 @@ from portal.actions import create_pending_project, create_pending_join, sfa_add_
 from portal.models import PendingProject, PendingJoin
 
 from myslice.theme import ThemeView
-
-import json, time, re
+from myslice.settings import logger
 
 class ProjectRequestView(LoginRequiredAutoLogoutView, ThemeView):
     template_name = 'projectrequest_view.html'
@@ -20,8 +23,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):
@@ -119,7 +124,7 @@ class ProjectRequestView(LoginRequiredAutoLogoutView, ThemeView):
                 errors.append('Project name is mandatory')
             
             if not errors:
-                print "is_pi on auth_hrn = ", user_authority
+                logger.info("is_pi on auth_hrn = {}".format(user_authority))
                 if is_pi(wsgi_request, user_hrn, user_authority):
                     # PIs can directly create/join project in their own authority...
                     if 'join' in wsgi_request.POST: