From 6b945bf3229f02cfdd4bab0872b26ca6b0207df1 Mon Sep 17 00:00:00 2001 From: Hugo LEVY-FALK Date: Thu, 19 Jul 2018 12:30:15 +0200 Subject: [PATCH 1/4] fix #65, gestion propre de l'historique. --- .../templates/cotisations/aff_article.html | 9 +- .../templates/cotisations/aff_banque.html | 11 +- .../cotisations/aff_cotisations.html | 5 +- .../templates/cotisations/aff_paiement.html | 5 +- cotisations/urls.py | 7 - logs/templatetags/logs_extra.py | 12 + logs/urls.py | 5 + logs/views.py | 68 +++- machines/templates/machines/aff_alias.html | 35 +- .../templates/machines/aff_extension.html | 23 +- machines/templates/machines/aff_iptype.html | 19 +- machines/templates/machines/aff_ipv6.html | 45 +-- machines/templates/machines/aff_machines.html | 305 ++++++++-------- .../templates/machines/aff_machinetype.html | 39 +- machines/templates/machines/aff_mx.html | 43 +-- machines/templates/machines/aff_nas.html | 51 +-- machines/templates/machines/aff_ns.html | 39 +- machines/templates/machines/aff_servers.html | 40 +-- machines/templates/machines/aff_service.html | 49 +-- machines/templates/machines/aff_soa.html | 55 +-- machines/templates/machines/aff_srv.html | 65 ++-- machines/templates/machines/aff_txt.html | 39 +- machines/templates/machines/aff_vlan.html | 15 +- machines/urls.py | 5 - .../templates/preferences/aff_service.html | 3 +- preferences/urls.py | 7 - re2o/views.py | 133 +------ templates/buttons/history.html | 5 +- topologie/templates/topologie/aff_ap.html | 83 +++-- .../templates/topologie/aff_building.html | 25 +- .../templates/topologie/aff_chambres.html | 27 +- .../topologie/aff_constructor_switch.html | 25 +- .../templates/topologie/aff_model_switch.html | 31 +- topologie/templates/topologie/aff_port.html | 117 +++--- .../templates/topologie/aff_repr_switch.html | 148 ++++---- topologie/templates/topologie/aff_stacks.html | 45 ++- topologie/templates/topologie/aff_switch.html | 95 ++--- .../templates/topologie/aff_switch_bay.html | 39 +- .../templates/topologie/edit_stack_sw.html | 41 ++- topologie/urls.py | 5 - users/templates/users/aff_bans.html | 43 +-- users/templates/users/aff_clubs.html | 58 +-- users/templates/users/aff_listright.html | 47 +-- users/templates/users/aff_rights.html | 26 +- users/templates/users/aff_schools.html | 17 +- users/templates/users/aff_serviceusers.html | 49 +-- users/templates/users/aff_shell.html | 41 +-- users/templates/users/aff_users.html | 12 +- users/templates/users/aff_whitelists.html | 41 +-- users/templates/users/profil.html | 340 +++++++++--------- users/urls.py | 5 - 51 files changed, 1218 insertions(+), 1279 deletions(-) diff --git a/cotisations/templates/cotisations/aff_article.html b/cotisations/templates/cotisations/aff_article.html index ad044f55..3ed4568c 100644 --- a/cotisations/templates/cotisations/aff_article.html +++ b/cotisations/templates/cotisations/aff_article.html @@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% load acl %} {% load i18n %} +{% load logs_extra %} @@ -46,14 +47,12 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endfor %} diff --git a/cotisations/templates/cotisations/aff_banque.html b/cotisations/templates/cotisations/aff_banque.html index d9ec8d1c..b5074c6c 100644 --- a/cotisations/templates/cotisations/aff_banque.html +++ b/cotisations/templates/cotisations/aff_banque.html @@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% load acl %} {% load i18n %} +{% load logs_extra %}
{{ article.type_user }} {{ article.available_for_everyone }} - {% can_edit article %} + {% can_edit article %} - {% acl_end %} - - - + {% acl_end %} + {% history_button article %}
@@ -36,14 +37,12 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endfor %} diff --git a/cotisations/templates/cotisations/aff_cotisations.html b/cotisations/templates/cotisations/aff_cotisations.html index fdb575ed..27ced69e 100644 --- a/cotisations/templates/cotisations/aff_cotisations.html +++ b/cotisations/templates/cotisations/aff_cotisations.html @@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% load acl %} {% load i18n %} +{% load logs_extra %}
{% if facture_list.paginator %} @@ -86,9 +87,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% acl_end %}
  • - - {% trans "Historique" %} - + {% history_button facture text='History' html_class=''%}
  • diff --git a/cotisations/templates/cotisations/aff_paiement.html b/cotisations/templates/cotisations/aff_paiement.html index e42d512f..c07b7e3b 100644 --- a/cotisations/templates/cotisations/aff_paiement.html +++ b/cotisations/templates/cotisations/aff_paiement.html @@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% load acl %} {% load i18n %} +{% load logs_extra %}
    {{ banque.name }} - {% can_edit banque %} - + {% can_edit banque %} + - {% acl_end %} - - - + {% acl_end %} + {% history_button banque %}
    @@ -47,9 +48,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% acl_end %} - - - + {% history_button paiement %} {% endfor %} diff --git a/cotisations/urls.py b/cotisations/urls.py index c906c54a..470ccbfa 100644 --- a/cotisations/urls.py +++ b/cotisations/urls.py @@ -27,7 +27,6 @@ from __future__ import unicode_literals from django.conf.urls import url -import re2o from . import views from . import payment_methods @@ -122,12 +121,6 @@ urlpatterns = [ views.index_paiement, name='index-paiement' ), - url( - r'history/(?P\w+)/(?P[0-9]+)$', - re2o.views.history, - name='history', - kwargs={'application': 'cotisations'}, - ), url( r'^control/$', views.control, diff --git a/logs/templatetags/logs_extra.py b/logs/templatetags/logs_extra.py index 97f60ec8..48573003 100644 --- a/logs/templatetags/logs_extra.py +++ b/logs/templatetags/logs_extra.py @@ -33,3 +33,15 @@ register = template.Library() def classname(obj): """ Returns the object class name """ return obj.__class__.__name__ + + +@register.inclusion_tag('buttons/history.html') +def history_button(instance, text=None, html_class=None): + """Creates the correct history button for an instance.""" + return { + 'application': instance._meta.app_label, + 'name': instance._meta.model_name, + 'id': instance.id, + 'text': text, + 'class': html_class, + } diff --git a/logs/urls.py b/logs/urls.py index 11009835..9398cfe4 100644 --- a/logs/urls.py +++ b/logs/urls.py @@ -39,4 +39,9 @@ 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'(?P\w+)/(?P\w+)/(?P[0-9]+)$', + views.history, + name='history', + ), ] diff --git a/logs/views.py b/logs/views.py index cdbad9ac..0b785f08 100644 --- a/logs/views.py +++ b/logs/views.py @@ -2,9 +2,10 @@ # 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 +# Copyright © 2018 Gabriel Détraz +# Copyright © 2018 Goulven Kermarec +# Copyright © 2018 Augustin Lemesle +# Copyright © 2018 Hugo Levy-Falk # # 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 @@ -36,12 +37,15 @@ nombre d'objets par models, nombre d'actions par user, etc """ from __future__ import unicode_literals +from itertools import chain from django.urls import reverse from django.shortcuts import render, redirect from django.contrib import messages from django.contrib.auth.decorators import login_required +from django.http import Http404 from django.db.models import Count, Max, F +from django.apps import apps from reversion.models import Revision from reversion.models import Version, ContentType @@ -453,3 +457,61 @@ def stats_actions(request): }, } return render(request, 'logs/stats_users.html', {'stats_list': stats}) + + +def history(request, application, object_name, object_id): + """Render history for a model. + + The model is determined using the `HISTORY_BIND` dictionnary if none is + found, raises a Http404. The view checks if the user is allowed to see the + history using the `can_view` method of the model. + + Args: + request: The request sent by the user. + application: Name of the application. + object_name: Name of the model. + object_id: Id of the object you want to acces history. + + Returns: + The rendered page of history if access is granted, else the user is + redirected to their profile page, with an error message. + + Raises: + Http404: This kind of models doesn't have history. + """ + try: + model = apps.get_model(application, object_name) + except LookupError: + raise Http404(u"Il n'existe pas d'historique pour ce modèle.") + object_name_id = object_name + 'id' + kwargs = {object_name_id: object_id} + try: + instance = model.get_instance(**kwargs) + except model.DoesNotExist: + messages.error(request, u"Entrée inexistante") + return redirect(reverse( + 'users:profil', + kwargs={'userid': str(request.user.id)} + )) + can, msg = instance.can_view(request.user) + if not can: + messages.error(request, msg or "Vous ne pouvez pas accéder à ce menu") + return redirect(reverse( + 'users:profil', + kwargs={'userid': str(request.user.id)} + )) + pagination_number = GeneralOption.get_cached_value('pagination_number') + reversions = Version.objects.get_for_object(instance) + if hasattr(instance, 'linked_objects'): + for related_object in chain(instance.linked_objects()): + reversions = (reversions | + Version.objects.get_for_object(related_object)) + reversions = re2o_paginator(request, reversions, pagination_number) + return render( + request, + 're2o/history.html', + {'reversions': reversions, 'object': instance} + ) + + + diff --git a/machines/templates/machines/aff_alias.html b/machines/templates/machines/aff_alias.html index f19b6482..184db6f4 100644 --- a/machines/templates/machines/aff_alias.html +++ b/machines/templates/machines/aff_alias.html @@ -23,24 +23,25 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load acl %} +{% load logs_extra %} -
    - - - - - - - {% for alias in alias_list %} +
    Alias
    + - - + + - {% endfor %} -
    {{ alias }} - {% can_edit alias %} - {% include 'buttons/edit.html' with href='machines:edit-alias' id=alias.id %} - {% acl_end %} - {% include 'buttons/history.html' with href='machines:history' name='domain' id=alias.id %} - Alias
    + + {% for alias in alias_list %} + + {{ alias }} + + {% can_edit alias %} + {% include 'buttons/edit.html' with href='machines:edit-alias' id=alias.id %} + {% acl_end %} + {% history_button alias %} + + + {% endfor %} + diff --git a/machines/templates/machines/aff_extension.html b/machines/templates/machines/aff_extension.html index 44061b1b..0692a039 100644 --- a/machines/templates/machines/aff_extension.html +++ b/machines/templates/machines/aff_extension.html @@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load acl %} +{% load logs_extra %}
    @@ -30,28 +31,28 @@ with this program; if not, write to the Free Software Foundation, Inc., - - - {% if ipv6_enabled %} - - {% endif %} - + + + {% if ipv6_enabled %} + + {% endif %} + {% for extension in extension_list %} - + - + {% if ipv6_enabled %} {% endif %} {% endfor %} diff --git a/machines/templates/machines/aff_iptype.html b/machines/templates/machines/aff_iptype.html index 1a76e303..acf8260c 100644 --- a/machines/templates/machines/aff_iptype.html +++ b/machines/templates/machines/aff_iptype.html @@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load acl %} +{% load logs_extra %}
    Extension Droit infra pour utiliser ?Enregistrement SOAEnregistrement A originEnregistrement AAAA originEnregistrement SOAEnregistrement A originEnregistrement AAAA origin
    {{ extension.name }} {{ extension.need_infra }} {{ extension.soa}}{{ extension.origin }}{{ extension.origin }}{{ extension.origin_v6 }} - {% can_edit extension %} + {% can_edit extension %} {% include 'buttons/edit.html' with href='machines:edit-extension' id=extension.id %} - {% acl_end %} - {% include 'buttons/history.html' with href='machines:history' name='extension' id=extension.id %} + {% acl_end %} + {% history_button extension %}
    @@ -31,10 +32,10 @@ with this program; if not, write to the Free Software Foundation, Inc., - + - - + + @@ -43,15 +44,15 @@ with this program; if not, write to the Free Software Foundation, Inc., - - + + - + {% endfor %} diff --git a/machines/templates/machines/aff_ipv6.html b/machines/templates/machines/aff_ipv6.html index b6efa3f0..d5323f61 100644 --- a/machines/templates/machines/aff_ipv6.html +++ b/machines/templates/machines/aff_ipv6.html @@ -23,29 +23,30 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load acl %} +{% load logs_extra %} -
    Extension Nécessite l'autorisation infra Plage ipv4Préfixe v6Préfixe v6 Sur vlanOuverture ports par défaultOuverture ports par défault
    {{ type.type }} {{ type.extension }} {{ type.need_infra }}{{ type.domaine_ip_start }}-{{ type.domaine_ip_stop }}{{ type.prefix_v6 }}{{ type.domaine_ip_start }}-{{ type.domaine_ip_stop }}{{ type.prefix_v6 }} {{ type.vlan }}{{ type.ouverture_ports }}{{ type.ouverture_ports }} - {% can_edit type %} + {% can_edit type %} {% include 'buttons/edit.html' with href='machines:edit-iptype' id=type.id %} - {% acl_end %} - {% include 'buttons/history.html' with href='machines:history' name='iptype' id=type.id %} + {% acl_end %} + {% history_button type %}
    - - - - - - - - {% for ipv6 in ipv6_list %} +
    Ipv6Slaac
    + - - - + + + - {% endfor %} -
    {{ ipv6.ipv6 }}{{ ipv6.slaac_ip }} - {% can_edit ipv6 %} - {% include 'buttons/edit.html' with href='machines:edit-ipv6list' id=ipv6.id %} - {% acl_end %} - {% can_delete ipv6 %} - {% include 'buttons/suppr.html' with href='machines:del-ipv6list' id=ipv6.id %} - {% acl_end %} - {% include 'buttons/history.html' with href='machines:history' name='ipv6list' id=ipv6.id %} - Ipv6Slaac
    + + {% for ipv6 in ipv6_list %} + + {{ ipv6.ipv6 }} + {{ ipv6.slaac_ip }} + + {% can_edit ipv6 %} + {% include 'buttons/edit.html' with href='machines:edit-ipv6list' id=ipv6.id %} + {% acl_end %} + {% can_delete ipv6 %} + {% include 'buttons/suppr.html' with href='machines:del-ipv6list' id=ipv6.id %} + {% acl_end %} + {% history_button ipv6 %} + + + {% endfor %} + diff --git a/machines/templates/machines/aff_machines.html b/machines/templates/machines/aff_machines.html index 0020d8b3..0acababc 100644 --- a/machines/templates/machines/aff_machines.html +++ b/machines/templates/machines/aff_machines.html @@ -22,165 +22,166 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. {% endcomment %} -{% load acl %} +{% load acl %} +{% load logs_extra %}
    -{% if machines_list.paginator %} -{% include "pagination.html" with list=machines_list %} -{% endif %} + {% if machines_list.paginator %} + {% include "pagination.html" with list=machines_list %} + {% endif %} - - - - - - - - - - - - - - - - {% for machine in machines_list %} - - - - - {% for interface in machine.interface_set.all %} - - - - - - + + + {% endif %} + {% endfor %} + + + + {% endfor %} + +
    {% include "buttons/sort.html" with prefix='machine' col='name' text='Nom DNS' %}TypeMACIPActions
    - {{ machine.name|default:'Pas de nom' }} - - {{ machine.user }} - - - {% can_create Interface machine.id %} - {% include 'buttons/add.html' with href='machines:new-interface' id=machine.id desc='Ajouter une interface' %} - {% acl_end %} - {% include 'buttons/history.html' with href='machines:history' name='machine' id=machine.id %} - {% can_delete machine %} - {% include 'buttons/suppr.html' with href='machines:del-machine' id=machine.id %} - {% acl_end %} -
    - {% if interface.domain.related_domain.all %} - {{ interface.domain }} - - {% else %} - {{ interface.domain }} - {% endif %} - - {{ interface.type }} - - {{ interface.mac_address }} - - IPv4 {{ interface.ipv4 }} -
    - {% if ipv6_enabled and interface.ipv6 != 'None'%} - IPv6 - - {% endif %} -
    -
    -
    -
    +
    +
      + {% for al in interface.domain.related_domain.all %} +
    • + + {{ al }} + + +
    • + {% endfor %} +
    +
    +
    - + -{% if machines_list.paginator %} -{% include "pagination.html" with list=machines_list %} -{% endif %} + {% if machines_list.paginator %} + {% include "pagination.html" with list=machines_list %} + {% endif %}
    diff --git a/machines/templates/machines/aff_machinetype.html b/machines/templates/machines/aff_machinetype.html index facad203..f6c99e49 100644 --- a/machines/templates/machines/aff_machinetype.html +++ b/machines/templates/machines/aff_machinetype.html @@ -23,26 +23,27 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load acl %} +{% load logs_extra %} - - - - - - - - - {% for type in machinetype_list %} +
    Type de machineType d'ip correspondant
    + - - - + + + - {% endfor %} -
    {{ type.type }}{{ type.ip_type }} - {% can_edit type %} - {% include 'buttons/edit.html' with href='machines:edit-machinetype' id=type.id %} - {% acl_end %} - {% include 'buttons/history.html' with href='machines:history' name='machinetype' id=type.id %} - Type de machineType d'ip correspondant
    + + {% for type in machinetype_list %} + + {{ type.type }} + {{ type.ip_type }} + + {% can_edit type %} + {% include 'buttons/edit.html' with href='machines:edit-machinetype' id=type.id %} + {% acl_end %} + {% history_button type %} + + + {% endfor %} + diff --git a/machines/templates/machines/aff_mx.html b/machines/templates/machines/aff_mx.html index 4478cdab..1a4dac40 100644 --- a/machines/templates/machines/aff_mx.html +++ b/machines/templates/machines/aff_mx.html @@ -23,30 +23,31 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load acl %} +{% load logs_extra %} - - - - - - - - - - - {% for mx in mx_list %} +
    Zone concernéePrioritéEnregistrement
    + - - - - + + + + + + + {% for mx in mx_list %} + + + + + - - {% endfor %} -
    {{ mx.zone }}{{ mx.priority }}{{ mx.name }} + Zone concernéePrioritéEnregistrement
    {{ mx.zone }}{{ mx.priority }}{{ mx.name }} {% can_edit mx %} {% include 'buttons/edit.html' with href='machines:edit-mx' id=mx.id %} - {% acl_end %} - {% include 'buttons/history.html' with href='machines:history' name='mx' id=mx.id %} -
    + {% acl_end %} + {% history_button mx %} + + + {% endfor %} + diff --git a/machines/templates/machines/aff_nas.html b/machines/templates/machines/aff_nas.html index 735a4ca8..2c2cfd21 100644 --- a/machines/templates/machines/aff_nas.html +++ b/machines/templates/machines/aff_nas.html @@ -23,32 +23,33 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load acl %} +{% load logs_extra %} - - - - - - - - - - - - {% for nas in nas_list %} +
    NomType du nasType de machine reliées au nasMode d'accèsAutocapture mac
    + - - - - - - + + + + + + - {% endfor %} -
    {{ nas.name }}{{ nas.nas_type }}{{ nas.machine_type }}{{ nas.port_access_mode }}{{ nas.autocapture_mac }} - {% can_edit nas %} - {% include 'buttons/edit.html' with href='machines:edit-nas' id=nas.id %} - {% acl_end %} - {% include 'buttons/history.html' with href='machines:history' name='nas' id=nas.id %} - NomType du nasType de machine reliées au nasMode d'accèsAutocapture mac
    + + {% for nas in nas_list %} + + {{ nas.name }} + {{ nas.nas_type }} + {{ nas.machine_type }} + {{ nas.port_access_mode }} + {{ nas.autocapture_mac }} + + {% can_edit nas %} + {% include 'buttons/edit.html' with href='machines:edit-nas' id=nas.id %} + {% acl_end %} + {% history_button nas %} + + + {% endfor %} + diff --git a/machines/templates/machines/aff_ns.html b/machines/templates/machines/aff_ns.html index 5ee87304..73423047 100644 --- a/machines/templates/machines/aff_ns.html +++ b/machines/templates/machines/aff_ns.html @@ -23,28 +23,29 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load acl %} +{% load logs_extra %} - - - - - - - - - - {% for ns in ns_list %} +
    Zone concernéeInterface autoritaire de la zone
    + - - - + + + + + + {% for ns in ns_list %} + + + + - - {% endfor %} -
    {{ ns.zone }}{{ ns.ns }} + Zone concernéeInterface autoritaire de la zone
    {{ ns.zone }}{{ ns.ns }} {% can_edit ns %} {% include 'buttons/edit.html' with href='machines:edit-ns' id=ns.id %} - {% acl_end %} - {% include 'buttons/history.html' with href='machines:history' name='ns' id=ns.id %} -
    + {% acl_end %} + {% history_button ns %} + + + {% endfor %} + diff --git a/machines/templates/machines/aff_servers.html b/machines/templates/machines/aff_servers.html index f29b620f..030afcea 100644 --- a/machines/templates/machines/aff_servers.html +++ b/machines/templates/machines/aff_servers.html @@ -22,26 +22,26 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. {% endcomment %} - - - - - - - - - - - {% for server in servers_list %} +
    Nom du serviceServeurDernière régénérationRégénération nécessaireRégénération activée
    + - - - - - - + + + + + - {% endfor %} -
    {{ server.service }}{{ server.server }}{{ server.last_regen }}{{ server.asked_regen }}{{ server.need_regen }} - Nom du serviceServeurDernière régénérationRégénération nécessaireRégénération activée
    + + {% for server in servers_list %} + + {{ server.service }} + {{ server.server }} + {{ server.last_regen }} + {{ server.asked_regen }} + {{ server.need_regen }} + + + + {% endfor %} + diff --git a/machines/templates/machines/aff_service.html b/machines/templates/machines/aff_service.html index da80b4da..6ca6278b 100644 --- a/machines/templates/machines/aff_service.html +++ b/machines/templates/machines/aff_service.html @@ -23,31 +23,32 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load acl %} +{% load logs_extra %} - - - - - - - - - - - - {% for service in service_list %} +
    Nom du serviceTemps minimum avant nouvelle régénérationTemps avant nouvelle génération obligatoire (max)Serveurs inclus
    + - - - - - + + + + + + - {% endfor %} -
    {{ service.service_type }}{{ service.min_time_regen }}{{ service.regular_time_regen }}{% for serv in service.servers.all %}{{ serv }}, {% endfor %} - {% can_edit service %} - {% include 'buttons/edit.html' with href='machines:edit-service' id=service.id %} - {% acl_end %} - {% include 'buttons/history.html' with href='machines:history' name='service' id=service.id %} - Nom du serviceTemps minimum avant nouvelle régénérationTemps avant nouvelle génération obligatoire (max)Serveurs inclus
    + + {% for service in service_list %} + + {{ service.service_type }} + {{ service.min_time_regen }} + {{ service.regular_time_regen }} + {% for serv in service.servers.all %}{{ serv }}, {% endfor %} + + {% can_edit service %} + {% include 'buttons/edit.html' with href='machines:edit-service' id=service.id %} + {% acl_end %} + {% history_button service %} + + + {% endfor %} + diff --git a/machines/templates/machines/aff_soa.html b/machines/templates/machines/aff_soa.html index 5352a739..e41e38fa 100644 --- a/machines/templates/machines/aff_soa.html +++ b/machines/templates/machines/aff_soa.html @@ -23,36 +23,37 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load acl %} +{% load logs_extra %} - - - - - - - - - - - - - - {% for soa in soa_list %} +
    NomMailRefreshRetryExpireTTL
    + - - - - - - - + + + + + + + + + + {% for soa in soa_list %} + + + + + + + + - - {% endfor %} -
    {{ soa.name }}{{ soa.mail }}{{ soa.refresh }}{{ soa.retry }}{{ soa.expire }}{{ soa.ttl }} + NomMailRefreshRetryExpireTTL
    {{ soa.name }}{{ soa.mail }}{{ soa.refresh }}{{ soa.retry }}{{ soa.expire }}{{ soa.ttl }} {% can_edit soa %} {% include 'buttons/edit.html' with href='machines:edit-soa' id=soa.id %} - {% acl_end %} - {% include 'buttons/history.html' with href='machines:history' name='soa' id=soa.id %} -
    + {% acl_end %} + {% history_button soa %} + + + {% endfor %} + diff --git a/machines/templates/machines/aff_srv.html b/machines/templates/machines/aff_srv.html index e7886cf1..4c502dad 100644 --- a/machines/templates/machines/aff_srv.html +++ b/machines/templates/machines/aff_srv.html @@ -23,40 +23,41 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load acl %} +{% load logs_extra %} - - - - - - - - - - - - - - - - {% for srv in srv_list %} +
    ServiceProtocoleExtensionTTLPrioritéPoidsPortCible
    + - - - - - - - - - + + + + + + + + + + - {% endfor %} -
    {{ srv.service }}{{ srv.protocole }}{{ srv.extension }}{{ srv.ttl }}{{ srv.priority }}{{ srv.weight }}{{ srv.port }}{{ srv.target }} - {% can_edit srv %} - {% include 'buttons/edit.html' with href='machines:edit-srv' id=srv.id %} - {% acl_end %} - {% include 'buttons/history.html' with href='machines:history' name='srv' id=srv.id %} - ServiceProtocoleExtensionTTLPrioritéPoidsPortCible
    + + {% for srv in srv_list %} + + {{ srv.service }} + {{ srv.protocole }} + {{ srv.extension }} + {{ srv.ttl }} + {{ srv.priority }} + {{ srv.weight }} + {{ srv.port }} + {{ srv.target }} + + {% can_edit srv %} + {% include 'buttons/edit.html' with href='machines:edit-srv' id=srv.id %} + {% acl_end %} + {% history_button srv %} + + + {% endfor %} + diff --git a/machines/templates/machines/aff_txt.html b/machines/templates/machines/aff_txt.html index 973fd6d9..27d78d11 100644 --- a/machines/templates/machines/aff_txt.html +++ b/machines/templates/machines/aff_txt.html @@ -23,28 +23,29 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load acl %} +{% load logs_extra %} - - - - - - - - - - {% for txt in txt_list %} +
    Zone concernéeEnregistrement
    + - - - + + + + + + {% for txt in txt_list %} + + + + - - {% endfor %} -
    {{ txt.zone }}{{ txt.dns_entry }} + Zone concernéeEnregistrement
    {{ txt.zone }}{{ txt.dns_entry }} {% can_edit txt %} {% include 'buttons/edit.html' with href='machines:edit-txt' id=txt.id %} - {% acl_end %} - {% include 'buttons/history.html' with href='machines:history' name='txt' id=txt.id %} -
    + {% acl_end %} + {% history_button txt %} + + + {% endfor %} + diff --git a/machines/templates/machines/aff_vlan.html b/machines/templates/machines/aff_vlan.html index de49c7a6..cbc57133 100644 --- a/machines/templates/machines/aff_vlan.html +++ b/machines/templates/machines/aff_vlan.html @@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load acl %} +{% load logs_extra %}
    @@ -30,22 +31,22 @@ with this program; if not, write to the Free Software Foundation, Inc., - + - + {% for vlan in vlan_list %} - + - {% endfor %} diff --git a/machines/urls.py b/machines/urls.py index 9a5fa25e..670c3ce6 100644 --- a/machines/urls.py +++ b/machines/urls.py @@ -27,7 +27,6 @@ The defined URLs for the Cotisations app from __future__ import unicode_literals from django.conf.urls import url -import re2o from . import views urlpatterns = [ @@ -119,10 +118,6 @@ urlpatterns = [ url(r'^edit_nas/(?P[0-9]+)$', views.edit_nas, name='edit-nas'), url(r'^del_nas/$', views.del_nas, name='del-nas'), url(r'^index_nas/$', views.index_nas, name='index-nas'), - url(r'history/(?P\w+)/(?P[0-9]+)$', - re2o.views.history, - name='history', - kwargs={'application': 'machines'}), url(r'^$', views.index, name='index'), url(r'^rest/mac-ip/$', views.mac_ip, name='mac-ip'), url(r'^rest/regen-achieved/$', diff --git a/preferences/templates/preferences/aff_service.html b/preferences/templates/preferences/aff_service.html index b4d4894c..89cfc641 100644 --- a/preferences/templates/preferences/aff_service.html +++ b/preferences/templates/preferences/aff_service.html @@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. {% endcomment %} {% load acl %} +{% load logs_extra %}
    Id NomCommentaireCommentaire Ranges ip
    {{ vlan.vlan_id }} {{ vlan.name }}{{ vlan.comment }}{{ vlan.comment }} {% for range in vlan.iptype_set.all %}{{ range }}, {% endfor%} - {% can_edit vlan %} + + {% can_edit vlan %} {% include 'buttons/edit.html' with href='machines:edit-vlan' id=vlan.id %} - {% acl_end %} - {% include 'buttons/history.html' with href='machines:history' name='vlan' id=vlan.id %} + {% acl_end %} + {% history_button vlan %}
    @@ -43,7 +44,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% can_edit service%} {% include 'buttons/edit.html' with href='preferences:edit-service' id=service.id %} {% acl_end %} - {% include 'buttons/history.html' with href='preferences:history' name='service' id=service.id %} + {% history_button service %} {% endfor %} diff --git a/preferences/urls.py b/preferences/urls.py index bca7bb1e..ec35cc41 100644 --- a/preferences/urls.py +++ b/preferences/urls.py @@ -27,7 +27,6 @@ from __future__ import unicode_literals from django.conf.urls import url -import re2o from . import views @@ -74,11 +73,5 @@ urlpatterns = [ name='edit-service' ), url(r'^del_services/$', views.del_services, name='del-services'), - url( - r'^history/(?P\w+)/(?P[0-9]+)$', - re2o.views.history, - name='history', - kwargs={'application': 'preferences'}, - ), url(r'^$', views.display_options, name='display-options'), ] diff --git a/re2o/views.py b/re2o/views.py index 3c5cde09..c4159215 100644 --- a/re2o/views.py +++ b/re2o/views.py @@ -26,33 +26,20 @@ les views from __future__ import unicode_literals -from itertools import chain import git -from reversion.models import Version -from django.http import Http404 -from django.urls import reverse -from django.shortcuts import render, redirect +from django.shortcuts import render from django.template.context_processors import csrf -from django.contrib.auth.decorators import login_required -from django.contrib import messages from django.conf import settings from django.utils.translation import ugettext as _ from django.views.decorators.cache import cache_page -import preferences from preferences.models import ( Service, - GeneralOption, AssoOption, HomeOption ) -import users -import cotisations -import topologie -import machines -from .utils import re2o_paginator from .contributors import CONTRIBUTORS @@ -73,118 +60,12 @@ def index(request): twitter_account_name = HomeOption.get_cached_value('twitter_account_name') asso_name = AssoOption.get_cached_value('pseudo') return form({ - 'services_urls': services, - 'twitter_url': twitter_url, - 'twitter_account_name' : twitter_account_name, - 'facebook_url': facebook_url, - 'asso_name': asso_name - }, 're2o/index.html', request) - - -#: Binding the corresponding char sequence of history url to re2o models. -HISTORY_BIND = { - 'users': { - 'user': users.models.User, - 'ban': users.models.Ban, - 'whitelist': users.models.Whitelist, - 'school': users.models.School, - 'listright': users.models.ListRight, - 'serviceuser': users.models.ServiceUser, - 'listshell': users.models.ListShell, - }, - 'preferences': { - 'service': preferences.models.Service, - }, - 'cotisations': { - 'facture': cotisations.models.Facture, - 'article': cotisations.models.Article, - 'paiement': cotisations.models.Paiement, - 'banque': cotisations.models.Banque, - }, - 'topologie': { - 'switch': topologie.models.Switch, - 'port': topologie.models.Port, - 'room': topologie.models.Room, - 'stack': topologie.models.Stack, - 'modelswitch': topologie.models.ModelSwitch, - 'constructorswitch': topologie.models.ConstructorSwitch, - 'accesspoint': topologie.models.AccessPoint, - 'switchbay': topologie.models.SwitchBay, - 'building': topologie.models.Building, - }, - 'machines': { - 'machine': machines.models.Machine, - 'interface': machines.models.Interface, - 'domain': machines.models.Domain, - 'machinetype': machines.models.MachineType, - 'iptype': machines.models.IpType, - 'extension': machines.models.Extension, - 'soa': machines.models.SOA, - 'mx': machines.models.Mx, - 'txt': machines.models.Txt, - 'srv': machines.models.Srv, - 'ns': machines.models.Ns, - 'service': machines.models.Service, - 'vlan': machines.models.Vlan, - 'nas': machines.models.Nas, - 'ipv6list': machines.models.Ipv6List, - }, -} - - -@login_required -def history(request, application, object_name, object_id): - """Render history for a model. - - The model is determined using the `HISTORY_BIND` dictionnary if none is - found, raises a Http404. The view checks if the user is allowed to see the - history using the `can_view` method of the model. - - Args: - request: The request sent by the user. - object_name: Name of the model. - object_id: Id of the object you want to acces history. - - Returns: - The rendered page of history if access is granted, else the user is - redirected to their profile page, with an error message. - - Raises: - Http404: This kind of models doesn't have history. - """ - try: - model = HISTORY_BIND[application][object_name] - except KeyError: - raise Http404(u"Il n'existe pas d'historique pour ce modèle.") - object_name_id = object_name + 'id' - kwargs = {object_name_id: object_id} - try: - instance = model.get_instance(**kwargs) - except model.DoesNotExist: - messages.error(request, u"Entrée inexistante") - return redirect(reverse( - 'users:profil', - kwargs={'userid': str(request.user.id)} - )) - can, msg = instance.can_view(request.user) - if not can: - messages.error(request, msg or "Vous ne pouvez pas accéder à ce menu") - return redirect(reverse( - 'users:profil', - kwargs={'userid': str(request.user.id)} - )) - pagination_number = GeneralOption.get_cached_value('pagination_number') - reversions = Version.objects.get_for_object(instance) - if hasattr(instance, 'linked_objects'): - for related_object in chain(instance.linked_objects()): - reversions = (reversions | - Version.objects.get_for_object(related_object)) - reversions = re2o_paginator(request, reversions, pagination_number) - return render( - request, - 're2o/history.html', - {'reversions': reversions, 'object': instance} - ) + 'services_urls': services, + 'twitter_url': twitter_url, + 'twitter_account_name': twitter_account_name, + 'facebook_url': facebook_url, + 'asso_name': asso_name + }, 're2o/index.html', request) @cache_page(7 * 24 * 60 * 60) diff --git a/templates/buttons/history.html b/templates/buttons/history.html index 4b6bcc86..e22c719b 100644 --- a/templates/buttons/history.html +++ b/templates/buttons/history.html @@ -21,7 +21,8 @@ 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 i18n %} + + {% if text %}{% trans text %}{% endif %} diff --git a/topologie/templates/topologie/aff_ap.html b/topologie/templates/topologie/aff_ap.html index fc38b4b1..18a419d3 100644 --- a/topologie/templates/topologie/aff_ap.html +++ b/topologie/templates/topologie/aff_ap.html @@ -23,52 +23,51 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load acl %} +{% load logs_extra %}
    - {% if ap_list.paginator %} - {% include "pagination.html" with list=ap_list %} - {% endif %} + {% if ap_list.paginator %} + {% include "pagination.html" with list=ap_list %} + {% endif %} -
    - - - - - - - - - - - {% for ap in ap_list %} - - - - - - - - - {% endfor %} -
    {% include "buttons/sort.html" with prefix='ap' col='name' text='Borne' %}{% include "buttons/sort.html" with prefix='ap' col='mac' text='Addresse mac' %}{% include "buttons/sort.html" with prefix='ap' col='ip' text='Ipv4' %}CommentaireLocalisation
    {{ap.interface_set.first}}{{ap.interface_set.first.mac_address}}{{ap.interface_set.first.ipv4}}{{ap.interface_set.first.details}}{{ap.location}} - - - - {% can_edit ap %} - - - - {% acl_end %} - {% can_delete ap %} - - - - {% acl_end %} -
    + + + + + + + + + + + + {% for ap in ap_list %} + + + + + + + + + {% endfor %} +
    {% include "buttons/sort.html" with prefix='ap' col='name' text='Borne' %}{% include "buttons/sort.html" with prefix='ap' col='mac' text='Addresse mac' %}{% include "buttons/sort.html" with prefix='ap' col='ip' text='Ipv4' %}CommentaireLocalisation
    {{ap.interface_set.first}}{{ap.interface_set.first.mac_address}}{{ap.interface_set.first.ipv4}}{{ap.interface_set.first.details}}{{ap.location}} + {% history_button ap %} + {% can_edit ap %} + + + + {% acl_end %} + {% can_delete ap %} + + + + {% acl_end %} +
    - {% if ap_list.paginator %} -{% include "pagination.html" with list=ap_list %} -{% endif %} + {% if ap_list.paginator %} + {% include "pagination.html" with list=ap_list %} + {% endif %}
    diff --git a/topologie/templates/topologie/aff_building.html b/topologie/templates/topologie/aff_building.html index 878c85e8..f0e02135 100644 --- a/topologie/templates/topologie/aff_building.html +++ b/topologie/templates/topologie/aff_building.html @@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load acl %} +{% load logs_extra %} {% if building_list.paginator %} {% include "pagination.html" with list=building_list %} @@ -34,27 +35,25 @@ with this program; if not, write to the Free Software Foundation, Inc., {% include "buttons/sort.html" with prefix='building' col='name' text='Bâtiment' %} - - {% for building in building_list %} - - {{building.name}} + + {% for building in building_list %} + + {{building.name}} - - - - {% can_edit building %} + {% history_button building %} + {% can_edit building %} - {% acl_end %} - {% can_delete building %} + {% acl_end %} + {% can_delete building %} - {% acl_end %} + {% acl_end %} - - {% endfor %} + + {% endfor %} {% if building_list.paginator %} diff --git a/topologie/templates/topologie/aff_chambres.html b/topologie/templates/topologie/aff_chambres.html index 3ca4651d..f71d6927 100644 --- a/topologie/templates/topologie/aff_chambres.html +++ b/topologie/templates/topologie/aff_chambres.html @@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load acl %} +{% load logs_extra %} {% if room_list.paginator %} {% include "pagination.html" with list=room_list %} @@ -35,28 +36,26 @@ with this program; if not, write to the Free Software Foundation, Inc., Commentaire - - {% for room in room_list %} - - {{room.name}} - {{room.details}} + + {% for room in room_list %} + + {{room.name}} + {{room.details}} - - - - {% can_edit room %} + {% history_button room %} + {% can_edit room %} - {% acl_end %} - {% can_delete room %} + {% acl_end %} + {% can_delete room %} - {% acl_end %} + {% acl_end %} - - {% endfor %} + + {% endfor %} {% if room_list.paginator %} diff --git a/topologie/templates/topologie/aff_constructor_switch.html b/topologie/templates/topologie/aff_constructor_switch.html index 76c74734..1b9f5d19 100644 --- a/topologie/templates/topologie/aff_constructor_switch.html +++ b/topologie/templates/topologie/aff_constructor_switch.html @@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load acl %} +{% load logs_extra %} {% if constructor_switch_list.paginator %} {% include "pagination.html" with list=constructor_switch_list %} @@ -34,27 +35,25 @@ with this program; if not, write to the Free Software Foundation, Inc., {% include "buttons/sort.html" with prefix='constructor-switch' col='name' text='Constructeur' %} - - {% for constructor_switch in constructor_switch_list %} - - {{constructor_switch}} + + {% for constructor_switch in constructor_switch_list %} + + {{constructor_switch}} - - - - {% can_edit constructor_switch %} + {% history_button constructor_switch %} + {% can_edit constructor_switch %} - {% acl_end %} - {% can_delete constructor_switch %} + {% acl_end %} + {% can_delete constructor_switch %} - {% acl_end %} + {% acl_end %} - - {% endfor %} + + {% endfor %} {% if constructor_switch_list.paginator %} diff --git a/topologie/templates/topologie/aff_model_switch.html b/topologie/templates/topologie/aff_model_switch.html index 6bb3e1f0..3a62024f 100644 --- a/topologie/templates/topologie/aff_model_switch.html +++ b/topologie/templates/topologie/aff_model_switch.html @@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load acl %} +{% load logs_extra %} {% if model_switch_list.paginator %} {% include "pagination.html" with list=model_switch_list %} @@ -33,30 +34,28 @@ with this program; if not, write to the Free Software Foundation, Inc., {% include "buttons/sort.html" with prefix='model-switch' col='reference' text='Référence' %} {% include "buttons/sort.html" with prefix='model-switch' col='constructor' text='Constructeur' %} - + - - {% for model_switch in model_switch_list %} - - {{model_switch.reference}} - {{model_switch.constructor}} - - - - - {% can_edit model_switch %} + + {% for model_switch in model_switch_list %} + + {{model_switch.reference}} + {{model_switch.constructor}} + + {% history_button model_switch %} + {% can_edit model_switch %} - {% acl_end %} - {% can_delete model_switch %} + {% acl_end %} + {% can_delete model_switch %} - {% acl_end %} + {% acl_end %} - - {% endfor %} + + {% endfor %} {% if model_switch_list.paginator %} diff --git a/topologie/templates/topologie/aff_port.html b/topologie/templates/topologie/aff_port.html index deeb0655..f01269a8 100644 --- a/topologie/templates/topologie/aff_port.html +++ b/topologie/templates/topologie/aff_port.html @@ -23,68 +23,67 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load acl %} +{% load logs_extra %}
    - - +
    + + + + + + + + + + + + + {% for port in port_list %} - - - - - - - - - - - {% for port in port_list %} - - - - + + - + - - - - - - {% endfor %} -
    {% include "buttons/sort.html" with prefix='port' col='port' text='Port' %}{% include "buttons/sort.html" with prefix='port' col='room' text='Room' %}{% include "buttons/sort.html" with prefix='port' col='interface' text='Interface machine' %}{% include "buttons/sort.html" with prefix='port' col='related' text='Related' %}{% include "buttons/sort.html" with prefix='port' col='radius' text='Radius' %}{% include "buttons/sort.html" with prefix='port' col='vlan' text='Vlan forcé' %}Détails
    {% include "buttons/sort.html" with prefix='port' col='port' text='Port' %}{% include "buttons/sort.html" with prefix='port' col='room' text='Room' %}{% include "buttons/sort.html" with prefix='port' col='interface' text='Interface machine' %}{% include "buttons/sort.html" with prefix='port' col='related' text='Related' %}{% include "buttons/sort.html" with prefix='port' col='radius' text='Radius' %}{% include "buttons/sort.html" with prefix='port' col='vlan' text='Vlan forcé' %}Détails
    {{ port.port }} - {% if port.room %}{{ port.room }}{% endif %} - - {% if port.machine_interface %} - {% can_view port.machine_interface.machine.user %} - + {{ port.port }} + {% if port.room %}{{ port.room }}{% endif %} + + {% if port.machine_interface %} + {% can_view port.machine_interface.machine.user %} + + {{ port.machine_interface }} + + {% acl_else %} {{ port.machine_interface }} - - {% acl_else %} - {{ port.machine_interface }} - {% acl_end %} - {% endif %} - - {% if port.related %} - {% can_view port.related.switch %} - + {% acl_end %} + {% endif %} + + {% if port.related %} + {% can_view port.related.switch %} + + {{ port.related }} + + {% acl_else %} {{ port.related }} - - {% acl_else %} - {{ port.related }} - {% acl_end %} - {% endif %} - {{ port.radius }}{% if not port.vlan_force %}Aucun{% else %}{{ port.vlan_force }}{% endif %}{{ port.details }} - - - - {% can_edit port %} - - - - {% acl_end %} - {% can_delete port %} - - - - {% acl_end %} -
    + {% acl_end %} + {% endif %} + + {{ port.radius }} + {% if not port.vlan_force %}Aucun{% else %}{{ port.vlan_force }}{% endif %} + {{ port.details }} + + {% history_button port %} + {% can_edit port %} + + + + {% acl_end %} + {% can_delete port %} + + + + {% acl_end %} + + + {% endfor %} +
    diff --git a/topologie/templates/topologie/aff_repr_switch.html b/topologie/templates/topologie/aff_repr_switch.html index 236dee56..f9e6e648 100644 --- a/topologie/templates/topologie/aff_repr_switch.html +++ b/topologie/templates/topologie/aff_repr_switch.html @@ -27,90 +27,90 @@ with this program; if not, write to the Free Software Foundation, Inc.,
    - + - {% for port in port_list|slice:"::2" %} - - {% endfor %} + {% for port in port_list|slice:"::2" %} + + {% endfor %} - - + + - {% for port in port_list|slice:"::2" %} - {% if port.room %} - - {% elif port.machine_interface %} - + {% elif port.machine_interface %} + - {% elif port.related%} - + {% elif port.related%} + - {% else %} - - {% endif %} - {% endfor %} - - + {% acl_end %} + + {% else %} + + {% endif %} + {% endfor %} - + - {% for port in port_list|slice:"1::2" %} - - {% endfor %} + - - + {% for port in port_list|slice:"1::2" %} + + {% endfor %} - {% for port in port_list|slice:"1::2" %} - {% if port.room %} - - {% elif port.machine_interface %} - + + + {% for port in port_list|slice:"1::2" %} + {% if port.room %} + + {% elif port.machine_interface %} + - {% elif port.related%} - + {% elif port.related%} + - {% else %} - - {% endif %} - {% endfor %} - - + {% acl_end %} + + {% else %} + + {% endif %} + {% endfor %} + +
    {{ port.port }}{{ port.port }}
    - {{ port.room }} - - {% can_view port.machine_interface.machine.user %} - + {% for port in port_list|slice:"::2" %} + {% if port.room %} + + {{ port.room }} + + {% can_view port.machine_interface.machine.user %} + + {{ port.machine_interface }} + + {% acl_else %} {{ port.machine_interface }} - - {% acl_else %} - {{ port.machine_interface }} - {% acl_end %} - - {% can_view port.related.switch %} - + {% acl_end %} + + {% can_view port.related.switch %} + + {{ port.related }} + + {% acl_else %} {{ port.related }} - - {% acl_else %} - {{ port.related }} - {% acl_end %} - - Vide -
    + Vide +
    {{ port.port }}
    {{ port.port }} - {{ port.room }} - - {% can_view port.machine_interface.machine.user %} - +
    + {{ port.room }} + + {% can_view port.machine_interface.machine.user %} + + {{ port.machine_interface }} + + {% acl_else %} {{ port.machine_interface }} - - {% acl_else %} - {{ port.machine_interface }} - {% acl_end %} - - {% can_view port.related.switch %} - + {% acl_end %} + + {% can_view port.related.switch %} + + {{ port.related }} + + {% acl_else %} {{ port.related }} - - {% acl_else %} - {{ port.related }} - {% acl_end %} - - Vide -
    + Vide +
    diff --git a/topologie/templates/topologie/aff_stacks.html b/topologie/templates/topologie/aff_stacks.html index 969c1075..4dd0f6ea 100644 --- a/topologie/templates/topologie/aff_stacks.html +++ b/topologie/templates/topologie/aff_stacks.html @@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load acl %} +{% load logs_extra %} @@ -33,29 +34,27 @@ with this program; if not, write to the Free Software Foundation, Inc., - - {% for stack in stack_list %} - - - - - - + + + + + - - {% endfor %} + + {% endfor %}
    Membres
    {{ stack.name }}{{stack.stack_id}}{{stack.details}}{% for switch in stack.switch_set.all %}{{switch }} {% endfor %} - - - - {% can_edit stack %} - - - - {% acl_end %} - {% can_delete stack %} - - - - {% acl_end %} + + {% for stack in stack_list %} +
    {{ stack.name }}{{stack.stack_id}}{{stack.details}}{% for switch in stack.switch_set.all %}{{switch }} {% endfor %} + {% history_button stack %} + {% can_edit stack %} + + + + {% acl_end %} + {% can_delete stack %} + + + + {% acl_end %}
    diff --git a/topologie/templates/topologie/aff_switch.html b/topologie/templates/topologie/aff_switch.html index 799225f0..1f4dcbcf 100644 --- a/topologie/templates/topologie/aff_switch.html +++ b/topologie/templates/topologie/aff_switch.html @@ -23,59 +23,60 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load acl %} +{% load logs_extra %}
    -{% if switch_list.paginator %} -{% include "pagination.html" with list=switch_list %} -{% endif %} + {% if switch_list.paginator %} + {% include "pagination.html" with list=switch_list %} + {% endif %} - - +
    + + + + + + + + + + + + + + {% for switch in switch_list %} - - - - - - - - - + + + + + + + + + - - {% for switch in switch_list %} - - - - - - - - - - - - {% endfor %} -
    {% include "buttons/sort.html" with prefix='switch' col='dns' text='Dns' %}{% include "buttons/sort.html" with prefix='switch' col='ip' text='Ipv4' %}{% include "buttons/sort.html" with prefix='switch' col='loc' text='Emplacement' %}{% include "buttons/sort.html" with prefix='switch' col='ports' text='Ports' %}{% include "buttons/sort.html" with prefix='switch' col='stack' text='Stack' %}Id stackModèleDétails
    {% include "buttons/sort.html" with prefix='switch' col='dns' text='Dns' %}{% include "buttons/sort.html" with prefix='switch' col='ip' text='Ipv4' %}{% include "buttons/sort.html" with prefix='switch' col='loc' text='Emplacement' %}{% include "buttons/sort.html" with prefix='switch' col='ports' text='Ports' %}{% include "buttons/sort.html" with prefix='switch' col='stack' text='Stack' %}Id stackModèleDétails + + {{switch}} + + {{switch.interface_set.first.ipv4}}{{switch.switchbay}}{{switch.number}}{{switch.stack.name}}{{switch.stack_member_id}}{{switch.model}}{{switch.interface_set.first.details}} + {% history_button switch %} + {% can_edit switch %} + {% include 'buttons/edit.html' with href='topologie:edit-switch' id=switch.pk %} + {% acl_end %} + {% can_delete switch %} + {% include 'buttons/suppr.html' with href='machines:del-machine' id=switch.id %} + {% acl_end %} + {% can_create Port %} + {% include 'buttons/add.html' with href='topologie:create-ports' id=switch.pk desc='Création de ports'%} + {% acl_end %} +
    - - {{switch}} - - {{switch.interface_set.first.ipv4}}{{switch.switchbay}}{{switch.number}}{{switch.stack.name}}{{switch.stack_member_id}}{{switch.model}}{{switch.interface_set.first.details}} - {% include 'buttons/history.html' with href='topologie:history' name='switch' id=switch.pk%} - {% can_edit switch %} - {% include 'buttons/edit.html' with href='topologie:edit-switch' id=switch.pk %} - {% acl_end %} - {% can_delete switch %} - {% include 'buttons/suppr.html' with href='machines:del-machine' id=switch.id %} - {% acl_end %} - {% can_create Port %} - {% include 'buttons/add.html' with href='topologie:create-ports' id=switch.pk desc='Création de ports'%} - {% acl_end %} -
    + {% endfor %} + -{% if switch_list.paginator %} -{% include "pagination.html" with list=switch_list %} -{% endif %} + {% if switch_list.paginator %} + {% include "pagination.html" with list=switch_list %} + {% endif %}
    diff --git a/topologie/templates/topologie/aff_switch_bay.html b/topologie/templates/topologie/aff_switch_bay.html index 881a63e0..c73bdf5f 100644 --- a/topologie/templates/topologie/aff_switch_bay.html +++ b/topologie/templates/topologie/aff_switch_bay.html @@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load acl %} +{% load logs_extra %} {% if switch_bay_list.paginator %} {% include "pagination.html" with list=switch_bay_list %} @@ -32,35 +33,33 @@ with this program; if not, write to the Free Software Foundation, Inc., {% include "buttons/sort.html" with prefix='switch-bay' col='name' text='Baie' %} - {% include "buttons/sort.html" with prefix='switch-bay' col='building' text='Bâtiment' %} - Info particulières - Switchs de la baie + {% include "buttons/sort.html" with prefix='switch-bay' col='building' text='Bâtiment' %} + Info particulières + Switchs de la baie - - {% for switch_bay in switch_bay_list %} - - {{switch_bay.name}} - {{switch_bay.building}} - {{switch_bay.info}} - {% for switch in switch_bay.switch_set.all %}{{switch }} {% endfor %} - - - - - {% can_edit switch_bay %} + + {% for switch_bay in switch_bay_list %} + + {{switch_bay.name}} + {{switch_bay.building}} + {{switch_bay.info}} + {% for switch in switch_bay.switch_set.all %}{{switch }} {% endfor %} + + {% history_button switch_bay %} + {% can_edit switch_bay %} - {% acl_end %} - {% can_delete switch_bay %} + {% acl_end %} + {% can_delete switch_bay %} - {% acl_end %} + {% acl_end %} - - {% endfor %} + + {% endfor %} {% if switch_bay_list.paginator %} diff --git a/topologie/templates/topologie/edit_stack_sw.html b/topologie/templates/topologie/edit_stack_sw.html index 75faaf84..37a25cd0 100644 --- a/topologie/templates/topologie/edit_stack_sw.html +++ b/topologie/templates/topologie/edit_stack_sw.html @@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load acl %} +{% load logs_extra %} @@ -31,27 +32,25 @@ with this program; if not, write to the Free Software Foundation, Inc., - - {% for stack in stack_list %} - - - - - + + + + - - {% endfor %} + + {% endfor %}
    ID Details
    {{stack.name}}{{stack.stack_id}}{{stack.details}} - - - - {% can_edit stack %} - + + {% for stack in stack_list %} +
    {{stack.name}}{{stack.stack_id}}{{stack.details}} + {% history_button stack %} + {% can_edit stack %} + - - {% acl_end %} - {% can_delete stack %} - - - - {% acl_end %} + + {% acl_end %} + {% can_delete stack %} + + + + {% acl_end %}
    diff --git a/topologie/urls.py b/topologie/urls.py index af3327b7..e4b3225c 100644 --- a/topologie/urls.py +++ b/topologie/urls.py @@ -30,7 +30,6 @@ from __future__ import unicode_literals from django.conf.urls import url -import re2o from . import views urlpatterns = [ @@ -51,10 +50,6 @@ urlpatterns = [ url(r'^switch/(?P[0-9]+)$', views.index_port, name='index-port'), - url(r'^history/(?P\w+)/(?P[0-9]+)$', - re2o.views.history, - name='history', - kwargs={'application': 'topologie'}), url(r'^edit_port/(?P[0-9]+)$', views.edit_port, name='edit-port'), url(r'^new_port/(?P[0-9]+)$', views.new_port, name='new-port'), url(r'^del_port/(?P[0-9]+)$', views.del_port, name='del-port'), diff --git a/users/templates/users/aff_bans.html b/users/templates/users/aff_bans.html index f9b11455..7f25a2ab 100644 --- a/users/templates/users/aff_bans.html +++ b/users/templates/users/aff_bans.html @@ -22,42 +22,43 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. {% endcomment %} {% load acl %} +{% load logs_extra %} {% if ban_list.paginator %} {% include "pagination.html" with list=ban_list %} {% endif %} - - - - - - - - - - - {% for ban in ban_list %} - {% if ban.is_active %} - +
    {% include "buttons/sort.html" with prefix='ban' col="user" text="Utilisateur" %}Raison{% include "buttons/sort.html" with prefix='ban' col="start" text="Date de début" %}{% include "buttons/sort.html" with prefix='ban' col="end" text="Date de fin" %}
    + + + + + + + + + + {% for ban in ban_list %} + {% if ban.is_active %} + {% else %} - {% endif %} + {% endif %} {% endfor %} -
    {% include "buttons/sort.html" with prefix='ban' col="user" text="Utilisateur" %}Raison{% include "buttons/sort.html" with prefix='ban' col="start" text="Date de début" %}{% include "buttons/sort.html" with prefix='ban' col="end" text="Date de fin" %}
    {{ ban.user }} {{ ban.raison }} {{ ban.date_start }} {{ ban.date_end }} - {% can_delete ban %} - {% include 'buttons/suppr.html' with href='users:del-ban' id=ban.id %} - {% acl_end %} - {% can_edit ban %} + {% can_delete ban %} + {% include 'buttons/suppr.html' with href='users:del-ban' id=ban.id %} + {% acl_end %} + {% can_edit ban %} {% include 'buttons/edit.html' with href='users:edit-ban' id=ban.id %} - {% acl_end %} - {% include 'buttons/history.html' with href='users:history' name='ban' id=ban.id %} + {% acl_end %} + {% history_button ban %}
    + {% if ban_list.paginator %} {% include "pagination.html" with list=ban_list %} diff --git a/users/templates/users/aff_clubs.html b/users/templates/users/aff_clubs.html index 4fb6bd0d..dfb82e10 100644 --- a/users/templates/users/aff_clubs.html +++ b/users/templates/users/aff_clubs.html @@ -28,36 +28,36 @@ with this program; if not, write to the Free Software Foundation, Inc., {% load acl %} - - - - - - - - - - - - {% for club in clubs_list %} - {% can_view club %} - - - - - - - +
    {% include "buttons/sort.html" with prefix='club' col="surname" text="Nom" %}{% include "buttons/sort.html" with prefix='club' col="pseudo" text="Pseudo" %}{% include "buttons/sort.html" with prefix='club' col="room" text="Chambre" %}Fin de cotisation leConnexionProfil
    {{ club.surname }}{{ club.pseudo }}{{ club.room }}{% if club.is_adherent %}{{ club.end_adhesion }}{% else %}Non adhérent{% endif %}{% if club.has_access == True %} - Active - {% else %} - Désactivée - {% endif %} - -
    + + + + + + + + - {% acl_end %} - {% endfor %} -
    {% include "buttons/sort.html" with prefix='club' col="surname" text="Nom" %}{% include "buttons/sort.html" with prefix='club' col="pseudo" text="Pseudo" %}{% include "buttons/sort.html" with prefix='club' col="room" text="Chambre" %}Fin de cotisation leConnexionProfil
    + + {% for club in clubs_list %} + {% can_view club %} + + {{ club.surname }} + {{ club.pseudo }} + {{ club.room }} + {% if club.is_adherent %}{{ club.end_adhesion }}{% else %}Non adhérent{% endif %} + {% if club.has_access == True %} + Active + {% else %} + Désactivée + {% endif %} + + + + + {% acl_end %} + {% endfor %} + {% if clubs_list.paginator %} {% include "pagination.html" with list=clubs_list %} diff --git a/users/templates/users/aff_listright.html b/users/templates/users/aff_listright.html index f4ed1e83..cf78e295 100644 --- a/users/templates/users/aff_listright.html +++ b/users/templates/users/aff_listright.html @@ -23,20 +23,21 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endcomment %} {% load i18n %} +{% load logs_extra %} {% if superusers.count %}
    - -

    - - {% trans "Superuser" %} -

    - {% trans "Django's specific pre-defined right that supersed any other rights." %} + +

    + + {% trans "Superuser" %} +

    + {% trans "Django's specific pre-defined right that supersed any other rights." %}
    @@ -106,24 +107,24 @@ with this program; if not, write to the Free Software Foundation, Inc., {% for right, users in rights.items %}
    -
    - {% if users %} - +
    + {% if users %} + {% else %} - {% endif %} + {% 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 }} + {% history_button right %} +
    +

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

    + {{ right.details }}
    diff --git a/users/templates/users/aff_rights.html b/users/templates/users/aff_rights.html index 98eb4674..26ed3c5d 100644 --- a/users/templates/users/aff_rights.html +++ b/users/templates/users/aff_rights.html @@ -22,20 +22,20 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. {% endcomment %} - - - - {% for right in right_list %} - - - {% endfor %} - - - {% for user_right in user_right_list %} +
    {{ right }}
    + - + {% for right in right_list %} + + + {% endfor %} - {% endfor %} -
    {{ user_right }}{{ right }}
    + + {% for user_right in user_right_list %} + + {{ user_right }} + + {% endfor %} + diff --git a/users/templates/users/aff_schools.html b/users/templates/users/aff_schools.html index 260c7ef3..1d32a6eb 100644 --- a/users/templates/users/aff_schools.html +++ b/users/templates/users/aff_schools.html @@ -22,18 +22,19 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. {% endcomment %} {% load acl %} +{% load logs_extra %}
    -{% if school_list.paginator %} -{% include "pagination.html" with list=school_list %} -{% endif %} + {% if school_list.paginator %} + {% include "pagination.html" with list=school_list %} + {% endif %} - + @@ -44,14 +45,14 @@ with this program; if not, write to the Free Software Foundation, Inc., {% can_edit school %} {% include 'buttons/edit.html' with href='users:edit-school' id=school.id %} {% acl_end %} - {% include 'buttons/history.html' with href='users:history' name='school' id=school.id %} + {% history_button school %} {% endfor %}
    {% include "buttons/sort.html" with prefix='school' col='name' text='Etablissement' %}{% include "buttons/sort.html" with prefix='school' col='name' text='Etablissement' %}
    -{% if school_list.paginator %} -{% include "pagination.html" with list=school_list %} -{% endif %} + {% if school_list.paginator %} + {% include "pagination.html" with list=school_list %} + {% endif %}
    diff --git a/users/templates/users/aff_serviceusers.html b/users/templates/users/aff_serviceusers.html index ddef0360..5f43b0d7 100644 --- a/users/templates/users/aff_serviceusers.html +++ b/users/templates/users/aff_serviceusers.html @@ -22,30 +22,31 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. {% endcomment %} {% load acl %} - - - - - - - - - - {% for serviceuser in serviceusers_list %} +{% load logs_extra %} +
    NomRôleCommentaire
    + - - - - + + + + - {% endfor %} -
    {{ serviceuser.pseudo }}{{ serviceuser.access_group }}{{ serviceuser.comment }} - {% can_delete serviceuser %} - {% include 'buttons/suppr.html' with href='users:del-serviceuser' id=serviceuser.id %} - {% acl_end %} - {% can_edit serviceuser %} - {% include 'buttons/edit.html' with href='users:edit-serviceuser' id=serviceuser.id %} - {% acl_end %} - {% include 'buttons/history.html' with href='users:history' name='serviceuser' id=serviceuser.id %} - NomRôleCommentaire
    + + {% for serviceuser in serviceusers_list %} + + {{ serviceuser.pseudo }} + {{ serviceuser.access_group }} + {{ serviceuser.comment }} + + {% can_delete serviceuser %} + {% include 'buttons/suppr.html' with href='users:del-serviceuser' id=serviceuser.id %} + {% acl_end %} + {% can_edit serviceuser %} + {% include 'buttons/edit.html' with href='users:edit-serviceuser' id=serviceuser.id %} + {% acl_end %} + {% history_button serviceuser %} + + + {% endfor %} + diff --git a/users/templates/users/aff_shell.html b/users/templates/users/aff_shell.html index a660f88b..a968a312 100644 --- a/users/templates/users/aff_shell.html +++ b/users/templates/users/aff_shell.html @@ -22,26 +22,27 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. {% endcomment %} {% load acl %} - - - - - - - - {% for shell in shell_list %} +{% load logs_extra %} +
    Shell
    + - - + + - {% endfor %} -
    {{ shell.shell }} - {% can_delete shell %} - {% include 'buttons/suppr.html' with href='users:del-shell' id=shell.id %} - {% acl_end %} - {% can_edit shell %} - {% include 'buttons/edit.html' with href='users:edit-shell' id=shell.id %} - {% acl_end %} - {% include 'buttons/history.html' with href='users:history' name='listshell' id=shell.id %} - Shell
    + + {% for shell in shell_list %} + + {{ shell.shell }} + + {% can_delete shell %} + {% include 'buttons/suppr.html' with href='users:del-shell' id=shell.id %} + {% acl_end %} + {% can_edit shell %} + {% include 'buttons/edit.html' with href='users:edit-shell' id=shell.id %} + {% acl_end %} + {% history_button shell %} + + + {% endfor %} + diff --git a/users/templates/users/aff_users.html b/users/templates/users/aff_users.html index d8c18890..42dc07d6 100644 --- a/users/templates/users/aff_users.html +++ b/users/templates/users/aff_users.html @@ -22,9 +22,9 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. {% endcomment %}
    -{% if users_list.paginator %} -{% include "pagination.html" with list=users_list %} -{% endif %} + {% if users_list.paginator %} + {% include "pagination.html" with list=users_list %} + {% endif %} @@ -57,7 +57,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endfor %}
    -{% if users_list.paginator %} -{% include "pagination.html" with list=users_list %} -{% endif %} + {% if users_list.paginator %} + {% include "pagination.html" with list=users_list %} + {% endif %}
    diff --git a/users/templates/users/aff_whitelists.html b/users/templates/users/aff_whitelists.html index 01a9efdd..98989093 100644 --- a/users/templates/users/aff_whitelists.html +++ b/users/templates/users/aff_whitelists.html @@ -26,38 +26,39 @@ with this program; if not, write to the Free Software Foundation, Inc., {% include "pagination.html" with list=white_list %} {% endif %} {% load acl %} - - - - - - - - - - - {% for whitelist in white_list %} - {% if whitelist.is_active %} - +{% load logs_extra %} +
    {% include "buttons/sort.html" with prefix='white' col="user" text="Utilisateur" %}Raison{% include "buttons/sort.html" with prefix='white' col="start" text="Date de début" %}{% include "buttons/sort.html" with prefix='white' col="end" text="Date de fin" %}
    + + + + + + + + + + {% for whitelist in white_list %} + {% if whitelist.is_active %} + {% else %} - {% endif %} + {% endif %} {% endfor %} -
    {% include "buttons/sort.html" with prefix='white' col="user" text="Utilisateur" %}Raison{% include "buttons/sort.html" with prefix='white' col="start" text="Date de début" %}{% include "buttons/sort.html" with prefix='white' col="end" text="Date de fin" %}
    {{ whitelist.user }} {{ whitelist.raison }} {{ whitelist.date_start }} {{ whitelist.date_end }} - {% can_delete whitelist %} + {% can_delete whitelist %} {% include 'buttons/suppr.html' with href='users:del-whitelist' id=whitelist.id %} - {% acl_end %} - {% can_edit whitelist %} + {% acl_end %} + {% can_edit whitelist %} {% include 'buttons/edit.html' with href='users:edit-whitelist' id=whitelist.id %} - {% acl_end %} - {% include 'buttons/history.html' with href='users:history' name='whitelist' id=whitelist.id %} + {% acl_end %} + {% history_button whitelist %}
    + {% if white_list.paginator %} {% include "pagination.html" with list=white_list %} diff --git a/users/templates/users/profil.html b/users/templates/users/profil.html index c0cccb14..2d671b86 100644 --- a/users/templates/users/profil.html +++ b/users/templates/users/profil.html @@ -25,12 +25,13 @@ with this program; if not, write to the Free Software Foundation, Inc., {% load bootstrap3 %} {% load acl %} +{% load logs_extra %} {% block title %}Profil{% endblock %} {% block content %}

    {{ users.surname }} {{users.name}}

    Vous êtes {% if users.end_adhesion != None %} -un {{ users.class_name | lower}}{% else %} -non adhérent{% endif %} et votre connexion est {% if users.has_access %} + un {{ users.class_name | lower}}{% else %} + non adhérent{% endif %} et votre connexion est {% if users.has_access %} active{% else %}désactivée{% endif %}.

    {% if user_solde %}

    Votre solde est de {{ users.solde }}€. @@ -49,134 +50,131 @@ non adhérent{% endif %} et votre connexion est {% if users.has_access %}

    -
    - - - Editer - - - - Changer le mot de passe - - {% can_change User state %} - - - Changer le statut - - {% acl_end %} - {% can_change User groups %} - - - Gérer les groupes - - {% acl_end %} - - - Historique - +
    + + + Editer + + + + Changer le mot de passe + + {% can_change User state %} + + + Changer le statut + + {% acl_end %} + {% can_change User groups %} + + + Gérer les groupes + + {% acl_end %} + {% history_button users text="History" %}
    -
    +
    - - - {% if users.is_class_club %} - - {% if users.club.mailing %} - - {% else %} - - {% endif %} - {% else %} - - - {% endif %} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {% if users.end_adhesion != None %} - - {% else %} - - {% endif %} - - {% if users.end_whitelist != None %} - - {% else %} - - {% endif %} - - - {% if users.end_ban != None %} - - {% else %} - - {% endif %} - - {% if users.state == 0 %} - - {% elif users.state == 1 %} - - {% else %} - - {% endif %} - - - - {% if users.has_access == True %} - - {% else %} - - {% endif %} - - {% if users.groups.all %} - - {% else %} - - {% endif %} - - - - - {% if users.shell %} - - - {% endif %} - -
    Mailing{{ users.pseudo }}(-admin)Mailing désactivéePrénom{{ users.name }}Nom{{ users.surname }}
    Pseudo{{ users.pseudo }}E-mail{{ users.email }}
    Chambre{{ users.room }}Téléphone{{ users.telephone }}
    École{{ users.school }}Commentaire{{ users.comment }}
    Date d'inscription{{ users.registered }}Dernière connexion{{ users.last_login }}
    Fin d'adhésion{{ users.end_adhesion }}Non adhérentAccès gracieux{{ users.end_whitelist }}Aucun
    Bannissement{{ users.end_ban }}Non banniStatutActifDésactivéArchivé
    Accès internetActif (jusqu'au {{ users.end_access }})DésactivéGroupes{{ users.groups.all|join:", "}}Aucun
    Solde{{ users.solde }} € - {% if user_solde %} - - - Recharger - - {% endif %} - Shell{{ users.shell }}
    + + + {% if users.is_class_club %} + + {% if users.club.mailing %} + + {% else %} + + {% endif %} + {% else %} + + + {% endif %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {% if users.end_adhesion != None %} + + {% else %} + + {% endif %} + + {% if users.end_whitelist != None %} + + {% else %} + + {% endif %} + + + {% if users.end_ban != None %} + + {% else %} + + {% endif %} + + {% if users.state == 0 %} + + {% elif users.state == 1 %} + + {% else %} + + {% endif %} + + + + {% if users.has_access == True %} + + {% else %} + + {% endif %} + + {% if users.groups.all %} + + {% else %} + + {% endif %} + + + + + {% if users.shell %} + + + {% endif %} + +
    Mailing{{ users.pseudo }}(-admin)Mailing désactivéePrénom{{ users.name }}Nom{{ users.surname }}
    Pseudo{{ users.pseudo }}E-mail{{ users.email }}
    Chambre{{ users.room }}Téléphone{{ users.telephone }}
    École{{ users.school }}Commentaire{{ users.comment }}
    Date d'inscription{{ users.registered }}Dernière connexion{{ users.last_login }}
    Fin d'adhésion{{ users.end_adhesion }}Non adhérentAccès gracieux{{ users.end_whitelist }}Aucun
    Bannissement{{ users.end_ban }}Non banniStatutActifDésactivéArchivé
    Accès internetActif (jusqu'au {{ users.end_access }})DésactivéGroupes{{ users.groups.all|join:", "}}Aucun
    Solde{{ users.solde }} € + {% if user_solde %} + + + Recharger + + {% endif %} + Shell{{ users.shell }}
    @@ -193,46 +191,46 @@ non adhérent{% endif %} et votre connexion est {% if users.has_access %} Gérer admin et membres - +
    -
    +

    Administrateurs du club

    - - +
    + + + + + + + + {% for admin in users.club.administrators.all %} - - - + + + - - {% for admin in users.club.administrators.all %} - - - - - - {% endfor %} -
    NomPrenomPseudo
    NomPrenomPseudo{{ admin.surname }}{{ admin.name }}{{ admin.pseudo }}
    {{ admin.surname }}{{ admin.name }}{{ admin.pseudo }}
    + {% endfor %} +

    Membres

    - - +
    + + + + + + + + {% for admin in users.club.members.all %} - - - + + + - - {% for admin in users.club.members.all %} - - - - - - {% endfor %} -
    NomPrenomPseudo
    NomPrenomPseudo{{ admin.surname }}{{ admin.name }}{{ admin.pseudo }}
    {{ admin.surname }}{{ admin.name }}{{ admin.pseudo }}
    + {% endfor %} +
    @@ -245,12 +243,12 @@ non adhérent{% endif %} et votre connexion est {% if users.has_access %} Machines {{nb_machines}} -
    +
    @@ -299,12 +297,12 @@ non adhérent{% endif %} et votre connexion est {% if users.has_access %} Bannissements -
    +
    -
    - {% can_create Ban %} - - +
    + {% can_create Ban %} + + Ajouter un bannissement {% acl_end %} @@ -326,12 +324,12 @@ non adhérent{% endif %} et votre connexion est {% if users.has_access %}
    -
    +
    diff --git a/users/urls.py b/users/urls.py index 724601c3..6bb374c3 100644 --- a/users/urls.py +++ b/users/urls.py @@ -27,7 +27,6 @@ from __future__ import unicode_literals from django.conf.urls import url -import re2o from . import views urlpatterns = [ @@ -95,10 +94,6 @@ urlpatterns = [ url(r'^process/(?P[a-z0-9]{32})/$', views.process, name='process'), url(r'^reset_password/$', views.reset_password, name='reset-password'), url(r'^mass_archive/$', views.mass_archive, name='mass-archive'), - url(r'^history/(?P\w+)/(?P[0-9]+)$', - re2o.views.history, - name='history', - kwargs={'application': 'users'}), url(r'^$', views.index, name='index'), url(r'^index_clubs/$', views.index_clubs, name='index-clubs'), url(r'^rest/ml/std/$', From fa6614adb5e20eb9c334db75a20a8927a2414d76 Mon Sep 17 00:00:00 2001 From: Hugo LEVY-FALK Date: Thu, 19 Jul 2018 12:43:19 +0200 Subject: [PATCH 2/4] i18n pour l'historique --- logs/views.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/logs/views.py b/logs/views.py index 0b785f08..d7ba59f3 100644 --- a/logs/views.py +++ b/logs/views.py @@ -44,8 +44,9 @@ from django.shortcuts import render, redirect from django.contrib import messages from django.contrib.auth.decorators import login_required from django.http import Http404 -from django.db.models import Count, Max, F +from django.db.models import Count from django.apps import apps +from django.utils.translation import ugettext as _ from reversion.models import Revision from reversion.models import Version, ContentType @@ -146,7 +147,7 @@ def index(request): 'comment': version.revision.comment, 'datetime': version.revision.date_created.strftime( '%d/%m/%y %H:%M:%S' - ), + ), 'username': version.revision.user.get_username() if version.revision.user else '?', @@ -177,7 +178,7 @@ def stats_logs(request): revisions = re2o_paginator(request, revisions, pagination_number) return render(request, 'logs/stats_logs.html', { 'revisions_list': revisions - }) + }) @login_required @@ -195,7 +196,7 @@ def revert_action(request, revision_id): return form({ 'objet': revision, 'objet_name': revision.__class__.__name__ - }, 'logs/delete.html', request) + }, 'logs/delete.html', request) @login_required @@ -482,20 +483,20 @@ def history(request, application, object_name, object_id): try: model = apps.get_model(application, object_name) except LookupError: - raise Http404(u"Il n'existe pas d'historique pour ce modèle.") + raise Http404(_("No model found.")) object_name_id = object_name + 'id' kwargs = {object_name_id: object_id} try: instance = model.get_instance(**kwargs) except model.DoesNotExist: - messages.error(request, u"Entrée inexistante") + messages.error(request, _("No entry found.")) return redirect(reverse( 'users:profil', kwargs={'userid': str(request.user.id)} )) can, msg = instance.can_view(request.user) if not can: - messages.error(request, msg or "Vous ne pouvez pas accéder à ce menu") + messages.error(request, msg or _("You cannot acces to this menu")) return redirect(reverse( 'users:profil', kwargs={'userid': str(request.user.id)} @@ -512,6 +513,3 @@ def history(request, application, object_name, object_id): 're2o/history.html', {'reversions': reversions, 'object': instance} ) - - - From 2ee17b370b5595d48c685fd47d02a5a1c83b08ac Mon Sep 17 00:00:00 2001 From: Hugo LEVY-FALK Date: Fri, 20 Jul 2018 19:54:03 +0200 Subject: [PATCH 3/4] =?UTF-8?q?Passage=20par=20flags=20plut=C3=B4t=20que?= =?UTF-8?q?=20par=20valeurs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/cotisations/aff_cotisations.html | 2 +- logs/templatetags/logs_extra.py | 12 ++++++++++-- templates/buttons/history.html | 4 ++-- users/templates/users/profil.html | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/cotisations/templates/cotisations/aff_cotisations.html b/cotisations/templates/cotisations/aff_cotisations.html index 27ced69e..6b5fa8fa 100644 --- a/cotisations/templates/cotisations/aff_cotisations.html +++ b/cotisations/templates/cotisations/aff_cotisations.html @@ -87,7 +87,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% acl_end %}
  • - {% history_button facture text='History' html_class=''%} + {% history_button facture text=True html_class=False%}
  • diff --git a/logs/templatetags/logs_extra.py b/logs/templatetags/logs_extra.py index 48573003..0620f8f4 100644 --- a/logs/templatetags/logs_extra.py +++ b/logs/templatetags/logs_extra.py @@ -36,8 +36,16 @@ def classname(obj): @register.inclusion_tag('buttons/history.html') -def history_button(instance, text=None, html_class=None): - """Creates the correct history button for an instance.""" +def history_button(instance, text=False, html_class=True): + """Creates the correct history button for an instance. + + Args: + instance: The instance of which you want to get history buttons. + text: Flag stating if a 'History' text should be displayed. + html_class: Flag stating if the link should have the html classes + allowing it to be displayed as a button. + + """ return { 'application': instance._meta.app_label, 'name': instance._meta.model_name, diff --git a/templates/buttons/history.html b/templates/buttons/history.html index e22c719b..8d0cc8bc 100644 --- a/templates/buttons/history.html +++ b/templates/buttons/history.html @@ -22,7 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. {% endcomment %} {% load i18n %} - - {% if text %}{% trans text %}{% endif %} + + {% if text %}{% trans 'History' %}{% endif %} diff --git a/users/templates/users/profil.html b/users/templates/users/profil.html index 2d671b86..2442f167 100644 --- a/users/templates/users/profil.html +++ b/users/templates/users/profil.html @@ -71,7 +71,7 @@ with this program; if not, write to the Free Software Foundation, Inc., Gérer les groupes {% acl_end %} - {% history_button users text="History" %} + {% history_button users text=True %}
    From c7bf295838f4915450c80d1a1e632a0de350c510 Mon Sep 17 00:00:00 2001 From: Hugo LEVY-FALK Date: Sun, 22 Jul 2018 22:18:31 +0200 Subject: [PATCH 4/4] i18n sur le title du bouton historique --- templates/buttons/history.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/buttons/history.html b/templates/buttons/history.html index 8d0cc8bc..fa7835da 100644 --- a/templates/buttons/history.html +++ b/templates/buttons/history.html @@ -22,7 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. {% endcomment %} {% load i18n %} - + {% if text %}{% trans 'History' %}{% endif %}