+ def handle_request(self, wsgi_request, method):
+ errors = []
+ authority_hrn = None
+ authority_name = None
+
+ user_hrn = self.getUserHrn(wsgi_request)
+
+ authorities = self.getAuthorities(wsgi_request)
+
+ user_authority = self.getUserAuthority(wsgi_request)
+
+ # getting the org from authority
+ for authority in authorities:
+ if authority['authority_hrn'] == user_authority:
+ authority_name = authority['name']
+
+ if method == 'POST' :
+
+ post = {
+ 'user_hrn' : user_hrn,
+ 'authority_hrn' : wsgi_request.POST.get('authority_name', ''),
+ 'project_name' : wsgi_request.POST.get('project_name', ''),
+ 'purpose' : wsgi_request.POST.get('purpose', ''),
+ }
+
+# # create slice_hrn based on authority_hrn and slice_name
+# # slice_name = slice_request['slice_name']
+# req_slice_hrn = authority_hrn + '.' + slice_name
+# # comparing requested slice_hrn with the existing slice_hrn
+# slice_query = Query().get('myslice:slice').select('slice_hrn','parent_authority').filter_by('parent_authority','==',authority_hrn)
+# slice_details_sfa = execute_admin_query(wsgi_request, slice_query)
+# for _slice in slice_details_sfa:
+# if _slice['slice_hrn'] == req_slice_hrn:
+# errors.append('Slice already exists. Please use a different slice name.')
+
+
+ # What kind of slice name is valid?
+ if (post['project_name'] is None or post['project_name'] == ''):
+ errors.append('Project name is mandatory')
+
+ if (re.search(r'^[A-Za-z0-9_]*$', post['project_name']) == None):
+ errors.append('Project name may contain only letters, numbers, and underscore.')
+
+ 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('Experiment purpose is mandatory')
+
+ if not errors:
+ create_pending_project(wsgi_request, post)
+
+ # retrieves the pending projects list
+ pending_projects = PendingProject.objects.all().filter(user_hrn=user_hrn)
+
+ env = {
+ 'errors': errors,
+ 'username': wsgi_request.user,
+ 'theme': self.theme,
+ 'authorities': authorities,
+ 'authority_hrn': user_authority,
+ 'pending_projects': pending_projects,
+ }
+ return render(wsgi_request, self.template, env)
+
+
+