Account: download keys and jfed identity based on functions in actions.py
[unfold.git] / portal / projectrequestview.py
index 8a48428..75054dc 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):
@@ -105,8 +107,8 @@ class ProjectRequestView(LoginRequiredAutoLogoutView, ThemeView):
                     'purpose'           : wsgi_request.POST.get('purpose', ''),
                 }
 
-                if (post['authority_hrn'] is None or post['authority_hrn'] == ''):
-                    errors.append('Organization is mandatory')
+                #if (post['authority_hrn'] is None or post['authority_hrn'] == ''):
+                #    errors.append('Organization is mandatory')
     
                 if (post['purpose'] is None or post['purpose'] == ''):
                     errors.append('Project purpose is mandatory')
@@ -117,6 +119,11 @@ class ProjectRequestView(LoginRequiredAutoLogoutView, ThemeView):
             # What kind of project name is valid?
             if (post['project_name'] is None or post['project_name'] == ''):
                 errors.append('Project name is mandatory')
+
+            # max project_name length is 10
+            if (len(post['project_name']) >10):
+                errors.append('Project name can be maximum 10 characters long')
+
             
             if not errors:
                 print "is_pi on auth_hrn = ", user_authority