from myslice.settings import config, logger, DEBUG
+from portal.actions import authority_check_pis
+
# from unfold.sessioncache import SessionCache
# Name my backend 'ManifoldBackend'
if 'lastname' in person:
user.last_name = person['lastname']
+ user.pi = authority_check_pis (request, user.email)
+ request.session['user'] = {'email':user.email,'pi':user.pi,'firstname':user.first_name,'lastname':user.last_name}
return user
# Required for your backend to work properly - unchanged in most scenarios
# DEBUG
if config.myslice.debug :
DEBUG = True
+ INTERNAL_IPS = ("127.0.0.1","132.227.84.195","132.227.78.191","132.227.84.191")
else :
DEBUG = False
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
'portal',
- #SLA
- #'sla',
+ #'debug_toolbar',
]
# with django-1.7 we leave south and use native migrations
# managing database migrations
platform_list = [{'platform_no_access': t[0]}
for t in itertools.izip_longest(total_platform_list)]
-
- ## check user is pi or not
- # platform_query = Query().get('local:platform').select('platform_id','platform','gateway_type','disabled')
- # account_query = Query().get('local:account').select('user_id','platform_id','auth_type','config')
- # platform_details = execute_query(self.request, platform_query)
- # account_details = execute_query(self.request, account_query)
- # for platform_detail in platform_details:
- # for account_detail in account_details:
- # if platform_detail['platform_id'] == account_detail['platform_id']:
- # if 'config' in account_detail and account_detail['config'] is not '':
- # account_config = json.loads(account_detail['config'])
- # if 'myslice' in platform_detail['platform']:
- # acc_auth_cred = account_config.get('delegated_authority_credentials','N/A')
- # assigning values
- if acc_auth_cred == {} or acc_auth_cred == 'N/A':
- pi = "is_not_pi"
- else:
- pi = "is_pi"
-
# check if the user has creds or not
if acc_user_cred == {} or acc_user_cred == 'N/A':
user_cred = 'no_creds'
context['ref_acc'] = ref_acc_list
context['platform_list'] = platform_list
context['my_users'] = my_users
- context['pi'] = pi
context['user_cred'] = user_cred
context['my_slices'] = my_slices
context['my_auths'] = my_auths
context['theme'] = self.theme
context['section'] = "User account"
# context ['firstname'] = config['firstname']
+
+ context['request'] = self.request
+
prelude_env = page.prelude_env()
context.update(prelude_env)
return context
def get_myslice_platform(request):
platform_query = Query().get('local:platform').select('platform_id','platform','gateway_type','disabled','config').filter_by('platform','==','myslice')
platform_details = execute_query(request, platform_query)
- for platform_detail in platform_details:
- return platform_detail
+ if isinstance(platform_details,list):
+ for platform_detail in platform_details:
+ return platform_detail
+ else:
+ return None
def get_myslice_account(request):
platform_myslice = get_myslice_platform(request)
account_query = Query().get('local:account').select('user_id','platform_id','auth_type','config').filter_by('platform_id','==',platform_myslice['platform_id'])
account_details = execute_query(request, account_query)
- for account_detail in account_details:
- return account_detail
+ if isinstance(account_details,list):
+ for account_detail in account_details:
+ return account_detail
+ else:
+ return None
def get_registry_url(request):
try:
username = None
# log user activity
activity.user.contact(self.request)
- return render(request,'contact_sent.html', { 'theme' : self.theme, 'username': username}) # Redirect after POST
+ return render(request,'contact_sent.html', { 'theme' : self.theme, 'username': username, 'request':request}) # Redirect after POST
else:
return self._display (request, form)
def _display (self, request, form):
if request.user.is_authenticated():
username = request.user.email
- ## check user is pi or not
- platform_query = Query().get('local:platform').select('platform_id','platform','gateway_type','disabled')
- account_query = Query().get('local:account').select('user_id','platform_id','auth_type','config')
- platform_details = execute_query(self.request, platform_query)
- account_details = execute_query(self.request, account_query)
- for platform_detail in platform_details:
- for account_detail in account_details:
- if platform_detail['platform_id'] == account_detail['platform_id']:
- if 'config' in account_detail and account_detail['config'] is not '':
- account_config = json.loads(account_detail['config'])
- if 'myslice' in platform_detail['platform']:
- acc_auth_cred = account_config.get('delegated_authority_credentials','N/A')
- # assigning values
- if acc_auth_cred == {} or acc_auth_cred == 'N/A':
- pi = "is_not_pi"
- else:
- pi = "is_pi"
else :
username = None
pi = "is_not_pi"
'topmenu_items': topmenu_items('Contact', request),
'theme' : self.theme,
'username': username,
- 'pi': pi,
- 'section': "Contact"
+ 'section': "Contact",
+ 'request': request,
})
from portal.account import Account, get_expiration
from portal.models import PendingSlice
-from portal.actions import authority_check_pis, get_jfed_identity
+from portal.actions import authority_check_pis, get_jfed_identity, get_myslice_account
import activity.user
activity.user.login(self.request)
## check user is pi or not
- platform_details = {}
- account_details = {}
acc_auth_cred = {}
acc_user_cred = {}
- platform_query = Query().get('local:platform').select('platform_id','platform','gateway_type','disabled')
- account_query = Query().get('local:account').select('user_id','platform_id','auth_type','config')
- platform_details = execute_query(self.request, platform_query)
- account_details = execute_query(self.request, account_query)
- if platform_details is not None and platform_details != {}:
- for platform_detail in platform_details:
- for account_detail in account_details:
- if platform_detail['platform_id'] == account_detail['platform_id']:
- if 'config' in account_detail and account_detail['config'] is not '':
- account_config = json.loads(account_detail['config'])
- if 'myslice' in platform_detail['platform']:
- acc_auth_cred = account_config.get('delegated_authority_credentials','N/A')
- acc_user_cred = account_config.get('delegated_user_credential','N/A')
+
+ account_detail = get_myslice_account(self.request)
+ if 'config' in account_detail and account_detail['config'] is not '':
+ account_config = json.loads(account_detail['config'])
+ acc_auth_cred = account_config.get('delegated_authority_credentials','N/A')
+ acc_user_cred = account_config.get('delegated_user_credential','N/A')
# assigning values
#if acc_auth_cred=={} or acc_auth_cred=='N/A':
# pi = "is_not_pi"
# log user activity
activity.user.login(self.request, "error")
env['state'] = "Your username and/or password were incorrect."
-
+ env['request'] = request
return render_to_response(self.template,env, context_instance=RequestContext(request))
def get (self, request, state=None):
env = self.default_env()
acc_auth_cred={}
- jfed_identity = get_jfed_identity(request)
- if jfed_identity is not None:
- import base64
- encoded_jfed_identity = base64.b64encode(jfed_identity)
- env['jfed_identity'] = encoded_jfed_identity
- else:
- env['jfed_identity'] = None
+
if request.user.is_authenticated():
+ jfed_identity = get_jfed_identity(request)
+ if jfed_identity is not None:
+ import base64
+ encoded_jfed_identity = base64.b64encode(jfed_identity)
+ env['jfed_identity'] = encoded_jfed_identity
+ else:
+ env['jfed_identity'] = None
## check user is pi or not
platform_details = {}
platform_query = Query().get('local:platform').select('platform_id','platform','gateway_type','disabled')
account_query = Query().get('local:account').select('user_id','platform_id','auth_type','config')
# XXX Something like an invalid session seems to make the execute fail sometimes, and thus gives an error on the main page
- platform_details = execute_query(self.request, platform_query)
- account_details = execute_query(self.request, account_query)
- if platform_details is not None and platform_details != {}:
- for platform_detail in platform_details:
- for account_detail in account_details:
- if 'platform_id' in platform_detail:
- if platform_detail['platform_id'] == account_detail['platform_id']:
- if 'config' in account_detail and account_detail['config'] is not '':
- account_config = json.loads(account_detail['config'])
- if 'myslice' in platform_detail['platform']:
- acc_auth_cred = account_config.get('delegated_authority_credentials','N/A')
- acc_user_cred = account_config.get('delegated_user_credential','N/A')
+
+ account_detail = get_myslice_account(self.request)
+ if 'config' in account_detail and account_detail['config'] is not '':
+ account_config = json.loads(account_detail['config'])
+ acc_auth_cred = account_config.get('delegated_authority_credentials','N/A')
+ acc_user_cred = account_config.get('delegated_user_credential','N/A')
# assigning values
#if acc_auth_cred=={} or acc_auth_cred=='N/A':
# pi = "is_not_pi"
env['theme'] = self.theme
env['section'] = "Dashboard"
-
env['username']=the_user(request)
env['topmenu_items'] = topmenu_items(None, request)
+ env['request'] = request
if state: env['state'] = state
elif not env['username']: env['state'] = None
# use one or two columns for the layout - not logged in users will see the login prompt
-
return render_to_response(self.template, env, context_instance=RequestContext(request))
def post (self,request):
env = self.default_env()
env['theme'] = self.theme
+ env['request'] = request
return render_to_response(self.template, env, context_instance=RequestContext(request))
def get (self, request, authority_hrn=None, state=None):
# use one or two columns for the layout - not logged in users will see the login prompt
env['layout_1_or_2']="layout-unfold2.html" if not env['username'] else "layout-unfold1.html"
-
+ env['request'] = request
return render_to_response(self.template, env, context_instance=RequestContext(request))
authority_name = authority['name']
if method == 'POST' :
-
+
+ project_name = wsgi_request.POST.get('project_name', '')
+ if not project_name or len(project_name) == 0 :
+ errors.append('Project name can\'t be empty')
+
+ # accept only lowercase names
+ project_name = project_name.lower()
+
if 'join' in wsgi_request.POST:
post = {
'user_hrn' : user_hrn,
'email' : user_email,
- 'project_name' : wsgi_request.POST.get('project_name', ''),
- 'authority_hrn' : wsgi_request.POST.get('project_name', ''),
+ 'project_name' : project_name,
+ 'authority_hrn' : project_name,
}
else:
'user_hrn' : user_hrn,
'email' : user_email,
'authority_hrn' : wsgi_request.POST.get('authority_name', ''),
- 'project_name' : wsgi_request.POST.get('project_name', ''),
+ 'project_name' : project_name,
'purpose' : wsgi_request.POST.get('purpose', ''),
}
-
+
# for new projects max project_name length is 10
if (len(post['project_name']) >10):
errors.append('Project name can be maximum 10 characters long')
#if (post['authority_hrn'] is None or post['authority_hrn'] == ''):
# errors.append('Organization is mandatory')
- if (post['purpose'] is None or post['purpose'] == ''):
+ if post['purpose'] is None or post['purpose'] == '':
errors.append('Project purpose is mandatory')
- if (re.search(r'^[A-Za-z0-9_]*$', post['project_name']) == None):
+ if re.search(r'^[A-Za-z0-9_]*$', post['project_name']) is None:
errors.append('Project name may contain only letters, numbers, and underscore.')
# What kind of project name is valid?
- if (post['project_name'] is None or post['project_name'] == ''):
+ if post['project_name'] is None or post['project_name'] == '':
errors.append('Project name is mandatory')
if not errors:
'pending_join_projects': pending_join_projects,
}
return render(wsgi_request, self.template, env)
-
-
-
- """
- """
- errors = []
- slice_name =''
- purpose=''
- url=''
- authority_hrn = None
- authority_name = None
- # Retrieve the list of authorities
- 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'])
-
- # Get user_email (XXX Would deserve to be simplified)
- user_query = Query().get('local:user').select('email','config')
- user_details = execute_query(wsgi_request, user_query)
- user_email = user_details[0].get('email')
- # getting user_hrn
- for user_detail in user_details:
- user_config = json.loads(user_detail['config'])
- user_authority = user_config.get('authority','N/A')
- # getting the org from authority
- for authority in authorities:
- if authority['authority_hrn'] == user_authority:
- authority_name = authority['name']
-
- # Handle the case when we use only hrn and not name
- if authority_name is None:
- authority_name = user_authority
- #
- account_query = Query().get('local:account').select('user_id','platform_id','auth_type','config')
- account_details = execute_query(wsgi_request, account_query)
- #
- platform_query = Query().get('local:platform').select('platform_id','platform','gateway_type','disabled')
- platform_details = execute_query(wsgi_request, platform_query)
-
- user_hrn = None
- # getting user_hrn from local:account
- for account_detail in account_details:
- for platform_detail in platform_details:
- if platform_detail['platform_id'] == account_detail['platform_id']:
- # taking user_hrn only from myslice account
- # NOTE: we should later handle accounts filter_by auth_type= managed OR user
- if 'myslice' in platform_detail['platform']:
- account_config = json.loads(account_detail['config'])
- user_hrn = account_config.get('user_hrn','N/A')
- acc_auth_cred = account_config.get('delegated_authority_credentials','N/A')
-
-
- # 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')
-
-
-
- purpose = slice_request['purpose']
- if (purpose is None or purpose == ''):
- errors.append('Experiment purpose is mandatory')
-
- url = slice_request['url']
-
- if not errors:
- if is_pi(wsgi_request, user_hrn, authority_hrn):
- # PIs can directly create slices in their own authority...
- create_slice(wsgi_request, slice_request)
- clear_user_creds(wsgi_request, user_email)
- self.template_name = 'slice-request-done-view.html'
- else:
- # Otherwise a wsgi_request is sent to the PI
- create_pending_slice(wsgi_request, slice_request, user_email)
- self.template_name = 'slice-request-ack-view.html'
-
- # log user activity
- activity.user.slice(wsgi_request)
-
- return render(wsgi_request, self.template, {'theme': self.theme}) # Redirect after POST
- else:
- slice_request = {}
-
- template_env = {
- 'username': wsgi_request.user.email,
- 'errors': errors,
- 'slice_name': slice_name,
- 'purpose': purpose,
- 'email': user_email,
- 'user_hrn': user_hrn,
- 'url': url,
- 'pi': pi,
- 'authority_name': authority_name,
- 'authority_hrn': user_authority,
- 'cc_myself': True,
- 'authorities': authorities,
- 'theme': self.theme,
- 'section': "Slice request"
- }
- template_env.update(slice_request)
- template_env.update(page.prelude_env())
- return render(wsgi_request, self.template, template_env)
import re
from django.shortcuts import render
+from django.shortcuts import render_to_response
+from django.template import RequestContext
from django.contrib.sites.models import Site
from unfold.page import Page
def get (self, request):
return self.get_or_post (request, 'GET')
- def get_or_post (self, wsgi_request, method):
+ def get_or_post (self, request, method):
"""
"""
+ from django.conf import settings
+ print "_"*80
+ print settings.TEMPLATE_CONTEXT_PROCESSORS
+ print "_"*80
+
errors = []
slice_name =''
purpose=''
authority_name = None
# Retrieve the list of authorities
authorities_query = Query.get('authority').select('name', 'authority_hrn')
- authorities = execute_admin_query(wsgi_request, authorities_query)
+ 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'])
# Get user_email (XXX Would deserve to be simplified)
user_query = Query().get('local:user').select('email','config')
- user_details = execute_query(wsgi_request, user_query)
+ user_details = execute_query(request, user_query)
user_email = user_details[0].get('email')
# getting user_hrn
for user_detail in user_details:
authority_name = user_authority
account_query = Query().get('local:account').select('user_id','platform_id','auth_type','config')
- account_details = execute_query(wsgi_request, account_query)
+ account_details = execute_query(request, account_query)
platform_query = Query().get('local:platform').select('platform_id','platform','gateway_type','disabled')
- platform_details = execute_query(wsgi_request, platform_query)
+ platform_details = execute_query(request, platform_query)
user_hrn = None
#getting user_hrn from local:account
for account_detail in account_details:
#else:
# pi = "is_pi"
- pi = authority_check_pis (wsgi_request, user_email)
+ pi = authority_check_pis (request, user_email)
logger.debug("SLICEREQUESTVIEW.PY ----- pi= {}".format(pi))
# Page rendering
- page = Page(wsgi_request)
+ page = Page(request)
page.add_js_files ( [ "js/jquery.validate.js", "js/jquery-ui.js" ] )
page.add_css_files ( [ "css/jquery-ui.css" ] )
page.expose_js_metadata()
# getting the authority_hrn from the selected organization
for authority in authorities:
- if authority['name'] == wsgi_request.POST.get('org_name', ''):
+ 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:
- authority_hrn = wsgi_request.POST.get('org_name', '')
+ authority_hrn = request.POST.get('org_name', '')
# Handle project if used
- project = wsgi_request.POST.get('project', None)
+ project = request.POST.get('project', None)
if project is not None and project != '':
authority_hrn = project
+ slice_name = wsgi_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,
'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', ''),
+ 'organization' : request.POST.get('org_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(wsgi_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']
if not errors:
- if is_pi(wsgi_request, user_hrn, authority_hrn):
+ if is_pi(request, user_hrn, authority_hrn):
# PIs can directly create slices in their own authority...
- create_slice(wsgi_request, slice_request)
- clear_user_creds(wsgi_request, user_email)
+ create_slice(request, slice_request)
+ clear_user_creds(request, user_email)
self.template_name = 'slice-request-done-view.html'
else:
- # Otherwise a wsgi_request is sent to the PI
- create_pending_slice(wsgi_request, slice_request, user_email)
+ # Otherwise a request is sent to the PI
+ create_pending_slice(request, slice_request, user_email)
self.template_name = 'slice-request-ack-view.html'
# log user activity
- activity.user.slice(wsgi_request)
-
- return render(wsgi_request, self.template, {'theme': self.theme}) # Redirect after POST
+ activity.user.slice(request)
+ return render_to_response(self.template, {'theme': self.theme, 'request':request}, context_instance=RequestContext(request))
+ #return render(request, self.template, {'theme': self.theme}) # Redirect after POST
else:
slice_request = {}
template_env = {
- 'username': wsgi_request.user.email,
+ 'username': request.user.email,
'topmenu_items': topmenu_items_live('Request a slice', page),
'errors': errors,
'slice_name': slice_name,
'cc_myself': True,
'authorities': authorities,
'theme': self.theme,
- 'section': "Slice request"
+ 'section': "Slice request",
+ 'request': request,
}
template_env.update(slice_request)
template_env.update(page.prelude_env())
- return render(wsgi_request, self.template, template_env)
+
+ return render_to_response(self.template,template_env, context_instance=RequestContext(request))
+ #return render(request, self.template, template_env)
#outline_complete = True,
username = request.user,
)
-
- ## check user is pi or not
- platform_query = Query().get('local:platform').select('platform_id','platform','gateway_type','disabled')
- account_query = Query().get('local:account').select('user_id','platform_id','auth_type','config')
- platform_details = execute_query(self.request, platform_query)
- account_details = execute_query(self.request, account_query)
-
- # XXX When session has expired, this is None and thus not iterable
- for platform_detail in platform_details:
- for account_detail in account_details:
- if platform_detail['platform_id'] == account_detail['platform_id']:
- if 'config' in account_detail and account_detail['config'] is not '':
- account_config = json.loads(account_detail['config'])
- if 'myslice' in platform_detail['platform']:
- acc_auth_cred = account_config.get('delegated_authority_credentials','N/A')
- # assigning values
- if acc_auth_cred == {} or acc_auth_cred == 'N/A':
- pi = "is_not_pi"
- else:
- pi = "is_pi"
template_env = {}
+
+ template_env['request'] = self.request
+
template_env['list_resources'] = list_resources.render(self.request)
template_env['list_reserved_resources'] = list_reserved_resources.render(self.request)
template_env['list_reserved_leases'] = list_reserved_leases.render(self.request)
# template_env['vms_list'] = univbrisvtamplugin.render(self.request)
# template_env['vm_form'] = univbrisvtamform.render(self.request)
-# template_env['pending_resources'] = pending_resources.render(self.request)
+ # template_env['pending_resources'] = pending_resources.render(self.request)
template_env['sla_dialog'] = sla_dialog.render(self.request)
template_env["theme"] = self.theme
template_env["username"] = request.user
- template_env["pi"] = pi
template_env["slice"] = slicename
template_env["section"] = "resources"
template_env["msg"] = msg
import urllib2,json
class ExperimentView (FreeAccessView, ThemeView):
+ # parent View is portal/sliceview.py
+
template_name = 'slice-tab-experiment.html'
def get (self, request, slicename, state=None):
for user in all_users:
if user['email'] == username:
iot_login = user['login']
-
- return render_to_response(self.template, { 'theme' : self.theme,'slicename':slicename, 'ple_slicename':ple_slicename, 'username':username, 'ple_resources':ple_resource_list, 'nitos_resources': nitos_resource_list, 'nitos_paris_resources':nitos_paris_resource_list, 'iotlab_resources':iotlab_resource_list, 'iot_login':iot_login }, context_instance=RequestContext(request))
+ env = { 'theme' : self.theme,
+ 'slicename':slicename,
+ 'ple_slicename':ple_slicename,
+ 'username':username,
+ 'ple_resources':ple_resource_list,
+ 'nitos_resources': nitos_resource_list,
+ 'nitos_paris_resources':nitos_paris_resource_list,
+ 'iotlab_resources':iotlab_resource_list,
+ 'iot_login':iot_login,
+ 'request':self.request,
+ }
+ return render_to_response(self.template, env, context_instance=RequestContext(request))
template_name = "slice-view.html"
def get(self, request, slicename):
- ## check user is pi or not
- platform_query = Query().get('local:platform').select('platform_id','platform','gateway_type','disabled')
- account_query = Query().get('local:account').select('user_id','platform_id','auth_type','config')
- platform_details = execute_query(self.request, platform_query)
- account_details = execute_query(self.request, account_query)
- for platform_detail in platform_details:
- for account_detail in account_details:
- if platform_detail['platform_id'] == account_detail['platform_id']:
- if 'config' in account_detail and account_detail['config'] is not '':
- account_config = json.loads(account_detail['config'])
- if 'myslice' in platform_detail['platform']:
- acc_auth_cred = account_config.get('delegated_authority_credentials','N/A')
- # assigning values
- if acc_auth_cred == {} or acc_auth_cred == 'N/A':
- pi = "is_not_pi"
- else:
- pi = "is_pi"
+
return render_to_response(self.template,
{"slice" : slicename,
"theme" : self.theme,
"username" : request.user,
- "pi" : pi,
- "section" : "Slice {}".format(slicename) },
+ "section" : "Slice {}".format(slicename),'request':request },
context_instance=RequestContext(request))
if request.user.is_authenticated():
env['person'] = self.request.user
- ## check user is pi or not
- platform_query = Query().get('local:platform').select('platform_id','platform','gateway_type','disabled')
- account_query = Query().get('local:account').select('user_id','platform_id','auth_type','config')
- platform_details = execute_query(self.request, platform_query)
- account_details = execute_query(self.request, account_query)
- for platform_detail in platform_details:
- for account_detail in account_details:
- if platform_detail['platform_id'] == account_detail['platform_id']:
- if 'config' in account_detail and account_detail['config'] is not '':
- account_config = json.loads(account_detail['config'])
- if 'myslice' in platform_detail['platform']:
- acc_auth_cred = account_config.get('delegated_authority_credentials','N/A')
- # assigning values
- if acc_auth_cred == {} or acc_auth_cred == 'N/A':
- pi = "is_not_pi"
- else:
- pi = "is_pi"
- env['pi'] = pi
else:
env['person'] = None
if state: env['state'] = state
elif not env['username']: env['state'] = None
# use one or two columns for the layout - not logged in users will see the login prompt
-
+ env['request'] = request
return render_to_response(self.template, env, context_instance=RequestContext(request))
</ul>
</div>
</li>
- {%if 'is_pi' in pi %}
+ {% if request.session.user.pi %}
<li id="nav-institution" class=""><a href="/institution">MANAGEMENT</a></li>
- {%endif%}
+ {%endif%}
<li><a href="/support/">SUPPORT</a></li>
</ul>
</div>
slices.push("no slice");
}else{
slices = user.slices;
- //drawSlices(slices);
+ {% if theme != "fed4fire" %}
+ drawSlices(slices);
+ {% endif %}
}
{% if theme == "fed4fire" %}
p = myslice.get_projects();
<script src='https://authority.ilabt.iminds.be/js/jquery/jquery-ui.min.js'></script>
<script src="//java.com/js/dtjava.js"></script>
<script src='https://authority.ilabt.iminds.be/js/jfed_webstart_f4fportal.js'></script>
-
+<link rel='stylesheet' href='https://authority.ilabt.iminds.be/js/jquery/jquery-ui.css' />
{% endblock %}
<script>
$(document).ready(function() {
var myprojects = JSON.parse(localStorage.getItem('projects'));
- console.log(myprojects);
if (myprojects) {
$.each(myprojects, function (i, val){
- console.log(val);
$('.project-list').append('<tr><td>'+ val +'</td></tr>');
});
} else {
$("#project_loading").hide();
$("#projects").html(projects.join( "" ));
$("#projects").combobox();
+ var $s = jQuery("#projects").next().attr('id','listProjects');
+ jQuery('#listProjects').bind("click",function(){
+ // show all items click
+ this.childNodes[1].click();
+ });
+
});
/*
// auto-complete the form
jQuery("#org_name").combobox();
+ $('input[name=project_name]').keyup(function(){
+ this.value = this.value.toLowerCase();
+ });
});
</script>
{% endblock %}
}
}
}).bind('focus', function(){ $(this).autocomplete("search"); } );
+ $('input[name=slice_name]').keyup(function(){
+ this.value = this.value.toLowerCase();
+ });
});
-
-/*function draw_projects(authority_hrn){
-
- var projects = [];
- project_row = "<option value=''> - </option>";
- projects.push(project_row);
-
- if(authority_hrn.length > 0){
- // Not for root authority
- if(authority_hrn.split('.').length > 1){
- $.post("/rest/myslice:authority/",{'fields':['authority_hrn','pi_users'],'filters':{'authority_hrn':'CONTAINS'+authority_hrn}}, function( data ) {
-
- $.each( data, function( key, val ) {
- project_row = "<option value='"+val.authority_hrn+"'>"+val.authority_hrn+"</option>";
- projects.push(project_row);
- });
- $("#project").html(projects.join( "" ));
- });
- }else{
- $("#project").html(projects.join( "" ));
- }
- }else{
- my_projects = JSON.parse(localStorage.getItem('projects'));
- $.each( my_projects, function( i, val ) {
- project_row = "<option value='"+val+"'>"+val+"</option>";
- projects.push(project_row);
- });
- $("#project").html(projects.join( "" ));
- }
- $("#project").show();
- $("#project_loading").hide();
-}*/
</script>
{% endblock %}
<input type="file" name="pubkey" class="required" id="pubkey"/>
<input class="btn btn-default btn-xs" name="upload_key" id="upload_key" type="submit" title="Upload your public key" value="Upload"
onclick="return confirm('Are you sure? It will overwrite your current credentials and you have delegate it manually.');"/>
- </span>
+
<div style='display:none;'> <input type='hidden' name='dload' /> </div>
<button type="submit" name="dl_pubkey" class="btn btn-default btn-xs" title="Download your public key" id="dl_pubkey" onclick="javascript:document.getElementById('button_value').value='dl_pubkey';">
<span class="glyphicon glyphicon-download"></span> Download
title="Please enter a name for your slice"required="required">
</div>
<div class="form-group">
- {% if pi %}
- <input type="text" class="form-control" id="authority_hrn" name="org_name" style="width:300px" placeholder="Organization"
+ {% if request.session.user.pi %}
+ <input type="text" class="form-control" id="authority_hrn" name="authority_hrn" style="width:300px" placeholder="Authority"
title="An authority responsible for vetting your slice" required="required">
- {% else %}
- <input type="text" class="form-control" id="authority_hrn" name="org_name" placeholder="Organization" style="width:300px;"
- title="An authority responsible for vetting your slice" required="required" readonly>
- {% endif %}
+ {% else %}
+ <input type="text" class="form-control" id="authority_hrn" name="authority_hrn" placeholder="Authority" style="width:300px; display:none;"
+ title="An authority responsible for vetting your slice" required="required" readonly="readonly">
+ {% endif %}
</div>
<div class="form-group">
<input type="text" class="form-control" name="url" id="url" style="width:300px" placeholder="Experiment URL (if one exists)"
</ul>
</div>
</li>
- {%if 'is_pi' in pi %}
+ {% if request.session.user.pi %}
<li id="nav-institution" class=""><a href="/institution">MANAGEMENT</a></li>
- {%endif%}
+ {%endif%}
<li><a href="/support/">SUPPORT</a></li>
</ul>
</div>
<link rel="stylesheet" href="{{ STATIC_URL }}css/jquery-ui.css">
<script>
function get_users_in_slice(authority_hrn){
- console.log(authority_hrn);
$("table#user-tab").html("<tr><th>+/-</th><th>Email</th><th>User hrn</th></tr>");
var slice_users = [];
var slice_users_removed = [];
title="Please enter a name for your slice"required="required">
</div>
<div class="form-group">
- {%if 'is_pi' in pi %}
- <input type="text" class="form-control" id="authority_hrn" name="authority_hrn" style="width:300px" placeholder="Authority"
+ {% if request.session.user.pi %}
+ <input type="text" class="form-control" id="authority_hrn" name="authority_hrn" style="width:300px" placeholder="Authority"
title="An authority responsible for vetting your slice" required="required">
- {%else%}
- <input type="text" class="form-control" id="authority_hrn" name="authority_hrn" placeholder="Authority" style="width:300px; display:none;"
+ {% else %}
+ <input type="text" class="form-control" id="authority_hrn" name="authority_hrn" placeholder="Authority" style="width:300px; display:none;"
title="An authority responsible for vetting your slice" required="required" readonly="readonly">
- {%endif%}
+ {% endif %}
</div>
<div class="form-group">
<input type="number" class="form-control" name="number_of_nodes" id="number_of_nodes" style="width:300px" placeholder="Number of nodes"
minLength: 0,
select: function( event, ui ) {console.log(jQuery(this));}
});
+ $('input[name=slice_name]').keyup(function(){
+ this.value = this.value.toLowerCase();
+ });
});
</script>
{% endblock %}
# for 'as_view' that we need to call in urls.py and the like
from django.views.generic.base import TemplateView
-from manifoldapi.manifoldresult import ManifoldException
+from manifoldapi.manifoldresult import ManifoldException
from myslice.settings import logger