Commit ae7d3735ec8b5e941b79020434acaef4d5bf2423
1 parent
5139a8ed
Exists in
dev
improving admin dashboard pages for users and scientific programs
Showing
5 changed files
with
51 additions
and
8 deletions
Show diff stats
src/core/pyros_django/dashboard/templates/dashboard/user_detail.html
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | |
3 | 3 | {% block content %} |
4 | 4 | {% load tags %} |
5 | - | |
5 | + <a href="{% url "users" %}" class="btn btn-info" role="button">Return to list of users</a> | |
6 | 6 | <h1>Name : {{ user.first_name }} {{ user.last_name }}</h1> |
7 | 7 | <br> <br> |
8 | 8 | <p><strong>Email : </strong> {{user.email }}</p> |
... | ... | @@ -20,8 +20,20 @@ |
20 | 20 | <p><strong>Put validation beginning : </strong>{{ user.putvalid_beg }}</p> |
21 | 21 | <p><strong>Put validation end : </strong>{{ user.putvalid_end }}</p> |
22 | 22 | <p><strong>Quota : </strong>{{ user.quota }}</p> |
23 | - <p><strong>Scientific Program : </strong> {% for area in user.scientific_programs.all %}{{ area }} </p> | |
23 | + <p><strong>Scientific Program : </strong> <table class="table table-bordered table-hover table-striped tablesorter" style="font-family: 'Montserra', sans-serif;"> | |
24 | + <thead> | |
25 | + <tr> | |
26 | + <th>Name <i class="fa fa-sort"></i></th> | |
27 | + </tr> | |
28 | + </thead> | |
29 | + <tbody> | |
30 | + {% for sp in user.scientific_programs.all %} | |
31 | + <tr> | |
32 | + <td> <a href="{% url "detail_scientific_program" sp.pk %}">{{ sp }} </a></td> | |
33 | + </tr> | |
24 | 34 | {% endfor %} |
35 | + </tbody> | |
36 | + </table></p> | |
25 | 37 | {% if USER_LEVEL >= 5 %} |
26 | 38 | <a href="{% url "user-edit" user.pk %}" class="btn btn-info" role="button">Edit</a> |
27 | 39 | {% if not is_last_user or not user.is_superuser%} | ... | ... |
src/core/pyros_django/dashboard/templates/dashboard/users_management.html
1 | 1 | {% extends "base.html" %} |
2 | - | |
2 | +{% load tags %} | |
3 | 3 | {% block title %} |
4 | 4 | PYROS USERS MANAGEMENT |
5 | 5 | {% endblock %} |
... | ... | @@ -17,12 +17,37 @@ |
17 | 17 | <div id="div_users"class="row"> |
18 | 18 | <h3>Current list of Users </h3> |
19 | 19 | <div class="table-responsive"> |
20 | - <table | |
21 | - class="table table-bordered table-hover table-striped tablesorter" style="font-family: 'Montserra', sans-serif;"> | |
20 | + <table class="table table-bordered table-hover table-striped tablesorter" style="font-family: 'Montserra', sans-serif;"> | |
21 | + <thead> | |
22 | + <tr> | |
23 | + <th>Name <i class="fa fa-sort"></i></th> | |
24 | + <th colspan="{{ nb_of_scientific_program }}">Scientific program</th> | |
25 | + <th>Laboratory </th> | |
26 | + <th>Quota </th> | |
27 | + </tr> | |
28 | + </thead> | |
22 | 29 | <tbody> |
23 | 30 | {% for field in instance %} |
24 | 31 | <tr> |
25 | 32 | <td> <a href="{% url "user-detail" field.pk %}"> {{ field.username }} </a></td> |
33 | + | |
34 | + {% for sp in field.scientific_programs.all %} | |
35 | + | |
36 | + {% if forloop.last and forloop.counter < nb_of_scientific_program %} | |
37 | + {% comment "" %} | |
38 | + we need to fill the remaining colspan size | |
39 | + {% endcomment %} | |
40 | + <td colspan="{{ forloop.counter0 | add:negative_nb_scientific_program|abs}}"> | |
41 | + | |
42 | + {% else %} | |
43 | + <td> | |
44 | + {% endif %} | |
45 | + <a href="{% url "detail_scientific_program" sp.pk %}"> {{ sp }} </a> </td> | |
46 | + {% endfor %} | |
47 | + | |
48 | + </td> | |
49 | + <td> {{ field.laboratory }} </td> | |
50 | + <td> {{ field.quota}} </td> | |
26 | 51 | </tr> |
27 | 52 | {% endfor %} |
28 | 53 | </tbody> | ... | ... |
src/core/pyros_django/dashboard/templatetags/tags.py
... | ... | @@ -80,4 +80,8 @@ def get_level(name): |
80 | 80 | elif name == "USER_LEVEL_SYSADMIN": |
81 | 81 | return (7) |
82 | 82 | else : |
83 | - return (0) | |
84 | 83 | \ No newline at end of file |
84 | + return (0) | |
85 | + | |
86 | +@register.filter(name='abs') | |
87 | +def abs_filter(value): | |
88 | + return abs(value) | |
85 | 89 | \ No newline at end of file | ... | ... |
src/core/pyros_django/dashboard/views.py
... | ... | @@ -165,7 +165,9 @@ def retrieve_main_icon(request): |
165 | 165 | @level_required(6) |
166 | 166 | def users(request): |
167 | 167 | instance = PyrosUser.objects.order_by("-id") |
168 | - return render(request, 'dashboard/users_management.html', {'instance': instance}) # return the initial view (the users management's one) | |
168 | + nb_of_scientific_program = ScientificProgram.objects.count() | |
169 | + negative_nb_scientific_program = -nb_of_scientific_program | |
170 | + return render(request, 'dashboard/users_management.html', {'instance': instance,"nb_of_scientific_program": nb_of_scientific_program,"negative_nb_scientific_program":negative_nb_scientific_program}) # return the initial view (the users management's one) | |
169 | 171 | |
170 | 172 | @login_required |
171 | 173 | @level_required(2) | ... | ... |
src/core/pyros_django/scientific_program/templates/scientific_program/scientific_program_detail.html
... | ... | @@ -14,7 +14,7 @@ |
14 | 14 | </thead> |
15 | 15 | <tbody> |
16 | 16 | {% for user in scientific_program.pyros_users.all %} |
17 | - <tr><td>{{ user.username }}</td></tr> | |
17 | + <tr><td><a href=" {% url 'user-detail' user.pk %}" >{{ user.username }} </a> </td></tr> | |
18 | 18 | {% endfor %} |
19 | 19 | </tbody> |
20 | 20 | </table></p> | ... | ... |