diff --git a/logs/templates/logs/aff_stats_droits.html b/logs/templates/logs/aff_stats_droits.html deleted file mode 100644 index 6e424223..00000000 --- a/logs/templates/logs/aff_stats_droits.html +++ /dev/null @@ -1,86 +0,0 @@ -{% comment %} -Re2o est un logiciel d'administration développé initiallement au rezometz. Il -se veut agnostique au réseau considéré, de manière à être installable en -quelques clics. - -Copyright © 2017 Gabriel Détraz -Copyright © 2017 Goulven Kermarec -Copyright © 2017 Augustin Lemesle - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -{% endcomment %} - -{% load bootstrap3 %} -{% load acl %} - -{% for droit,users in stats_list.items %} -
-
-

- - {{droit}} - {{users.count}} -

-
-
-
-
- - - - - - - - - - - - {% for utilisateur in users %} - - - {% if utilisateur.is_adherent %} - - {% elif not utilisateur.end_adhesion %} - - {% else %} - - {% endif %} - - - {% if not utilisateur.last %} - - {% else %} - - {% endif %} - - - {% endfor %} -
PseudoAdhésionDerniere connexionNombre d'actionsDate de la dernière action
{{ utilisateur.pseudo }}

Adhérent

On ne s'en souvient plus...

Plus depuis {{ utilisateur.end_adhesion }}

{{ utilisateur.last_login }}{{ utilisateur.num }}

Jamais

{{utilisateur.last}}

- {% if droit != 'Superuser' %} - - {% else %} - - {% endif %} - - -
-
-
-
-
-{% endfor %} diff --git a/logs/templates/logs/sidebar.html b/logs/templates/logs/sidebar.html index 03a4bd73..0e3048e3 100644 --- a/logs/templates/logs/sidebar.html +++ b/logs/templates/logs/sidebar.html @@ -51,9 +51,5 @@ with this program; if not, write to the Free Software Foundation, Inc., Utilisateurs - - - Groupes de droit - {% acl_end %} {% endblock %} diff --git a/logs/templates/logs/stats_droits.html b/logs/templates/logs/stats_droits.html deleted file mode 100644 index 76c20331..00000000 --- a/logs/templates/logs/stats_droits.html +++ /dev/null @@ -1,36 +0,0 @@ -{% extends "logs/sidebar.html" %} -{% comment %} -Re2o est un logiciel d'administration développé initiallement au rezometz. Il -se veut agnostique au réseau considéré, de manière à être installable en -quelques clics. - -Copyright © 2017 Gabriel Détraz -Copyright © 2017 Goulven Kermarec -Copyright © 2017 Augustin Lemesle - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -{% endcomment %} - -{% load bootstrap3 %} - -{% block title %}Statistiques des droits{% endblock %} - -{% block content %} -

Statistiques des droits

