def get_or_post (self, request, method):
"""
"""
- from django.conf import settings
- print "_"*80
- print settings.TEMPLATE_CONTEXT_PROCESSORS
- print "_"*80
errors = []
slice_name =''
authority_hrn = None
authority_name = None
# Retrieve the list of authorities
- authorities_query = Query.get('authority').select('name', 'authority_hrn')
+ if self.theme == 'fed4fire':
+ authorities_query = Query.get('myslice:authority').select('authority_hrn')
+ else:
+ 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'])
+ if self.theme != 'fed4fire':
+ authorities = sorted(authorities, key=lambda k: k['name'])
# Get user_email (XXX Would deserve to be simplified)
user_query = Query().get('local:user').select('email','config')
user_authority = user_config.get('authority','N/A')
# getting the org from authority
for authority in authorities:
- if authority['authority_hrn'] == user_authority:
+ if 'name' in authority and authority['authority_hrn'] == user_authority:
authority_name = authority['name']
# Handle the case when we use only hrn and not name
# 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'] == request.POST.get('org_name', ''):
- authority_hrn = authority['authority_hrn']
+
+ if theme.theme != 'fed4fire':
+ # getting the authority_hrn from the selected organization
+ for authority in authorities:
+ if authority['name'] == 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:
if project is not None and project != '':
authority_hrn = project
+ slice_name = request.POST.get('slice_name', '')
+ if not slice_name or len(slice_name) == 0 :
+ errors.append('Slice name can\'t be empty')
+
+ # accept only lowercase names
+ slice_name = slice_name.lower()
+
slice_request = {
'type' : 'slice',
'id' : None,
'timestamp' : time.time(),
'authority_hrn' : authority_hrn,
'organization' : request.POST.get('org_name', ''),
- 'slice_name' : request.POST.get('slice_name', ''),
+ 'slice_name' : slice_name,
'url' : request.POST.get('url', ''),
'purpose' : request.POST.get('purpose', ''),
'current_site' : current_site
}
-
- # create slice_hrn based on authority_hrn and slice_name
- slice_name = slice_request['slice_name']
+
# slice name is unique among all authorities
- slice_query = Query().get('myslice:slice').select('slice_hrn')
+ slice_query = Query().get('myslice:slice').select('slice_hrn')
slice_details_sfa = execute_admin_query(request, slice_query)
for _slice in slice_details_sfa:
split_list = _slice['slice_hrn'].split('.')
# What kind of slice name is valid?
- if (slice_name is None or slice_name == ''):
+ 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):
+ if re.search(r'^[A-Za-z0-9_]*$', slice_name) is None:
errors.append('Slice name may contain only letters, numbers, and underscore.')
organization = slice_request['organization']
if theme.theme == 'fed4fire':
- if (organization is None or organization == ''):
+ if organization is None or organization == '':
errors.append('Selecting project is mandatory')
else:
- if (organization is None or organization == ''):
+ if organization is None or organization == '':
errors.append('Organization is mandatory')
slice_length= len(slice_request['slice_name'])
purpose = slice_request['purpose']
- if (purpose is None or purpose == ''):
+ if purpose is None or purpose == '':
errors.append('Experiment purpose is mandatory')
url = slice_request['url']