From: Ciro Scognamiglio Date: Tue, 15 Jul 2014 13:46:13 +0000 (+0200) Subject: Management About page reworked + cosmetic changes X-Git-Tag: myslice-1.0~57^2~3 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=58575ad29f72754370a220cc20bf0eaa278f5263;p=myslice.git Management About page reworked + cosmetic changes --- diff --git a/myslice/urls.py b/myslice/urls.py index 68ec521a..1d0248cb 100644 --- a/myslice/urls.py +++ b/myslice/urls.py @@ -31,6 +31,7 @@ import portal.slicetabtestbeds import portal.slicetabusers import portal.slicetabmeasurements +import portal.managementtababout import portal.managementtabrequests #### high level choices @@ -94,6 +95,7 @@ urls = [ (r'^experiment/(?P[^/]+)/?$', portal.slicetabexperiment.ExperimentView.as_view()), # (r'^management/requests/?$', portal.managementtabrequests.ManagementRequestsView.as_view()), + (r'^management/about/?$', portal.managementtababout.ManagementAboutView.as_view()), # url(r'^register/?$', RegistrationView.as_view(), name='registration'), url(r'^portal/', include('portal.urls')), diff --git a/portal/managementtababout.py b/portal/managementtababout.py new file mode 100644 index 00000000..8a5f97a8 --- /dev/null +++ b/portal/managementtababout.py @@ -0,0 +1,50 @@ +# 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.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.manifoldresult import ManifoldResult +from myslice.configengine import ConfigEngine + +from myslice.theme import ThemeView +import json + +class ManagementAboutView (FreeAccessView, ThemeView): + template_name = 'management-tab-about.html' + + def get (self, request): + 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', + 'scientific', 'city', 'name', 'url', 'country', 'enabled', 'longitude', + 'tech', 'latitude', 'pi_users', 'parent_authority', '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 + + return render_to_response(self.template, { 'theme' : self.theme, 'authority' : authority_details[0], 'authority_contacts' : authority_contacts }, context_instance=RequestContext(request)) + diff --git a/portal/managementtabrequests.py b/portal/managementtabrequests.py index 50801e93..850bbc68 100644 --- a/portal/managementtabrequests.py +++ b/portal/managementtabrequests.py @@ -7,13 +7,13 @@ from manifoldapi.manifoldapi import execute_query from django.views.generic.base import TemplateView from unfold.loginrequired import LoginRequiredView -from django.http import HttpResponse -from django.shortcuts import render +from django.http import HttpResponse +from django.shortcuts import render -from manifold.core.query import Query, AnalyzedQuery -from manifoldapi.manifoldapi import execute_query +from manifold.core.query import Query, AnalyzedQuery +from manifoldapi.manifoldapi import execute_query -from portal.actions import get_requests +from portal.actions import get_requests from myslice.theme import ThemeView diff --git a/portal/templates/institution-tab-info.html b/portal/templates/institution-tab-info.html deleted file mode 100644 index e69de29b..00000000 diff --git a/portal/templates/management-tab-requests.html b/portal/templates/management-tab-requests.html index 36797962..d534915e 100644 --- a/portal/templates/management-tab-requests.html +++ b/portal/templates/management-tab-requests.html @@ -106,7 +106,7 @@ There is no pending request waiting for validation. {% endif %} - +

Sub-Authorities

@@ -164,7 +164,7 @@ There is no pending request waiting for validation. {% endif %} - +

Authorities with delegation

@@ -223,6 +223,7 @@ There is no pending request waiting for validation. {% endif %} +
diff --git a/portal/templates/onelab/onelab_institution.html b/portal/templates/onelab/onelab_institution.html index 6c358123..c8a668f1 100644 --- a/portal/templates/onelab/onelab_institution.html +++ b/portal/templates/onelab/onelab_institution.html @@ -18,7 +18,7 @@
-
-
-
Loading Authority
- -
+
@@ -66,12 +56,6 @@
- {% if 'is_pi' in pi %} - - {% else %} - - {% endif %} -

Loading Slices
{% endfor %} {% else %} @@ -106,7 +103,7 @@ There is no pending request waiting for validation.
{% endif %} - +
nnllknjkn

Sub-Authorities

@@ -114,8 +111,10 @@ {% for authority, requests in sub_authorities.items %}
-

{{authority}}

- +

{{authority}}

+ + +
@@ -156,8 +155,7 @@ {% endfor %} -
Type Id
-
+ {% endfor %} {% else %}
@@ -174,7 +172,8 @@ {% for authority, requests in delegation_authorities.items %}

{{authority}}

- + +
@@ -215,8 +214,7 @@ {% endfor %} -
Type Id
-
+ {% endfor %} {% else %}
diff --git a/portal/templates/password_reset_confirm.html b/portal/templates/password_reset_confirm.html index 868f8181..eed94a0c 100644 --- a/portal/templates/password_reset_confirm.html +++ b/portal/templates/password_reset_confirm.html @@ -19,7 +19,7 @@
{% csrf_token %} {{ form.new_password1.errors }} - +
{{ form.new_password1 }} @@ -28,7 +28,7 @@
{{ form.new_password2.errors }} - +
{{ form.new_password2 }} diff --git a/portal/templatetags/portal_filters.py b/portal/templatetags/portal_filters.py index 9bd0175a..74f113ad 100644 --- a/portal/templatetags/portal_filters.py +++ b/portal/templatetags/portal_filters.py @@ -1,5 +1,6 @@ from django import template from django.template.loader_tags import do_include +from django.core.files.storage import default_storage from myslice.settings import theme register = template.Library() @@ -37,4 +38,13 @@ def widget(parser, token): raise template.TemplateSyntaxError, \ "%r tag requires a single argument" % token.contents.split()[0] - return IncludeNode(template_name[1:-1]) \ No newline at end of file + return IncludeNode(template_name[1:-1]) + +@register.filter(name='file_exists') +def file_exists(filepath): + if default_storage.exists('portal' + filepath): + return filepath + else: + index = filepath.rfind('/') + new_filepath = filepath[:index] + '/image.png' + return new_filepath \ No newline at end of file