X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=portal%2Fmanagementtababout.py;h=02714d41bb67b1c187de7e631cd1c5da6d41236e;hb=89af8babd28a7da90ffe59be3ce7b7e812734cd0;hp=8a5f97a8262f984e74d6bd34a78f763f51fde948;hpb=58575ad29f72754370a220cc20bf0eaa278f5263;p=myslice.git diff --git a/portal/managementtababout.py b/portal/managementtababout.py index 8a5f97a8..02714d41 100644 --- a/portal/managementtababout.py +++ b/portal/managementtababout.py @@ -1,3 +1,4 @@ +import json # this somehow is not used anymore - should it not be ? from django.core.context_processors import csrf from django.http import HttpResponseRedirect @@ -11,40 +12,42 @@ from unfold.loginrequired import FreeAccessView from manifold.core.query import Query from manifoldapi.manifoldapi import execute_query from manifoldapi.manifoldresult import ManifoldResult -from myslice.configengine import ConfigEngine +from myslice.configengine import ConfigEngine from myslice.theme import ThemeView -import json +from myslice.settings import logger class ManagementAboutView (FreeAccessView, ThemeView): template_name = 'management-tab-about.html' def get (self, request): + + authority_contacts = {} + authority = {'authority_hrn':'fed4fire.upmc'} if request.user.is_authenticated(): - user_query = Query().get('user').select('user_hrn','parent_authority').filter_by('user_hrn','==','$user_hrn') - user_details = execute_query(self.request, user_query) - user_local_query = Query().get('local:user').select('config').filter_by('email','==',str(self.request.user)) user_local_details = execute_query(self.request, user_local_query) user_authority = json.loads(user_local_details[0]['config']).get('authority') - - authority_query = Query().get('authority').select('description', 'authority_hrn', 'legal', 'address', 'abbreviated_name', + logger.info("**************________ management about = {}".format(user_authority)) + # XXX Should be done using Metadata + # select column.name from local:object where table=='authority' + authority_query = Query().get('authority').select('authority_hrn', 'name', 'address', 'enabled','description', 'scientific', 'city', 'name', 'url', 'country', 'enabled', 'longitude', - 'tech', 'latitude', 'pi_users', 'parent_authority', 'onelab_membership', + 'tech', 'latitude', 'pi_users', 'onelab_membership', 'postcode').filter_by('authority_hrn','==',user_authority) authority_details = execute_query(self.request, authority_query) - authority_contacts = {} - authority_contacts['scientific'] = [ x.strip()[1:-1] for x in authority_details[0]['scientific'][1:-1].split(',') ] - authority_contacts['technical'] = [ x.strip()[1:-1] for x in authority_details[0]['tech'][1:-1].split(',') ] - - authority_contacts['legal'] = [ x.strip().replace('"','') for x in authority_details[0]['legal'][1:-1].split(',') ] - print authority_contacts['legal'] - - - print "#######",authority_contacts - print "$$$$$$$",user_local_details - print "@@@@@@@",authority_details + if authority_details : + authority = authority_details[0] + if 'scientific' in authority and authority['scientific'] is not None: + authority_contacts['scientific'] = [ x.strip()[1:-1] for x in authority['scientific'][1:-1].split(',') ] + if 'technical' in authority and authority['technical'] is not None: + authority_contacts['technical'] = [ x.strip()[1:-1] for x in authority['tech'][1:-1].split(',') ] + if 'legal' in authority and authority['legal'] is not None: + authority_contacts['legal'] = [ x.strip().replace('"','') for x in authority['legal'][1:-1].split(',') ] + else : + authority_contacts = None + authority = None - return render_to_response(self.template, { 'theme' : self.theme, 'authority' : authority_details[0], 'authority_contacts' : authority_contacts }, context_instance=RequestContext(request)) + return render_to_response(self.template, { 'theme' : self.theme, 'authority' : authority, 'authority_contacts' : authority_contacts }, context_instance=RequestContext(request))