- {% include "logs/aff_stats_droits.html" with stats_list=stats_list %} -
-
-
- {% endblock %} diff --git a/logs/urls.py b/logs/urls.py index 98dec281..11009835 100644 --- a/logs/urls.py +++ b/logs/urls.py @@ -39,5 +39,4 @@ urlpatterns = [ url(r'^stats_models/$', views.stats_models, name='stats-models'), url(r'^stats_users/$', views.stats_users, name='stats-users'), url(r'^stats_actions/$', views.stats_actions, name='stats-actions'), - url(r'^stats_droits/$', views.stats_droits, name='stats-droits'), ] diff --git a/logs/views.py b/logs/views.py index 1fdda9fb..cdbad9ac 100644 --- a/logs/views.py +++ b/logs/views.py @@ -453,27 +453,3 @@ def stats_actions(request): }, } return render(request, 'logs/stats_users.html', {'stats_list': stats}) - - -@login_required -@can_view_app('users') -def stats_droits(request): - """Affiche la liste des droits et les users ayant chaque droit""" - stats_list = {} - - for droit in ListRight.objects.all().select_related('group_ptr'): - stats_list[droit] = droit.user_set.all().annotate( - num=Count('revision'), - last=Max('revision__date_created'), - ) - - stats_list['Superuser'] = User.objects.filter(is_superuser=True).annotate( - num=Count('revision'), - last=Max('revision__date_created'), - ) - - return render( - request, - 'logs/stats_droits.html', - {'stats_list': stats_list} - ) diff --git a/re2o/context_processors.py b/re2o/context_processors.py index a2e205c2..ceb03be2 100644 --- a/re2o/context_processors.py +++ b/re2o/context_processors.py @@ -21,8 +21,10 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. """Fonction de context, variables renvoyées à toutes les vues""" - from __future__ import unicode_literals + +import datetime + from django.contrib import messages from preferences.models import GeneralOption, OptionalMachine @@ -47,3 +49,12 @@ def context_user(request): 'name_website': GeneralOption.get_cached_value('site_name'), 'ipv6_enabled': OptionalMachine.get_cached_value('ipv6'), } + + +def date_now(request): + """Add the current date in the context for quick informations and + comparisons""" + return { + 'now_aware': datetime.datetime.now(datetime.timezone.utc), + 'now_naive': datetime.datetime.now() + } diff --git a/re2o/settings.py b/re2o/settings.py index 1117dd77..71bd266f 100644 --- a/re2o/settings.py +++ b/re2o/settings.py @@ -125,6 +125,7 @@ TEMPLATES = [ 'django.contrib.messages.context_processors.messages', 'django.template.context_processors.request', 're2o.context_processors.context_user', + 're2o.context_processors.date_now', ], }, }, diff --git a/static/css/base.css b/static/css/base.css index f6240970..2b44e95c 100644 --- a/static/css/base.css +++ b/static/css/base.css @@ -108,3 +108,9 @@ footer a { overflow-y: visible; } +/* Make modal wider on wide screens */ +@media (min-width: 1024px) { + .modal-dialog { + width: 1000px + } +} diff --git a/users/locale/fr/LC_MESSAGES/django.mo b/users/locale/fr/LC_MESSAGES/django.mo new file mode 100644 index 00000000..9808ced6 Binary files /dev/null and b/users/locale/fr/LC_MESSAGES/django.mo differ diff --git a/users/locale/fr/LC_MESSAGES/django.po b/users/locale/fr/LC_MESSAGES/django.po new file mode 100644 index 00000000..2814cb83 --- /dev/null +++ b/users/locale/fr/LC_MESSAGES/django.po @@ -0,0 +1,123 @@ +# Re2o est un logiciel d'administration développé initiallement au rezometz. Il +# se veut agnostique au réseau considéré, de manière à être installable en +# quelques clics. +# +# Copyright © 2018 Maël Kervella +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +msgid "" +msgstr "" +"Project-Id-Version: 2.5\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-06-28 00:06+0200\n" +"PO-Revision-Date: 2018-06-27 23:35+0200\n" +"Last-Translator: Maël Kervella \n" +"Language-Team: \n" +"Language: fr_FR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#: templates/users/aff_listright.html:37 +msgid "Superuser" +msgstr "Superuser" + +#: templates/users/aff_listright.html:39 +msgid "Django's specific pre-defined right that supersed any other rights." +msgstr "" +"Droit prédéfini spécifique à Django qui outrepasse tous les autres droits." + +#: templates/users/aff_listright.html:43 +msgid "Total: All permissions" +msgstr "Total: Toutes les permissions" + +#: templates/users/aff_listright.html:55 +msgid "Users in Superuser" +msgstr "Utilisateurs dans Superuser" + +#: templates/users/aff_listright.html:62 templates/users/aff_listright.html:167 +msgid "Username" +msgstr "Pseudo" + +#: templates/users/aff_listright.html:63 templates/users/aff_listright.html:168 +msgid "Membership" +msgstr "Adhésion" + +#: templates/users/aff_listright.html:64 templates/users/aff_listright.html:169 +msgid "Last seen" +msgstr "Dernière connexion" + +#: templates/users/aff_listright.html:65 templates/users/aff_listright.html:170 +msgid "Actions" +msgstr "Actions" + +#: templates/users/aff_listright.html:66 templates/users/aff_listright.html:171 +msgid "Last action" +msgstr "Dernière action" + +#: templates/users/aff_listright.html:74 templates/users/aff_listright.html:179 +msgid "Member" +msgstr "Adhérent" + +#: templates/users/aff_listright.html:76 templates/users/aff_listright.html:181 +msgid "No membership records" +msgstr "Aucune adhésion" + +#: templates/users/aff_listright.html:79 templates/users/aff_listright.html:184 +#, python-format +msgid "Not since %(end_date)s" +msgstr "Plus depuis %(end_date)s" + +#: templates/users/aff_listright.html:87 templates/users/aff_listright.html:192 +msgid "Never" +msgstr "Jamais" + +#: templates/users/aff_listright.html:122 +#, python-format +msgid "%(right_name)s (gid: %(right_gid)s)" +msgstr "%(right_name)s (gid: %(right_gid)s)" + +#: templates/users/aff_listright.html:131 +#, python-format +msgid "Total: %(perm_count)s permission" +msgid_plural "Total: %(perm_count)s permissions" +msgstr[0] "Total: %(perm_count)s permission" +msgstr[1] "Total: %(perm_count)s permissions" + +#: templates/users/aff_listright.html:157 +#, python-format +msgid "Users in %(right_name)s" +msgstr "Utilisateurs dans %(right_name)s" + +#: widgets.py:35 +msgid "Close" +msgstr "" + +#: widgets.py:36 +msgid "Today" +msgstr "" + +#: widgets.py:44 +msgid "Next" +msgstr "" + +#: widgets.py:45 +msgid "Previous" +msgstr "" + +#: widgets.py:46 +msgid "Wk" +msgstr "" diff --git a/users/templates/users/aff_listright.html b/users/templates/users/aff_listright.html index 8906b38e..f4ed1e83 100644 --- a/users/templates/users/aff_listright.html +++ b/users/templates/users/aff_listright.html @@ -22,118 +22,189 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. {% endcomment %} - - - - - - - - - - - - {% if superuser_right %} - - - - - - - - - - - + + + + +{% endif %} - {% endif %} - {% for listright in listright_list %} - - - - - - - - - - - - {% endfor %} -
DroitGidGroupe/permission critiqueInformationsDetails
SuperuserTrue - - - Donne tous les droits sur Re2o. - -
-
-
-
-
    - {% for user in superuser_right %} -
  • - {{user}} - - - -
  • - {% endfor %} -
