- # checking if pi or not
- if acc_auth_cred == {} or acc_auth_cred == 'N/A':
- pi = "is_not_pi"
- else:
- pi = "is_pi"
-
-
- # Page rendering
- page = Page(wsgi_request)
- page.add_js_files ( [ "js/jquery.validate.js", "js/jquery-ui.js" ] )
- page.add_css_files ( [ "https://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" ] )
- page.expose_js_metadata()
-
- if method == 'POST':
- # The form has been submitted
-
- # get the domain url
- current_site = Site.objects.get_current()
- current_site = current_site.domain
-
- # getting the authority_hrn from the selected organization
- for authority in authorities:
- if authority['name'] == wsgi_request.POST.get('org_name', ''):
- authority_hrn = authority['authority_hrn']
-
- # Handle the case when we use only hrn and not name
- if authority_hrn is None:
- authority_hrn = wsgi_request.POST.get('org_name', '')
-
- slice_request = {
- 'type' : 'slice',
- 'id' : None,
- 'user_hrn' : user_hrn,
- 'email' : user_email,
- 'timestamp' : time.time(),
- 'authority_hrn' : authority_hrn,
- 'organization' : wsgi_request.POST.get('org_name', ''),
- 'slice_name' : wsgi_request.POST.get('slice_name', ''),
- 'url' : wsgi_request.POST.get('url', ''),
- 'purpose' : wsgi_request.POST.get('purpose', ''),
- 'current_site' : current_site
- }
-
- # 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 (slice_name is None or slice_name == ''):
- errors.append('Slice name is mandatory')
-
- if (re.search(r'^[A-Za-z0-9_]*$', slice_name) == None):
- errors.append('Slice name may contain only letters, numbers, and underscore.')
-
- organization = slice_request['organization']
- if (organization is None or organization == ''):
- errors.append('Organization is mandatory')
+ def getUserEmail(self, request):
+ # Get user_email (XXX Would deserve to be simplified)
+ user_query = Query().get('local:user').select('email','config')
+ user_details = execute_query(request, user_query)
+ user_email = user_details[0].get('email')
+ return user_email
+
+ def post(self, request):
+ return self.handle_request(request, 'POST')