import portal.slicetabusers
import portal.slicetabmeasurements
+import portal.managementtababout
import portal.managementtabrequests
#### high level choices
(r'^experiment/(?P<slicename>[^/]+)/?$', 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')),
--- /dev/null
+# 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))
+
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
<i>There is no pending request waiting for validation.</i>
</div>
{% endif %}
-
+<br />
<div class="col-md-12">
<h2>Sub-Authorities</h2>
</div>
<i>There is no pending request waiting for validation.</i>
</div>
{% endif %}
-
+<br />
<div class="col-md-12">
<h2>Authorities with delegation</h2>
</div>
<i>There is no pending request waiting for validation.</i>
</div>
{% endif %}
+<br />
<div class="col-md-12">
<button class="btn btn-onelab" type="button" id="portal__validate" onclick="on_click_event();"><span class="glyphicon glyphicon-ok"></span> Validate</button>
</div>
<div class="row">
<div class="col-md-12">
<ul class="nav nav-tabs nav-section">
- <li class="active"><a href="#info">About</a></li>
+ <li class="active"><a href="#about">About</a></li>
<li><a href="#users">Users</a></li>
<li><a href="#slices">Slices</a></li>
<li><a href="#requests">Requests</a></li>
</div>
</div>
<div class="container tab-content">
- <div class="tab-pane active row" id="info">
- <div class="col-md-12 el">
- <div id="authority-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Authority" /></div>
- <div id="authority-tab-loaded" style="display:none;">
- <div id="authority-data" style="float:left; width:50%;"></div>
- <div id="onelab_membership" style="float:right; width:50%;">
- <img src="{{ STATIC_URL }}img/onelab-logo.png" alt="" /><br>
- <div id="onelab-data"></div>
- </div>
- </div>
- </div>
+ <div class="tab-pane active row" id="about">
</div>
<div class="tab-pane row" id="users" data-authority="{{user_details.parent_authority}}">
<div class="tab-pane row" id="slices">
<div class="col-md-12 el">
- {% if 'is_pi' in pi %}
- <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create slice</button>
- {% else %}
- <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Request slice</button>
- {% endif %}
- <br /><br />
<div id="slice-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
<div id="slice-tab-loaded" style="display:none;">
<table id="slice-tab" class="table">
</div>
{% if 'is_pi' in pi %}
<div>
+ {% if 'is_pi' in pi %}
+ <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create slice</button>
+ {% else %}
+ <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Request slice</button>
+ {% endif %}
<button id="renewslices" type="button" class="btn btn-primary"><span class="glyphicon glyphicon-refresh"></span> Renew Slices</button>
<button id="deleteslices" type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Delete Slices</button>
</div>
$(document).ready(function() {
{% if person %}
{% if user_details.parent_authority %}
-
- $.post("/rest/authority/",{'filters':{'authority_hrn':'{{user_details.parent_authority}}'}}, function( data ) {
-
- var authority_data = [];
- var onelab_data = [];
- /* 'city','enabled','legal','longitude','onelab_membership','address','parent_authority','slice','user','country',
- 'tech','abbreviated_name','url','postcode','description','scientific','authority_hrn','latitude','name' */
- $.each( data, function( key, val ) {
- $('#authority_name').text(val.name);
- authority_row = "<img src='{{ STATIC_URL }}img/institutions/{{user_details.parent_authority}}.gif' alt='' /><br>";
- authority_row += "<br>";
- authority_row += "<b>authority:</b> "+val.authority_hrn+"<br>";
- authority_row += "<br>";
- authority_row += "<b>"+val.name+"</b><br>";
- authority_row += "<br>";
- authority_row += "<b>Address:</b> "+val.address+"<br>";
- authority_row += "<b>City:</b> "+val.postcode+" "+val.city+"<br>";
- authority_row += "<br>";
- authority_row += "<b>Country:</b> "+val.country+"<br>";
- authority_row += "<br>";
- authority_row += "<br>";
- authority_row += "<h2>Contacts</h2>";
- authority_row += "<b>Legal:</b> ";
- /*
-
- TODO: find a way to express JSON correctly given the constrains: CSV / JSON
-
- legal = jQuery.parseJSON(val.legal);
- if($.isArray(legal)){
- $.each(legal, function(k,v){
- authority_row += k+" "+v+"<br>";
- });
- }else{
- */
- authority_row += val.legal+"<br>";
- //}
- authority_row += "<br>";
- authority_row += "<b>Scientific:</b> ";
- /*
- scientific = jQuery.parseJSON(val.scientific);
- if($.isArray(scientific)){
- $.each(scientific, function(v){
- authority_row += v+", ";
- });
- }else{
- */
- authority_row += val.scientific+"<br>";
- //}
- onelab_membership = "<b>Status: </b>"+val.onelab_membership;
- onelab_data.push(onelab_membership);
- authority_data.push(authority_row);
-
- });
- $("div#authority-data").html(authority_data.join( "" ));
- $("div#onelab-data").html(onelab_data.join( "" ));
- $("div#authority-tab-loaded").css("display","block");
- $("div#authority-tab-loading").css("display","none");
- });
$.post("/rest/slice/",{'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
var list_slices = [];
e.preventDefault();
$(this).tab('show');
var id = $(this).attr('href').substr(1);
- if (id == 'requests')
+ if ((id == 'requests') || (id == 'about'))
$("#" + id).load('/management/' + id);
});
var hash = window.location.hash;
if (hash) {
$('.nav-tabs a[href='+hash+']').click();
+ } else {
+ $('.nav-tabs a[href=#about]').click();
}
});
</script>
--- /dev/null
+{% load portal_filters %}
+<div class="col-md-6">
+ <div>
+ <img src="{{ STATIC_URL|add:'img/institutions/'|add:authority.authority_hrn|add:'.gif'|file_exists }}" alt="{{authority.name}}">
+ </div>
+ <br />
+ <h3><a href="{{authority.url}}">{{authority.name}}</a></h3>
+ <p>
+ {{authority.address}} <br />
+ {{authority.postcode}} {{authority.city}} <br />
+ {{authority.country}}
+ </p>
+ <br />
+ <h4>Onelab membership</h4>
+ <p>
+ {{ authority.onelab_membership }}
+ </p>
+</div>
+<div class="col-md-6">
+ <h4>Legal Contact:</h4>
+ <p>
+ {% for c in authority_contacts.legal %}
+ {{ c }} <br />
+ {% endfor %}
+ </p>
+ <br />
+ <h4>Scientific Contact:</h4>
+ <p>
+ {% for c in authority_contacts.scientific %}
+ {{ c }} <br />
+ {% endfor %}
+ </p>
+ <br />
+ <h4>Technical Contact:</h4>
+ <p>
+ {% for c in authority_contacts.technical %}
+ {{ c }} <br />
+ {% endfor %}
+ </p>
+</div>
+<script>$(document).ready(function() {$('#authority_name').text('{{authority.name}}')});</script>
\ No newline at end of file
});
if (ids.length > 0) {
var id_str = ids.join('/');
-
// XXX spinner
-
$.getJSON('/portal/validate_action/' + id_str,
function(status) {
$.each(status, function(request_type__id, request_status) {
{% endfor %}
</table>
- </div>
{% endfor %}
{% else %}
<i>There is no pending request waiting for validation.</i>
</div>
{% endif %}
-
+<div>nnllknjkn<br /><br /></div>
<div class="col-md-12">
<h2>Sub-Authorities</h2>
</div>
{% for authority, requests in sub_authorities.items %}
<div class="col-md-12">
- <h3>{{authority}}</h3>
- <table class="table">
+ <h2>{{authority}}</h2>
+ </div>
+
+ <table class="table">
<th>
<td>Type</td>
<td>Id</td>
<!--<div class='portal_validate_request {{request.type}} {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}'> -->
</tr>
{% endfor %}
- </table>
- </div>
+ </table>
{% endfor %}
{% else %}
<div class="col-md-12">
{% for authority, requests in delegation_authorities.items %}
<div class="col-md-12">
<h3>{{authority}}</h3>
- <table class="table">
+ </div>
+ <table class="table">
<th>
<td>Type</td>
<td>Id</td>
<!--<div class='portal_validate_request {{request.type}} {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}'> -->
</tr>
{% endfor %}
- </table>
- </div>
+ </table>
{% endfor %}
{% else %}
<div class="col-md-12">
<div class="col-md-3">
<form action="" method="post">{% csrf_token %}
{{ form.new_password1.errors }}
- <label for="id_new_password1">{% trans 'New password:' %}</label>
+ <label for="id_new_password1">New password:</label>
</div>
<div class="col-md-3">
{{ form.new_password1 }}
<div class="row">
<div class="col-md-3">
{{ form.new_password2.errors }}
- <label for="id_new_password2">{% trans 'Confirm password:' %}</label>
+ <label for="id_new_password2">Confirm password:</label>
</div>
<div class="col-md-3">
{{ form.new_password2 }}
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()
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