try:
user_query = Query().get('local:user').filter_by('email', '==', user_email).select('user_id','email','password','config')
user_details = execute_admin_query(request, user_query)
-
+
# getting the user_id from the session
for user_detail in user_details:
user_id = user_detail['user_id']
query = Query.create('user').set(sfa_user_params).select('user_hrn')
results = execute_query(wsgi_request, query)
+
if not results:
raise Exception, "Could not create %s. Already exists ?" % sfa_user_params['user_hrn']
else:
validate = lsClient.update_user( userData )
- return validate
+ return validate and addUserPublicKey
def ls_update_public_key( wsgi_request, request, lsClient, userId ):
userPbKey = {
ls_validate_user( wsgi_request, request )
except Exception, e:
"Error to validate the user in Labora Scheduler."
+
+def create_user_in_ldap(wsgi_request, request, user_detail):
+ """
+ """
+
+ # saves the user to django auth_user table [needed for password reset]
+ user = User.objects.create_user(request['username'], request['email'], request['password'])
+
+ # Creating a manifold user
+ user_id = manifold_add_user(wsgi_request, request)
+
+ # Creating a Manifold account on the MySlice platform
+ # Note the JSON representation of public and private keys already includes quotes
+ account_config = {
+ 'user_hrn' : request['user_hrn'],
+ 'user_public_key' : request['public_key'],
+ }
+ if request['private_key']:
+ account_config['user_private_key'] = request['private_key']
+
+ user_id = user_detail['user_id'] + 1 # the user_id for the newly created user in local:user
+
+ # XXX TODO: Require a myslice platform
+ # ALERT: this will disapear with ROUTERV2 of Manifold
+ # We have to consider the case where several registries can be used
+ # Removed hardcoded platform = 5
+ # This platform == 'myslice' is a TMP FIX !!
+ try:
+ reg_platform_query = Query().get('local:platform') \
+ .filter_by('platform', '==', 'myslice') \
+ .select('platform_id')
+ reg_platform = execute_admin_query(wsgi_request, reg_platform_query)
+ reg_platform_id = reg_platform[0]['platform_id']
+ account_params = {
+ 'platform_id' : reg_platform_id, # XXX ALERT !!
+ 'user_id' : user_id,
+ 'auth_type' : request['auth_type'],
+ 'config' : json.dumps(account_config),
+ }
+ manifold_add_account(wsgi_request, account_params)
+ except Exception, e:
+ print "Failed creating manifold account on platform %s for user: %s" % ('myslice', request['email'])
+
+ # XXX This has to be stored centrally
+ USER_STATUS_ENABLED = 2
+
+ # Update Manifold user status
+ manifold_update_user(wsgi_request, request['username'], {'status': USER_STATUS_ENABLED})
+
+ # Add reference accounts for platforms
+ manifold_add_reference_user_accounts(wsgi_request, request)
+ from sfa.util.xrn import Xrn
+
+ auth_pi = request.get('pi', None)
+ auth_pi = list([auth_pi]) if auth_pi else list()
+
+ # We create a user request with Manifold terminology
+ sfa_user_params = {
+ 'user_hrn' : request['user_hrn'],
+ 'user_email' : request['email'],
+ 'user_urn' : Xrn(request['user_hrn'], request['type']).get_urn(),
+ 'user_type' : request['type'],
+ 'keys' : request['public_key'],
+ 'user_first_name' : request['first_name'],
+ 'user_last_name' : request['last_name'],
+ 'pi_authorities' : auth_pi,
+ 'user_enabled' : True
+ }
+
+ print request['user_hrn']
+ print request['email']
+ print request['first_name']
+ print request['last_name']
+ print request['type']
+ print request['public_key']
+
+ query = Query.create('user').set(sfa_user_params).select('user_hrn')
+
+ print query
+
+ results = execute_admin_query(wsgi_request, query)
+
+ print results
+
+ if not results:
+ raise Exception, "Could not create %s. Already exists ?" % sfa_user_params['user_hrn']
+ else:
+ subject = 'User validated'
+ msg = 'A manager of your institution has validated your account. You have now full user access to the portal.'
+ send_mail(subject, msg, 'support@fibre.org.br',[request['email']], fail_silently=False)
+ return results
+
def create_pending_user(wsgi_request, request, user_detail):
"""
"""
user_hrn = request['user_hrn'],
pi = request['pi'],
email_hash = request['email_hash'],
+ reasons = request['reasons'],
status = 'False',
)
b.save()
msg.attach_alternative(html_content, "text/html")
msg.send()
+ print pi_emails
except Exception, e:
print "Failed to send email, please check the mail templates and the SMTP configuration of your server"
import traceback
#
from manifold.core.query import Query
from manifoldapi.manifoldapi import execute_query, execute_admin_query
-from portal.actions import manifold_update_user, manifold_update_account, manifold_add_account, manifold_delete_account, sfa_update_user, authority_get_pi_emails
+from portal.actions import manifold_update_user, manifold_update_account, manifold_add_account, manifold_delete_account, sfa_update_user, authority_get_pi_emails, authority_get_pis
#
from unfold.page import Page
from ui.topmenu import topmenu_items_live, the_user
from portal.models import PendingUser
from django.core.mail import EmailMultiAlternatives, send_mail
from django.contrib.sites.models import Site
-
+from django.contrib.auth.models import User
#
import json, os, re, itertools
PendingUser.objects.filter(email_hash__iexact = hash_code).update(status='True')
activation = 'success'
# sending email after activation success
+ try:
+ request = PendingUser.objects.filter(email_hash= hash_code)
+ split_authority_hrn = request[0].authority_hrn.split('.')[0]
+ pis = authority_get_pis(request, split_authority_hrn)
+ pi_emails = []
+ for x in pis:
+ for e in x['pi_users']:
+ u = e.split('.')[1]
+ y = User.Objects.get(username = u)
+ if y.username.count("@") != 0:
+ if y.username.split("@")[1] == request[0].user_hrn.split("@")[1]:
+ pi_emails += [y.email]
+ subject = 'User email activated'
+ msg = 'The user %s has validated his/her email. Now you can validate his/her account' % (request[0].login)
+ send_mail(subject, msg, 'support@fibre.org.br', pi_emails, fail_silently = False)
+ except:
+ print "error sending the email!"
#try:
# Send an email: the recipients are the PI of the authority
# If No PI is defined for this Authority, send to a default email (different for each theme)
# this somehow is not used anymore - should it not be ?
from django.core.context_processors import csrf
from django.http import HttpResponseRedirect
-from django.contrib.auth import authenticate, login, logout
+from django.contrib.auth import authenticate, login, logout, get_user_model
from django.template import RequestContext
from django.shortcuts import render_to_response
from django.shortcuts import render
from unfold.loginrequired import FreeAccessView
from manifold.core.query import Query
-from manifoldapi.manifoldapi import execute_query
+#from manifoldapi.manifoldapi import execute_query
+# LDAP query admin // If transfer this code to actions.py maybe don't need more execute_admin_query
+from manifoldapi.manifoldapi import execute_query, execute_admin_query
+# Edelberto - LDAP XXX
+from portal.models import PendingUser
+from django.contrib.auth.models import User #Pedro
+from portal.actions import create_pending_user, create_user, create_user_in_ldap, clear_user_creds
+from registrationview import RegistrationView
+from random import randint
+from hashlib import md5
+from django.contrib.sites.models import Site
+import os.path, re
+##################
+
from manifoldapi.manifoldresult import ManifoldResult
from ui.topmenu import topmenu_items, the_user
from myslice.theme import ThemeView
+# Edelberto LDAP authentication XXX
+import ldap
+
class HomeView (FreeAccessView, ThemeView):
template_name = 'home-view.html'
# LDAP form - If FIBRE, then get the possibilite to authenticate using usernameldap
#if self.theme == 'fibre':
- usernameldap = request.POST.get('usernameldap')
- token = {'usernameldap': usernameldap, 'username': username ,'password': password, 'request': request}
+ #usernameldap = request.POST.get('usernameldap')
+ #token = {'usernameldap': usernameldap, 'username': username ,'password': password, 'request': request}
+
+ ##################################################
+ ########## XXX Edelberto 010914 XXX
+ #################################################
+ ## first you must open a connection to the server
+ try:
+ # Connect to NOC
+ l = ldap.initialize("ldap://10.128.0.50:389")
+ # Bind/authenticate with a root user to search all objects
+ l.simple_bind_s("cn=Manager,dc=br,dc=fibre","fibre2013")
+
+ l.protocol_version = ldap.VERSION3
+ except ldap.LDAPError, e:
+ print e
+
+ ## Base directory
+ baseDN = "dc=fibre"
+ searchScope = ldap.SCOPE_SUBTREE
+ ## retrieve all attributes
+ retrieveAttributes = None
+ #retrieveAttributes = ['userEnable']
+ searchFilter = "uid=" + username
+ print searchFilter
+
+ in_ldap = 0
+
+ try:
+ if username != "admin":
+ ldap_result_id = l.search(baseDN, searchScope, searchFilter, retrieveAttributes)
+ result_set = []
+ result_type, result_data = l.result(ldap_result_id, 0)
+ if (result_data == []):
+ print "User doesnt exist in LDAP"
+ in_ldap = 0
+ else:
+ if result_type == ldap.RES_SEARCH_ENTRY:
+ result_set.append(result_data)
+ else:
+ result_set.append(result_data)
+ # TRUE or FALSE for userEnable attribute
+ userEnable = result_set[0][0][1]['userEnable'][0]
+ if userEnable == 'TRUE':
+ in_ldap = 1
+ enabled = 1
+ print "In LDAP and Enabled"
+
+ dn = result_set[0][0][0]
+ try:
+ l.simple_bind_s(dn,password)
+ pwd = 1
+ print "User password OK"
+
+ except:
+ pwd = 0
+ print "User password WRONG"
+
+ if in_ldap and enabled and pwd:
+ ldap_mail = result_set[0][0][1]['mail'][0]
+
+ user_exists = Query().get('local:user') \
+ .select('status') \
+ .filter_by('email', '==', username)
+ results = execute_admin_query(request, user_exists)
+ print "DEBUG: %s" % user_exists
+ if results:
+ print "DEBUG: user exists on MySlice DBs"
+ else:
+ print "DEBUG: user NOT exists on MySlice DBs"
+
+ cn = result_set[0][0][1]['cn'][0]
+ print cn
+ sn = result_set[0][0][1]['sn'][0]
+ print sn
+ fname = sn.split(' ')[0]
+ lname = sn.split(' ')[1]
+ print fname
+ print lname
+
+ #authority_hrn = 'fibre' + '.' + username.split('@')[1]
+ authority_hrn = 'fibre'
+ print authority_hrn
+ email = ldap_mail
+ print ldap_mail
+ username = username
+ print username
+ password = password
+ print password
+ # user_hrn = 'fibre' + '.' + username.split('@')[1] + '.' + username
+ user_hrn = 'fibre' + '.' + username
+ print user_hrn
+
+ # Based on registrationview
+
+
+ # get the domain url
+ current_site = Site.objects.get_current()
+ current_site = current_site.domain
+ print current_site
+
+ post_email = ldap_mail
+ salt = randint(1,100000)
+ email_hash = md5(str(salt)+post_email).hexdigest()
+ print email_hash
+
+ user_request = {
+ 'first_name' : fname,
+ 'last_name' : lname,
+ 'organization' : authority_hrn,
+ 'authority_hrn' : authority_hrn,
+ 'email' : ldap_mail,
+ 'username' : username,
+ 'password' : password,
+ 'current_site' : current_site,
+ 'email_hash' : email_hash,
+ 'pi' : '',
+ 'user_hrn' : user_hrn,
+ 'reasons' : 'already exists in the LDAP',
+ 'type' : 'user',
+ 'validation_link': 'https://' + current_site + '/portal/email_activation/'+ email_hash
+ }
+
+ # Validate input
+ errors = []
+ UserModel = get_user_model()
+ if (re.search(r'^[\w+\s.@+-]+$', user_request['first_name']) == None):
+ errors.append('First name may contain only letters, numbers, spaces and @/./+/-/_ characters.')
+ if (re.search(r'^[\w+\s.@+-]+$', user_request['last_name']) == None):
+ errors.append('Last name may contain only letters, numbers, spaces and @/./+/-/_ characters.')
+ if (re.search(r'^[\w,]+$' , username) == None):
+ errors.append('Username may contain only letters,numbers and -/_ characters.')
+ # checking in django_db !!
+ if PendingUser.objects.filter(email__iexact = user_request['email']):
+ errors.append('Email is pending for validation. Please provide a new email address.')
+ if User.objects.filter(username__iexact = user_request['username']):
+ errors.append('This username is already in use, try another one')
+ # Does the user exist in Manifold?
+ user_query = Query().get('local:user').select('user_id','email')
+ user_details = execute_admin_query(request, user_query)
+ for user_detail in user_details:
+ if user_detail['email'] == user_request['email']:
+ errors.append('Email already registered in Manifold. Please provide a new email address.')
+ # Does the user exist in sfa? [query is very slow!!]
+ #user_query = Query().get('user').select('user_hrn','user_email')
+ # XXX Test based on the user_hrn is quick
+ #user_query = Query().get('user').select('user_hrn','user_email').filter_by('user_hrn','==',user_request['user_hrn'])
+ user_query = Query().get('user').select('user_hrn','user_email').filter_by('user_hrn','==',user_hrn)
+ user_details_sfa = execute_admin_query(request, user_query)
+
+ #if 'generate' in wsgi_request.POST['question']:
+ user_request['auth_type'] = 'managed'
+
+ # XXX Common code, dependency ?
+ from Crypto.PublicKey import RSA
+ private = RSA.generate(1024)
+
+ # Example: private_key = '-----BEGIN RSA PRIVATE KEY-----\nMIIC...'
+ # Example: public_key = 'ssh-rsa AAAAB3...'
+ user_request['private_key'] = private.exportKey()
+ user_request['public_key'] = private.publickey().exportKey(format='OpenSSH')
+
+ # XXX Verify if errors exist - After!
+ #if not errors:
+ create_user_in_ldap(request, user_request, user_detail)
+ #create_pending_user(request, user_request, user_detail)
+
+ #create_user(request, user_request)
+
+ env['state'] = "LDAP associated. Please, login again."
+ return render_to_response(self.template, env, context_instance=RequestContext(request))
+
+
+ else:
+ env['state'] = "Access denied. Verify LDAP userEnable and password."
+ return render_to_response(self.template, env, context_instance=RequestContext(request))
+
+ else:
+ in_ldap = 1
+ enabled = 0
+ print "In LDAP but Disabled"
+ env['state'] = "Access denied. Verify LDAP userEnable."
+ return render_to_response(self.template, env, context_instance=RequestContext(request))
+
+ #print result_set
+ except ldap.LDAPError, e:
+ print e
+
#else:
-
- # Follow original code
- ## pass request within the token, so manifold session key can be attached to the request session.
- #token = {'username': username, 'password': password, 'request': request}
-
- # our authenticate function returns either
- # . a ManifoldResult - when something has gone wrong, like e.g. backend is unreachable
- # . a django User in case of success
- # . or None if the backend could be reached but the authentication failed
- auth_result = authenticate(token=token)
- # use one or two columns for the layout - not logged in users will see the login prompt
- # high-level errors, like connection refused or the like
- if isinstance (auth_result, ManifoldResult):
- manifoldresult = auth_result
- # let's use ManifoldResult.__repr__
- env['state']="%s"%manifoldresult
-
- return render_to_response(self.template,env, context_instance=RequestContext(request))
- # user was authenticated at the backend
- elif auth_result is not None:
- user=auth_result
- if user.is_active:
- print "LOGGING IN"
- login(request, user)
-
- if request.user.is_authenticated():
- env['person'] = self.request.user
- env['username'] = 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
- return render_to_response(self.template,env, context_instance=RequestContext(request))
- else:
- env['state'] = "Your account is not active, please contact the site admin."
- env['layout_1_or_2']="layout-unfold2.html"
-
- return render_to_response(self.template,env, context_instance=RequestContext(request))
- # otherwise
+ if in_ldap and enabled and pwd or username=="admin":
+
+################################################################################
+### XXX Edelberto LDAP auth end XXX
+###############################################################################
+ # Follow original code
+ ## pass request within the token, so manifold session key can be attached to the request session.
+ token = {'username': username, 'password': password, 'request': request}
+
+ # our authenticate function returns either
+ # . a ManifoldResult - when something has gone wrong, like e.g. backend is unreachable
+ # . a django User in case of success
+ # . or None if the backend could be reached but the authentication failed
+ auth_result = authenticate(token=token)
+ # use one or two columns for the layout - not logged in users will see the login prompt
+ # high-level errors, like connection refused or the like
+ if isinstance (auth_result, ManifoldResult):
+ manifoldresult = auth_result
+ # let's use ManifoldResult.__repr__
+ env['state']="%s"%manifoldresult
+
+ return render_to_response(self.template,env, context_instance=RequestContext(request))
+ # user was authenticated at the backend
+ elif auth_result is not None:
+ user=auth_result
+ if user.is_active:
+ print "LOGGING IN"
+ login(request, user)
+
+ if request.user.is_authenticated():
+ env['person'] = self.request.user
+ env['username'] = 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')
+
+ # Edleberto
+ #cc_auth_cred = {}
+
+ 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
+ return render_to_response(self.template,env, context_instance=RequestContext(request))
+ else:
+ env['state'] = "Your account is not active, please contact the site admin."
+ env['layout_1_or_2']="layout-unfold2.html"
+
+ return render_to_response(self.template,env, context_instance=RequestContext(request))
+ # otherwise
else:
env['state'] = "Your username and/or password were incorrect."
'get_user_id_by_username', 'add_user_public_key', 'delete_user_public_key' ]
def __init__ ( self, organization ):
- self.url, self.key = self.getOrganizationConfigs( organization )
-
+ self.url, self.key = self.getOrganizationConfigs( organization )
def __getattr__(self, name):
databaseConfig = {
'dbHost' : '10.128.11.200',
'dbUser' : 'postgres',
- 'dbPassword' : '5e6b70f2e9dc',
+ 'dbPassword' : '',
'dbName' : 'LaboraSchedulerNOC'
}
from myslice.theme import ThemeView
import json
+import ast
class ManagementRequestsView (LoginRequiredView, ThemeView):
template_name = "management-tab-requests.html"
ctx_delegation_authorities = {}
ctx_sub_authorities = {}
dest = {}
-
+ user_username = ''
+ user_authority = ''
# The user need to be logged in
if (self.request.user):
user_query = Query().get('local:user').filter_by('email', '==', self.request.user.username).select('user_id')
user, = execute_query(self.request, user_query)
user_id = user['user_id']
-
+ user_query = Query().get('local:user').filter_by('email', '==', self.request.user.username).select('config')
+ user, = execute_query(self.request, user_query)
+ user_config = user['config']
+ user_config = ast.literal_eval(user_config)
+ user_authority = user_config['authority']
+ user_username = self.request.user.username
# Query manifold to learn about available SFA platforms for more information
# In general we will at least have the portal
# For now we are considering all registries
# iterate on the requests and check if the authority matches a prefix
# startswith an authority on which the user is PI
requests = get_requests()
- for r in requests:
- auth_hrn = r['authority_hrn']
+ auth_hrn = ''
+ for r in requests:
+ auth_hrn = r['authority_hrn']
for my_auth in pi_my_authorities:
if auth_hrn.startswith(my_auth):
dest = ctx_my_authorities
# env['pi'] = "is_pi"
# env['theme'] = self.theme
# env['section'] = "Requests"
-
+# auth_hrn = user_authority + '.' + user_username.split("@")[1]
+ ctx_list = [ctx_my_authorities, ctx_sub_authorities, ctx_delegation_authorities]
+ for ctx in ctx_list:
+ if ctx:
+ for authorities in ctx:
+ for requests in ctx[authorities]:
+ try:
+ requests['object_auth'] = requests['user_hrn'].split('.')[0] + '.' + requests['user_hrn'].split('@')[1]
+ except:
+ print "This object has no user_hrn"
+
+ pi_authority = user_authority + '.' + user_username.split("@")[1]
context = super(ManagementRequestsView, self).get_context_data(**kwargs)
print "testing"
print ctx_my_authorities
+ print auth_hrn
+ print user_username
+ print pi_authority
context['my_authorities'] = ctx_my_authorities
context['sub_authorities'] = ctx_sub_authorities
context['delegation_authorities'] = ctx_delegation_authorities
context['pi'] = "is_pi"
context['theme'] = self.theme
context['section'] = "Requests"
+ context['pi_authority'] = pi_authority
# XXX We need to prepare the page for queries
#context.update(page.prelude_env())
login = models.TextField()
pi = models.TextField()
email_hash = models.TextField()
- status = models.TextField()
+ status = models.TextField()
+ reasons = models.TextField()
created = models.DateTimeField(auto_now_add = True)
# models.ForeignKey(Institution)
email_hash = md5(str(salt)+post_email).hexdigest()
#email_hash = md5(post_email).digest().encode('base64')[:-1]
user_request = {
- 'first_name' : wsgi_request.POST.get('firstname', ''),
- 'last_name' : wsgi_request.POST.get('lastname', ''),
- 'organization' : wsgi_request.POST.get('org_name', ''),
- 'authority_hrn' : authority_hrn,
- 'email' : post_email,
- 'username' : wsgi_request.POST.get('username','').lower(),
- 'password' : wsgi_request.POST.get('password', ''),
- 'current_site' : current_site,
- 'email_hash' : email_hash,
- 'pi' : '',
+ 'first_name' : wsgi_request.POST.get('firstname', ''),
+ 'last_name' : wsgi_request.POST.get('lastname', ''),
+ 'organization' : wsgi_request.POST.get('org_name', ''),
+ 'authority_hrn' : authority_hrn,
+ 'email' : post_email,
+ 'username' : wsgi_request.POST.get('username','').lower(),
+ 'password' : wsgi_request.POST.get('password', ''),
+ 'reasons' : wsgi_request.POST.get('reasons', ''),
+ 'current_site' : current_site,
+ 'email_hash' : email_hash,
+ 'pi' : '',
'validation_link': 'https://' + current_site + '/portal/email_activation/'+ email_hash
}
username = user_request['username']
if user_request['authority_hrn'] == "fibre" :
- user_request['username'] = user_request['username'] + "@" + "" # to be defined
+ user_request['username'] = user_request['username'] + "@" + "rnp" # catch-all island
+ split_authority = user_request['authority_hrn']
else :
split_authority = user_request['authority_hrn'].split(".")[1]
user_request['username'] = user_request['username'] + '@' + split_authority
create_pending_user(wsgi_request, user_request, user_detail)
self.template_name = 'user_register_complete.html'
- return render(wsgi_request, self.template, {'theme': self.theme})
+ return render(wsgi_request, self.template, {'theme': self.theme, 'REQINST':wsgi_request.POST.get('org_name', '').split(".")[1].upper()})
else:
user_request = {}
'topmenu_items': topmenu_items_live('Register', page),
'errors': errors,
'authorities': authorities,
- 'theme': self.theme
+ 'theme': self.theme,
+ 'section':'Registration'
}
template_env.update(user_request)
template_env.update(reg_form)
template_env['flowspaces']= univbrisfvlist.render(self.request)
template_env['flowspaces_form']= univbrisfvform.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
</div>
<div class="row">
{%if activation_status == 'success'%}
- <h3>Signup request confirmed.</h3>
- <p>You are currently able to log in to the portal using your email address and the password that you provided, but your access is still limited.</p>
+ <h3>Signup request confirmed.</h3>
<p>You will have full access as soon as your account is validated by a manager at your organization. We have sent an email to the managers with a validation request.</p>
{%else%}
<h3>Signup confirmation failed.</h3>
</div>
<div class="form-group">
- <label for="username">Email Username</label>
- <input type="text" class="form-control" name="username" placeholder="Enter username">
+ <label for="username">Username</label>
+ <input type="text" class="form-control" name="username" placeholder="Enter username@organization">
</div>
<div class="form-group">
<label for="password">Password</label>
<li><a href="/portal/about">About</a></li>
<li><a target="_blank" href="http://www.fibre-ict.eu/">Public Website</a></li>
</ul>
- {% if username %}
- {% if person.username %}
- <div class="account">You are logged in as <a href="/portal/account/">{{ person.username }}</a> | <a id="logout" style="cursor:pointer;" data-username="{{ person.username }}"><span class="glyphicon glyphicon-off"></span> Logout</a></div>
- {% else %}
- <div class="account"> You are logged in as <a href="/portal/account/">{{ email }}</a> | <a id="logout" style="cursor:pointer;" data-username="{{ email }}"><span class="glyphicon glyphicon-off"></span> Logout</a></div>
+ {% if section != 'Registration' %}
+ {% if username %}
+ {% if person.username %}
+ <div class="account">You are logged in as <a href="/portal/account/">{{ person.username }}</a> | <a id="logout" style="cursor:pointer;" data-username="{{ person.username }}"><span class="glyphicon glyphicon-off"></span> Logout</a></div>
+ {% else %}
+ <div class="account"> You are logged in as <a href="/portal/account/">{{ email }}</a> | <a id="logout" style="cursor:pointer;" data-username="{{ email }}"><span class="glyphicon glyphicon-off"></span> Logout</a></div>
+ {% endif %}
{% endif %}
{% endif %}
</div>
Organization: {{organization}}<br>
First name: {{first_name}}<br>
Last name: {{last_name}}<br>
+Username : {{ username }} <br>
Email: {{email}}<br>
<p></p>
<p>
-You may now log in to the portal using your email address and the password that you provided, but your access will be limited. To gain full access, two steps are required:
+ To gain full access, two steps are required:
</p>
<ul>
<input id="authority_hrn" name="org_name" class="form-control" style="width:590px" value="{{ organization }}"
title="Choose your organization (company/university) from the list that apears when you click in the field and start to type.
Use the arrow keys to scroll through the list; type part of the name to narrow down the list. If it is not in the list,
- please request its addition by clicking the link below. We will send an email to the managers that we have on record for
+ please choose the FIBRE organization. We will send an email to the managers that we have on record for
your organization, asking them to validate your sign-up request." required />
<p></p>
- <p>Organization not listed? <a href="/portal/join">Request its addition now.</a></p>
+ <!-- <p>Organization not listed? <a href="/portal/join">Request its addition now.</a></p> -->
</div>
</div>
</div>
title="Your e-mail address will be your identifier for logging in. We contact you to verify your account and then, occasionally, for important issues."
placeholder="Email" required />
</div>
+ <div class="form-group">
+ <label for="Reasons" class="control-label" >Reasons for Applying</label>
+ <p></p>
+ <textarea type="text" rows="4" cols="70" name="reasons" size="25" class="form-control" style="width:350px;height:60px" minlength="5" maxlength="250" value="{{reasons}}" placeholder="Reasons for applying" title="Identify yourself and tell us more about your expectations to use the testbed." required ></textarea>
+ </div>
</div>
<div class="col-md-6">
<div class="col-md-12">
<div class="form-group" id="register">
<p></p>
- <input class="submit btn btn-onelab" type="submit" value="Sign up" />
+ <input class="submit btn btn-onelab" type="submit" value="Request My Account" />
</div>
</div>
{% if authority.authority_hrn == "fibre.cpqd" %}
{value:"{{ authority.authority_hrn }}",label:"CENTRO DE PESQUISA E DESENVOLVIMENTO EM TELECOMUNICACOES"},
{% else %}
- {% if authority.authority_hrn == "fibre.i2cat" %}
- {value:"{{ authority.authority_hrn }}",label:"FOUNDATION, RESEARCH AND INNOVATION IN THE INTERNET AREA"},
- {% else %}
- {% if authority.authority_hrn == "fibre.uth" %}
- {value:"{{ authority.authority_hrn }}",label:"UNIVERSITY OF THESSALY"},
- {% else %}
- {% if authority.authority_hrn == "fibre.bristol" %}
- {value:"{{ authority.authority_hrn }}",label:"UNIVERSITY OF BRISTOL"},
- {% else %}
- {value:"{{ authority.authority_hrn }}",label:"FIBRE"},
- {% endif %}
+ {% if authority.authority_hrn == "fibre.rnp" %}
+ {value:"{{ authority.authority_hrn }}",label:"REDE NACIONAL DE ENSINO E PESQUISA"},
+ {% else %}
+ {% if authority.authority_hrn == "fibre.i2cat" %}
+ {value:"{{ authority.authority_hrn }}",label:"FOUNDATION, RESEARCH AND INNOVATION IN THE INTERNET AREA"},
+ {% else %}
+ {% if authority.authority_hrn == "fibre.uth" %}
+ {value:"{{ authority.authority_hrn }}",label:"UNIVERSITY OF THESSALY"},
+ {% else %}
+ {% if authority.authority_hrn == "fibre.bristol" %}
+ {value:"{{ authority.authority_hrn }}",label:"UNIVERSITY OF BRISTOL"},
+ {% else %}
+ {value:"{{ authority.authority_hrn }}",label:"FIBRE"},
+ {% endif %}
{% endif %}
{% endif %}
{% endif %}
+ {% endif %}
{% endif %}
{% endif %}
{% endif %}
</div>
<div class="row">
<h3>Sign up information received.</h3>
- <p>You can now log in to the portal. You will have limited access. </p>
- <p>To gain full access, two steps are required:</p>
+ <p>To gain full access, two steps are required:</p>
<ul>
- <li>1. You confirm your signup request by clicking on the link in the email that we have sent to your email address.</li>
- <li>2. A manager from your organization validates your request. (We have sent email to your organisation's registered managers.)</li>
+ <li>1. You confirm your signup request by clicking on the link in the email that we have sent to your email address.( Please verify your spam folder. )</li>
+ <li>2. A manager from the {{ REQINST }} will analize your request. (We have sent email to your organization's registered managers.)</li>
</ul>
<p></p>
<p></p>
<b>Public key :</b> {{public_key}}<br>
<b>Email :</b> {{email}}<br>
<b>User hrn :</b> {{user_hrn}}<br>
+<b>Reasons for applying :</b> {{ reasons }}<br>
<b>Portal url :</b> {{ current_site }}<br>
<p></p>
<p>You can validate the user <a href="https://{{current_site}}/portal/validate">here</a>.<p>
}
);
}
- }
+ };
+ function showMore(buttonId, divId){
+ var element = document.getElementById(buttonId);
+ var div_element = document.getElementById(divId);
+ if (element.value === '(+)'){
+ element.value = '(-)';
+ $('#'+divId).slideDown('fast');
+ }
+ else {
+ element.value = '(+)';
+ $('#'+divId).slideUp('fast');
+ }
+ return false;
+ }
</script>
<div class="col-md-12">
{% if my_authorities %}
{% for authority, requests in my_authorities.items %}
-
+ {% if authority == pi_authority or 'fibre'%}
<div class="col-md-12">
<h2>{{authority}}</h2>
- </div>
-
- <table class="table">
- <th>
- <td>Type</td>
- <td>Id</td>
- <td>Details</td>
- <td>Timestamp</td>
- <td>Status</td>
- </th>
- {% for request in requests %}
-
- <tr>
- <td>
- {% if request.allowed == 'allowed' %}
- <input class='portal__validate__checkbox' id='portal__validate__checkbox__{{request.type}}__{{request.id}}' type='checkbox'/>
- {% else %}
- {% if request.allowed == 'expired' %}
- expired
- {% else %} {# denied #}
- denied
- {% endif %}
- {% endif %}
- </td>
- <td>{{ request.type }}</td>
- <td>{{ request.id }}</td>
- <td>
- {% if request.type == 'user' %}
- Login: {{request.login}} -- First name: {{request.first_name}} -- Last name: {{request.last_name}} -- Email: {{request.email}}
- {% else %}
- {% if request.type == 'slice' %}
- Slice name: {{request.slice_name}} -- Number of nodes: {{request.number_of_nodes}} -- Type of nodes: {{request.type_of_nodes}} -- Purpose: {{request.purpose}}
- {% else %} {# authority #}
- Authority name: {{request.site_name}} -- authority_hrn: {{request.site_authority}} -- City: {{request.address_city}} -- Country: {{request.address_country}}
- {% endif %}
- {% endif %}
- </td>
- <td>{{ request.timestamp }}</td>
-
- <td><span id='portal__status__{{request.type}}__{{request.id}}'></span></td>
-
- <!--<div class='portal_validate_request {{request.type}} {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}'> -->
- </tr>
+ <table class="table">
+ <th>
+ <td>Type</td>
+ <td>Id</td>
+ <td>Details</td>
+ <td>Timestamp</td>
+ <td>Status</td>
+ </th>
+ {% for request in requests %}
+ <tr>
+ {% if request.object_auth == pi_authority %}
+ <td>
+ {% if request.allowed == 'allowed' %}
+ <input class='portal__validate__checkbox' id='portal__validate__checkbox__{{request.type}}__{{request.id}}' type='checkbox'/>
+ {% else %}
+ {% if request.allowed == 'expired' %}
+ expired
+ {% else %} {# denied #}
+ denied
+ {% endif %}
+ {% endif %}
+ </td>
+ <td>{{ request.type }}</td>
+ <td>{{ request.id }}</td>
+ <td>
+ {% if request.type == 'user' %}
+ Login: {{request.login}} -- First name: {{request.first_name}} -- Last name: {{request.last_name}} -- Email: {{request.email}}
+ <input type = "button" id = "moreBtn_{{request.id}}" value = "(+)" onclick = "showMore('moreBtn_{{request.id}}','reasons_{{request.id}}')" style="color:blue; padding:0; border:none; background:none">
+ <div id="reasons_{{request.id}}" style="display:none"> Reasons for Applying:<br> {{request.reasons}} </div>
+ {% else %}
+ {% if request.type == 'slice' %}
+ Slice name: {{request.slice_name}} -- User_hrn: {{ request.user_hrn }} -- Number of nodes: {{request.number_of_nodes}} -- Type of nodes: {{request.type_of_nodes}} -- Purpose: {{request.purpose}}
+ {% else %} {# authority #}
+ Authority name: {{request.site_name}} -- authority_hrn: {{request.site_authority}} -- City: {{request.address_city}} -- Country: {{request.address_country}}
+ {% endif %}
+ {% endif %}
+ </td>
+ <td>{{ request.timestamp }}</td>
+
+ <td><span id='portal__status__{{request.type}}__{{request.id}}'></span></td>
- {% endfor %}
- </table>
+ <!--<div class='portal_validate_request {{request.type}} {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}'> -->
+ {% endif %}
+ </tr>
+ {% endfor %}
+ </table>
</div>
+ {% endif %}
{% endfor %}
{% else %}
{% if sub_authorities %}
{% for authority, requests in sub_authorities.items %}
- <div class="col-md-12">
- <h3>{{authority}}</h3>
- <table class="table">
- <th>
- <td>Type</td>
- <td>Id</td>
- <td>Details</td>
- <td>Timestamp</td>
- <td>Status</td>
- </th>
- {% for request in requests %}
- <tr>
- <td>
- {% if request.allowed == 'allowed' %}
- <input class='portal__validate__checkbox' id='portal__validate__checkbox__{{request.type}}__{{request.id}}' type='checkbox'/>
- {% else %}
- {% if request.allowed == 'expired' %}
- expired
- {% else %} {# denied #}
- denied
+ {% if authority == pi_authority or 'fibre'%}
+ <div class="col-md-12">
+ <h3>{{authority}}</h3>
+ <table class="table">
+ <th>
+ <td>Type</td>
+ <td>Id</td>
+ <td>Details</td>
+ <td>Timestamp</td>
+ <td>Status</td>
+ </th>
+ {% for request in requests %}
+ <tr>
+ {% if request.object_auth == pi_authority %}
+ <td>
+ {% if request.allowed == 'allowed' %}
+ <input class='portal__validate__checkbox' id='portal__validate__checkbox__{{request.type}}__{{request.id}}' type='checkbox'/>
+ {% else %}
+ {% if request.allowed == 'expired' %}
+ expired
+ {% else %} {# denied #}
+ denied
+ {% endif %}
{% endif %}
- {% endif %}
- </td>
- <td>{{ request.type }}</td>
- <td>{{ request.id }}</td>
- <td>
- {% if request.type == 'user' %}
- Login: {{request.login}} -- First name: {{request.first_name}} -- Last name: {{request.last_name}} -- Email: {{request.email}}
- {% else %}
- {% if request.type == 'slice' %}
- Slice name: {{request.slice_name}} -- Number of nodes: {{request.number_of_nodes}} -- Type of nodes: {{request.type_of_nodes}} -- Purpose: {{request.purpose}}
- {% else %} {# authority #}
- Authority name: {{request.site_name}} -- authority_hrn: {{request.site_authority}} -- City: {{request.address_city}} -- Country: {{request.address_country}}
- {% endif %}
- {% endif %}
- </td>
- <td>{{ request.timestamp }}</td>
-
- <td><span id='portal__status__{{request.type}}__{{request.id}}'></span></td>
-
+ </td>
+ <td>{{ request.type }}</td>
+ <td>{{ request.id }}</td>
+ <td>
+ {% if request.type == 'user' %}
+ Login: {{request.login}} -- First name: {{request.first_name}} -- Last name: {{request.last_name}} -- Email: {{request.email}}
+ {% else %}
+ {% if request.type == 'slice' %}
+ Slice name: {{request.slice_name}} -- Number of nodes: {{request.number_of_nodes}} -- Type of nodes: {{request.type_of_nodes}} -- Purpose: {{request.purpose}}
+ {% else %} {# authority #}
+ Authority name: {{request.site_name}} -- authority_hrn: {{request.site_authority}} -- City: {{request.address_city}} -- Country: {{request.address_country}}
+ {% endif %}
+ {% endif %}
+ </td>
+ <td>{{ request.timestamp }}</td>
+
+ <td><span id='portal__status__{{request.type}}__{{request.id}}'></span></td>
+
<!--<div class='portal_validate_request {{request.type}} {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}'> -->
- </tr>
- {% endfor %}
- </table>
- </div>
+ {% endif %}
+ </tr>
+ {% endfor %}
+ </table>
+ </div>
+ {% endif %}
{% endfor %}
{% else %}
<div class="col-md-12">
{% if delegation_authorities %}
{% for authority, requests in delegation_authorities.items %}
+ {% if authority == pi_authority or 'fibre'%}
<div class="col-md-12">
<h3>{{authority}}</h3>
<table class="table">
</th>
{% for request in requests %}
<tr>
+ {% if request.object_auth == pi_authority %}
<td>
{% if request.allowed == 'allowed' %}
<input class='portal__validate__checkbox' id='portal__validate__checkbox__{{request.type}}__{{request.id}}' type='checkbox'/>
{% endif %}
</td>
<td>{{ request.timestamp }}</td>
-
+
<td><span id='portal__status__{{request.type}}__{{request.id}}'></span></td>
-
- <!--<div class='portal_validate_request {{request.type}} {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}'> -->
+
+ <!--<div class='portal_validate_request {{request.type}} {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}'> -->
+ {% endif %}
</tr>
{% endfor %}
</table>
- </div>
- {% endfor %}
+ </div>
+ {% endif %}
+ {% endfor %}
{% else %}
<div class="col-md-12">
<i>There is no pending request waiting for validation.</i>
context = super(ValidatePendingView, self).get_context_data(**kwargs)
print "testing"
print ctx_my_authorities
+ print auth_hrn
context['my_authorities'] = ctx_my_authorities
context['sub_authorities'] = ctx_sub_authorities
context['delegation_authorities'] = ctx_delegation_authorities