Merge branch 'onelab' of ssh://git.onelab.eu/git/myslice into onelab
authorLoic Baron <loic.baron@lip6.fr>
Mon, 9 Mar 2015 18:53:49 +0000 (19:53 +0100)
committerLoic Baron <loic.baron@lip6.fr>
Mon, 9 Mar 2015 18:53:49 +0000 (19:53 +0100)
Conflicts:
portal/joinview.py
portal/registrationview.py

1  2 
myslice/settings.py
portal/registrationview.py
portal/slicetabexperiment.py

diff --combined myslice/settings.py
@@@ -1,5 -1,7 +1,7 @@@
  # Django settings for unfold project.
  
+ from __future__ import print_function
  import os.path
  
  import djcelery
@@@ -13,7 -15,9 +15,9 @@@ except
      building=True
  
  DEBUG = True
- TEMPLATE_DEBUG = DEBUG
+ # show the various settings as we go
+ DEBUG_SETTINGS = False
  
  # compute ROOT from where this file is installed
  # should fit every need including developers
@@@ -45,9 -49,13 +49,13 @@@ except
  # when deployed from a package
  # this code is run by collectstatic too, so we cannot
  # assume we have ./static present already
 -HTTPROOT="/var/myslice-f4f"
 +HTTPROOT="/var/www/myslice/"
  # the place to store local data, like e.g. the sqlite db
  DATAROOT="/var/unfold"
+ if not os.path.isdir(DATAROOT):
+     print("WARNING: {} is a non-existing directory".format(DATAROOT))
+     print("consequently we assume development mode and re-route DATAROOT to {}".format(ROOT))
+     DATAROOT=ROOT
  # if not there, then we assume it's from a devel tree
  if not os.path.isdir (os.path.join(HTTPROOT,"static")):
      HTTPROOT=ROOT
  if not os.path.isdir(ROOT): raise Exception,"Cannot find ROOT %s for unfold"%ROOT
  if not os.path.isdir(HTTPROOT): raise Exception,"Cannot find HTTPROOT %s for unfold"%HTTPROOT
  
+ if DEBUG_SETTINGS:
+     print('ROOT', ROOT)
+     print('DATAROOT', DATAROOT)
+     print('HTTPROOT', HTTPROOT)
  # dec 2013 - we currently have 2 auxiliary subdirs with various utilities
  # that we do not wish to package 
  # * sandbox is for plugin developers
@@@ -101,6 -114,9 +114,9 @@@ DATABASES = 
      }
  }
  
+ if DEBUG_SETTINGS:
+     print('DATABASE NAME',DATABASES['default']['NAME'])
  # Local time zone for this installation. Choices can be found here:
  # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
  # although not all choices may be available on all operating systems.
@@@ -252,7 -268,7 +268,7 @@@ BROKER_URL = "amqp://myslice:myslice@lo
  
  for aux in auxiliaries:
      if os.path.isdir(os.path.join(ROOT,aux)): 
-         print "Using devel auxiliary",aux
+         print("Using devel auxiliary",aux)
          INSTALLED_APPS.append(aux)
  
  ACCOUNT_ACTIVATION_DAYS = 7 # One-week activation window; you may, of course, use a different value.
@@@ -45,6 -45,7 +45,7 @@@ class RegistrationView (FreeAccessView
          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, key=lambda k: k['authority_hrn'])
              authorities = sorted(authorities, key=lambda k: k['name'])
          
          print "############ BREAKPOINT 1 #################"
@@@ -80,7 -81,7 +81,7 @@@
                  'current_site'  : current_site,
                  'email_hash'    : email_hash,
                  'pi'            : '',
 -                'validation_link': current_site + '/portal/email_activation/'+ email_hash
 +                'validation_link': 'https://' + current_site + '/portal/email_activation/'+ email_hash
              }
  
              print "############ BREAKPOINT 4 #################"
                  # sqlite3 /var/unfold/unfold.sqlite3
                  # select email from auth_user;
                  if UserModel._default_manager.filter(email__iexact = user_request['email']): 
-                     errors.append('<a href="/contact">Contact OneLab support</a> or try with another email.')
+                     errors.append('<a href="/contact">Contact support</a> or try with another email.')
  
                  # XXX TODO: Factorize with portal/accountview.py
                  # XXX TODO: Factorize with portal/registrationview.py
@@@ -17,6 -17,8 +17,8 @@@ from myslice.configengine import Config
  from myslice.theme import ThemeView
  from myslice.configengine import ConfigEngine
  
+ from sfa.planetlab.plxrn import hash_loginbase
  import urllib2,json
  
  class ExperimentView (FreeAccessView, ThemeView):
    
          username = self.request.user    
          
-         split_slicename = slicename.split('.')
-         ple_slicename = split_slicename[0] + '8' + split_slicename[1] + '_' + split_slicename[2]
-         query_current_resources = Query.get('slice').select('resource').filter_by('slice_hrn','==',slicename)
+         query_current_resources = Query.get('slice').select('resource','parent_authority').filter_by('slice_hrn','==',slicename)
          current_resources = execute_query(request, query_current_resources)
  
+         parent_authority = current_resources[0]['parent_authority']
+         
+         split_slicename = slicename.split('.')
+         ple_slicename = hash_loginbase(parent_authority) + '_' + split_slicename[-1]
          ple_resource_list=[]
          nitos_resource_list=[]
          nitos_paris_resource_list=[]
@@@ -74,7 -78,6 +78,7 @@@
          #print "list of nitos res hrns"
          #print nitos_resource_list
  
 +        all_users = list() 
          #get all  iotlab users
          try:
              engine = ConfigEngine()
@@@ -89,6 -92,7 +93,6 @@@
          except urllib2.URLError as e:
              print "There is a problem in getting iotlab users %s" % e.reason
         
 -        all_users = list() 
  
          #getting the login from email
          #initial value  no-account == contact_admin