import json, time, re
import activity.user
+theme = ThemeView()
class SliceRequestView (LoginRequiredAutoLogoutView, ThemeView):
template_name = 'slicerequest_view.html'
authorities_query = Query.get('authority').select('name', 'authority_hrn')
authorities = execute_admin_query(wsgi_request, authorities_query)
if authorities is not None:
- authorities = sorted(authorities)
+ authorities = sorted(authorities, key=lambda k: k['authority_hrn'])
+ 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')
#else:
# pi = "is_pi"
- pi = authority_check_pis (wsgi_request, user_email)
+ pi = authority_check_pis (wsgi_request, user_email)
+ print "SLICEREQUESTVIEW.PY ----- pi=",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.add_css_files ( [ "css/jquery-ui.css" ] )
page.expose_js_metadata()
if method == 'POST':
if authority_hrn is None:
authority_hrn = wsgi_request.POST.get('org_name', '')
+ # Handle project if used
+ project = wsgi_request.POST.get('project', None)
+ if project is not None and project != '':
+ authority_hrn = project
+
slice_request = {
'type' : 'slice',
'id' : None,
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')
+ organization = slice_request['organization']
+ if theme.theme == 'fed4fire':
+ if (organization is None or organization == ''):
+ errors.append('Selecting project is mandatory')
+ else:
+ if (organization is None or organization == ''):
+ errors.append('Organization is mandatory')
+
+ slice_length= len(slice_request['slice_name'])
+ if slice_length >19:
+ errors.append('Slice name can be maximum 19 characters long')