Several modifications in fed4fire UI + Slice creation is restricted under projects...
[unfold.git] / portal / slicerequestview.py
index 324de71..5a72007 100644 (file)
@@ -1,7 +1,10 @@
+import json
+import time
+import re
+
 from django.shortcuts           import render
 from django.contrib.sites.models import Site
 
-
 from unfold.page                import Page
 
 from manifold.core.query        import Query
@@ -13,10 +16,10 @@ from unfold.loginrequired       import LoginRequiredAutoLogoutView
 from ui.topmenu                 import topmenu_items_live, the_user
 
 from myslice.theme import ThemeView
-
-import json, time, re
+from myslice.settings import logger
 
 import activity.user
+theme = ThemeView()
 
 class SliceRequestView (LoginRequiredAutoLogoutView, ThemeView):
     template_name = 'slicerequest_view.html'
@@ -87,12 +90,12 @@ class SliceRequestView (LoginRequiredAutoLogoutView, ThemeView):
         #    pi = "is_pi"
 
         pi = authority_check_pis (wsgi_request, user_email)
-        print "SLICEREQUESTVIEW.PY -----  pi=",pi
+        logger.debug("SLICEREQUESTVIEW.PY -----  pi= {}".format(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':
@@ -148,9 +151,17 @@ class SliceRequestView (LoginRequiredAutoLogoutView, ThemeView):
             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')