X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=portal%2Fviews.py;h=d454502e417c2e8a92076086300a2af5589b241d;hb=83f238a32f62a34370f24d69e85823c709d95627;hp=2029e70bbe25c7c9c65f4afe54b2fe9d62a96eff;hpb=1aea42c3668602aacfe22bc762ee939672129f53;p=myslice.git diff --git a/portal/views.py b/portal/views.py index 2029e70b..d454502e 100644 --- a/portal/views.py +++ b/portal/views.py @@ -24,14 +24,16 @@ import json from django.http import HttpResponseRedirect, HttpResponse -from django.views.generic.base import TemplateView from django.shortcuts import render from django.template.loader import render_to_string -from myslice.viewutils import topmenu_items, the_user +from unfold.loginrequired import FreeAccessView +from ui.topmenu import topmenu_items, the_user -from plugins.pres_view import PresView from portal.event import Event +# presview is put in observation for now +#from plugins.pres_view import PresView +from plugins.raw import Raw # these seem totally unused for now #from portal.util import RegistrationView, ActivationView @@ -47,19 +49,20 @@ from unfold.page import Page # all the other ones have now migrated into separate classes/files for more convenience # I'm leaving these ones here for now as I could not exactly figure what the purpose was # (i.e. what the correct name should be, as presviewview was a bit cryptic) -class PresViewView(TemplateView): +class PresViewView(FreeAccessView): template_name = "view-unfold1.html" def get_context_data(self, **kwargs): page = Page(self.request) - pres_view = PresView(page = page) +# pres_view = PresView(page = page) + pres_view = Raw(page = page,html="

PresView needs to be integrated

") context = super(PresViewView, self).get_context_data(**kwargs) #context['ALL_STATIC'] = "all_static" - context['unfold1_main'] = pres_view.render(self.request) + context['unfold_main'] = pres_view.render(self.request) # XXX This is repeated in all pages # more general variables expected in the template @@ -219,7 +222,7 @@ def pres_view_static(request, constraints, id): json_answer = json.dumps(cmd) return HttpResponse (json_answer, mimetype="application/json") -class ValidatePendingView(TemplateView): +class ValidatePendingView(FreeAccessView): template_name = "validate_pending.html" def get_context_data(self, **kwargs): @@ -268,26 +271,44 @@ class ValidatePendingView(TemplateView): all_authorities.append(auth) platform_ids.append(sfa_platform['platform_id']) + print "W: Hardcoding platform myslice" + # There has been a tweak on how new platforms are referencing a + # so-called 'myslice' platform for storing authentication tokens. + # XXX This has to be removed in final versions. + myslice_platforms_query = Query().get('local:platform').filter_by('platform', '==', 'myslice').select('platform_id') + myslice_platforms = execute_query(self.request, myslice_platforms_query) + if myslice_platforms: + myslice_platform, = myslice_platforms + platform_ids.append(myslice_platform['platform_id']) + # We can check on which the user has authoritity credentials = PI rights credential_authorities = set() credential_authorities_expired = set() # User account on these registries - user_accounts_query = Query.get('local:account').filter_by('user_id', '==', user_id).filter_by('platform_id', 'included', platform_ids).select('config') + user_accounts_query = Query.get('local:account').filter_by('user_id', '==', user_id).filter_by('platform_id', 'included', platform_ids).select('auth_type', 'config') user_accounts = execute_query(self.request, user_accounts_query) #print "=" * 80 #print user_accounts #print "=" * 80 for user_account in user_accounts: + + print "USER ACCOUNT", user_account + if user_account['auth_type'] == 'reference': + continue # we hardcoded the myslice platform... + config = json.loads(user_account['config']) creds = [] + print "CONFIG KEYS", config.keys() if 'authority_credentials' in config: + print "***", config['authority_credentials'].keys() for authority_hrn, credential in config['authority_credentials'].items(): #if credential is not expired: credential_authorities.add(authority_hrn) #else # credential_authorities_expired.add(authority_hrn) if 'delegated_authority_credentials' in config: + print "***", config['delegated_authority_credentials'].keys() for authority_hrn, credential in config['delegated_authority_credentials'].items(): #if credential is not expired: credential_authorities.add(authority_hrn) @@ -372,7 +393,7 @@ class ValidatePendingView(TemplateView): # more general variables expected in the template context['title'] = 'Test view that combines various plugins' # the menu items on the top - context['topmenu_items'] = topmenu_items('Dashboard', self.request) + context['topmenu_items'] = topmenu_items('Validation', self.request) # so we can sho who is logged context['username'] = the_user(self.request)