-
-
+ +
+
- {{ listright.name }} - {{ listright.gid }}{{ listright.critical }} - - {{ listright.details }} - {% include 'buttons/edit.html' with href='users:edit-listright' id=listright.id %} - {% include 'buttons/history.html' with href='users:history' name='listright' id=listright.id %} -
-
-
-
-
    - {% for perm in listright.permissions.all %} -
  • - {{perm.name}} -
  • - {% endfor %} -
-
-
-
-
-
    - {% for user in listright.user_set.all %} -
  • - {{user}} - - - -
  • - {% endfor %} -
-
-
+{% for right, users in rights.items %} +
+
+
+ {% if users %} + + {% else %} + + {% endif %} + {{users.count}} + + {% include 'buttons/edit.html' with href='users:edit-listright' id=right.id %} + {% include 'buttons/history.html' with href='users:history' name='listright' id=right.id %} +
+

+ + {% blocktrans trimmed with right.name as right_name and right.gid as right_gid %} + {{ right_name }} (gid: {{ right_gid }}) + {% endblocktrans %} +

+ {{ right.details }} +
+
+
+

+ {% blocktrans trimmed count right.permissions.count as perm_count%} + Total: {{ perm_count }} permission + {% plural %} + Total: {{ perm_count }} permissions + {% endblocktrans %} +

+
    + {% for perm in right.permissions.all %} +
  • + {{perm.name}} +
  • + {% endfor %} +
+
+
+
+ +{% if users %} +
- - + + + + +{% endif %} +{% endfor %} diff --git a/users/templates/users/index_listright.html b/users/templates/users/index_listright.html index 57165792..3b8b3e60 100644 --- a/users/templates/users/index_listright.html +++ b/users/templates/users/index_listright.html @@ -34,9 +34,8 @@ with this program; if not, write to the Free Software Foundation, Inc., Ajouter un droit ou groupe {% acl_end %} Supprimer un ou plusieurs droits/groupes - {% include "users/aff_listright.html" with listright_list=listright_list %} -


+ {% include "users/aff_listright.html" %} {% endblock %} diff --git a/users/views.py b/users/views.py index fcb44f65..4072e6a7 100644 --- a/users/views.py +++ b/users/views.py @@ -39,7 +39,7 @@ from django.urls import reverse from django.shortcuts import get_object_or_404, render, redirect from django.contrib import messages from django.contrib.auth.decorators import login_required, permission_required -from django.db.models import ProtectedError +from django.db.models import ProtectedError, Count, Max from django.utils import timezone from django.db import transaction from django.http import HttpResponse @@ -806,15 +806,30 @@ def index_shell(request): @can_view_all(ListRight) def index_listright(request): """ Affiche l'ensemble des droits""" - listright_list = ListRight.objects.order_by('unix_name')\ - .prefetch_related('permissions').prefetch_related('user_set') - superuser_right = User.objects.filter(is_superuser=True) + rights = {} + for right in (ListRight.objects + .order_by('name') + .prefetch_related('permissions') + .prefetch_related('user_set') + .prefetch_related('user_set__facture_set__vente_set__cotisation') + ): + rights[right] = (right.user_set + .annotate(action_number=Count('revision'), + last_seen=Max('revision__date_created'), + end_adhesion=Max('facture__vente__cotisation__date_end')) + ) + superusers = (User.objects + .filter(is_superuser=True) + .annotate(action_number=Count('revision'), + last_seen=Max('revision__date_created'), + end_adhesion=Max('facture__vente__cotisation__date_end')) + ) return render( request, 'users/index_listright.html', { - 'listright_list': listright_list, - 'superuser_right' : superuser_right, + 'rights': rights, + 'superusers' : superusers, } )