From 944adae7c58e58fc12fbae3709eec5d37eba98ab Mon Sep 17 00:00:00 2001 From: Ciro Scognamiglio Date: Mon, 7 Jul 2014 18:10:03 +0200 Subject: [PATCH] fixed management requests tab --- portal/managementtabrequests.py | 50 ++-- portal/templates/management-tab-requests.html | 228 ++++++++++++++++++ 2 files changed, 264 insertions(+), 14 deletions(-) create mode 100644 portal/templates/management-tab-requests.html diff --git a/portal/managementtabrequests.py b/portal/managementtabrequests.py index f2cea926..50801e93 100644 --- a/portal/managementtabrequests.py +++ b/portal/managementtabrequests.py @@ -22,7 +22,7 @@ import json class ManagementRequestsView (LoginRequiredView, ThemeView): template_name = "management-tab-requests.html" - def get(self, request): + def get_context_data(self, **kwargs): ctx_my_authorities = {} ctx_delegation_authorities = {} @@ -31,7 +31,7 @@ class ManagementRequestsView (LoginRequiredView, ThemeView): # The user need to be logged in - if (request.user): + if (self.request.user): user_query = Query().get('local:user').filter_by('email', '==', self.request.user.email).select('user_id') user, = execute_query(self.request, user_query) @@ -138,22 +138,44 @@ class ManagementRequestsView (LoginRequiredView, ThemeView): if not auth_hrn in dest: dest[auth_hrn] = [] - dest[auth_hrn].append(request) + dest[auth_hrn].append(r) - env = {} - env['my_authorities'] = ctx_my_authorities - env['sub_authorities'] = ctx_sub_authorities - env['delegation_authorities'] = ctx_delegation_authorities +# env = {} +# env['my_authorities'] = ctx_my_authorities +# env['sub_authorities'] = ctx_sub_authorities +# env['delegation_authorities'] = ctx_delegation_authorities +# +# # XXX This is repeated in all pages +# # more general variables expected in the template +# # the menu items on the top +# #env['topmenu_items'] = topmenu_items_live('Validation', page) +# # so we can sho who is logged +# env['username'] = request.user +# env['pi'] = "is_pi" +# env['theme'] = self.theme +# env['section'] = "Requests" + + context = super(ManagementRequestsView, self).get_context_data(**kwargs) + print "testing" + print ctx_my_authorities + context['my_authorities'] = ctx_my_authorities + context['sub_authorities'] = ctx_sub_authorities + context['delegation_authorities'] = ctx_delegation_authorities # XXX This is repeated in all pages # more general variables expected in the template + context['title'] = 'Test view that combines various plugins' # the menu items on the top - #env['topmenu_items'] = topmenu_items_live('Validation', page) + #context['topmenu_items'] = topmenu_items_live('Validation', page) # so we can sho who is logged - env['username'] = request.user - env['pi'] = "is_pi" - env['theme'] = self.theme - env['section'] = "Requests" - - return render_to_response(self.template, env, context_instance=RequestContext(request)) + context['username'] = self.request.user + context['pi'] = "is_pi" + context['theme'] = self.theme + context['section'] = "Requests" + # XXX We need to prepare the page for queries + #context.update(page.prelude_env()) + + return context + + #return render_to_response(self.template, env, context_instance=RequestContext(request)) diff --git a/portal/templates/management-tab-requests.html b/portal/templates/management-tab-requests.html new file mode 100644 index 00000000..1356ef52 --- /dev/null +++ b/portal/templates/management-tab-requests.html @@ -0,0 +1,228 @@ + + +
+

Authorities

+
+{% if my_authorities %} + + {% for authority, requests in my_authorities.items %} + +
+

{{authority}}

+
+ + + + + + + + + {% for request in requests %} + + + + + + + + + + + + + + {% endfor %} +
+ TypeIdDetailsTimestampStatus
+ {% if request.allowed == 'allowed' %} + + {% else %} + {% if request.allowed == 'expired' %} + expired + {% else %} {# denied #} + denied + {% endif %} + {% endif %} + {{ request.type }}{{ request.id }} + {% 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 %} + {{ request.timestamp }}
+ + {% endfor %} + +{% else %} +
+ There is no pending request waiting for validation. +
+{% endif %} + +
+

Sub-Authorities

+
+{% if sub_authorities %} + + {% for authority, requests in sub_authorities.items %} +
+

{{authority}}

+ + + + + + + + {% for request in requests %} + + + + + + + + + + + + {% endfor %} +
+ TypeIdDetailsTimestampStatus
+ {% if request.allowed == 'allowed' %} + + {% else %} + {% if request.allowed == 'expired' %} + expired + {% else %} {# denied #} + denied + {% endif %} + {% endif %} + {{ request.type }}{{ request.id }} + {% 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 %} + {{ request.timestamp }}
+
+ {% endfor %} +{% else %} +
+ There is no pending request waiting for validation. +
+{% endif %} + +
+

Authorities with delegation

+
+ +{% if delegation_authorities %} + + {% for authority, requests in delegation_authorities.items %} +
+

{{authority}}

+ + + + + + + + {% for request in requests %} + + + + + + + + + + + + {% endfor %} +
+ TypeIdDetailsTimestampStatus
+ {% if request.allowed == 'allowed' %} + + {% else %} + {% if request.allowed == 'expired' %} + expired + {% else %} {# denied #} + denied + {% endif %} + {% endif %} + {{ request.type }}{{ request.id }} + {% 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 %} + {{ request.timestamp }}
+
+ {% endfor %} +{% else %} +
+ There is no pending request waiting for validation. +
+{% endif %} +
+ +
-- 2.43.0