From 2d9bd30f127287001e6936400f70d2a40d123b5f Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Wed, 11 Jul 2018 03:14:56 +0200 Subject: [PATCH] Bricoles d'affichage --- .../templates/preferences/aff_radiuskey.html | 7 ++++ .../preferences/aff_switchmanagementcred.html | 7 ++++ preferences/templates/preferences/delete.html | 40 +++++++++++++++++++ preferences/urls.py | 4 +- preferences/views.py | 16 ++++++-- 5 files changed, 68 insertions(+), 6 deletions(-) create mode 100644 preferences/templates/preferences/delete.html diff --git a/preferences/templates/preferences/aff_radiuskey.html b/preferences/templates/preferences/aff_radiuskey.html index 6aca740d..9d9980fa 100644 --- a/preferences/templates/preferences/aff_radiuskey.html +++ b/preferences/templates/preferences/aff_radiuskey.html @@ -28,6 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc., Clef Commentaire Clef par default des switchs + Clef utilisée par les switchs @@ -37,10 +38,16 @@ with this program; if not, write to the Free Software Foundation, Inc., {{ radiuskey.radius_key }} {{ radiuskey.comment }} {{ radiuskey.default_switch }} + {{ radiuskey.switch_set.all|join:", " }} {% can_edit radiuskey %} {% include 'buttons/edit.html' with href='preferences:edit-radiuskey' id=radiuskey.id %} {% acl_end %} + {% can_delete radiuskey %} + + + + {% acl_end %} {% include 'buttons/history.html' with href='preferences:history' name='radiuskey' id=radiuskey.id %} diff --git a/preferences/templates/preferences/aff_switchmanagementcred.html b/preferences/templates/preferences/aff_switchmanagementcred.html index 2f03edf8..d69a287a 100644 --- a/preferences/templates/preferences/aff_switchmanagementcred.html +++ b/preferences/templates/preferences/aff_switchmanagementcred.html @@ -27,6 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc., Identifiant Creds par default des switchs + Utilisé pour les switchs @@ -35,10 +36,16 @@ with this program; if not, write to the Free Software Foundation, Inc., {{ switchmanagementcred.management_id }} {{ switchmanagementcred.default_switch }} + {{ switchmanagementcred.switch_set.all|join:", " }} {% can_edit switchmanagementcred %} {% include 'buttons/edit.html' with href='preferences:edit-switchmanagementcred' id=switchmanagementcred.id %} {% acl_end %} + {% can_delete switchmanagementcred %} + + + + {% acl_end %} {% include 'buttons/history.html' with href='preferences:history' name='switchmanagementcred' id=switchmanagementcred.id %} diff --git a/preferences/templates/preferences/delete.html b/preferences/templates/preferences/delete.html new file mode 100644 index 00000000..ce277647 --- /dev/null +++ b/preferences/templates/preferences/delete.html @@ -0,0 +1,40 @@ +{% extends "topologie/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 %}Création et modification de machines{% endblock %} + +{% block content %} + +
+ {% csrf_token %} +

Attention, voulez-vous vraiment supprimer cet objet {{ objet_name }} ( {{ objet }} ) ?

+ {% bootstrap_button "Confirmer" button_type="submit" icon="trash" %} +
+
+
+
+{% endblock %} diff --git a/preferences/urls.py b/preferences/urls.py index 87e2f0ae..89d0254c 100644 --- a/preferences/urls.py +++ b/preferences/urls.py @@ -93,13 +93,13 @@ urlpatterns = [ views.edit_radiuskey, name='edit-radiuskey' ), - url(r'^del_radiuskey/$', views.del_radiuskey, name='del-radiuskey'), + url(r'^del_radiuskey/(?P[0-9]+)$', views.del_radiuskey, name='del-radiuskey'), url(r'^add_switchmanagementcred/$', views.add_switchmanagementcred, name='add-switchmanagementcred'), url( r'^edit_switchmanagementcred/(?P[0-9]+)$', views.edit_switchmanagementcred, name='edit-switchmanagementcred' ), - url(r'^del_switchmanagementcred/$', views.del_switchmanagementcred, name='del-switchmanagementcred'), + url(r'^del_switchmanagementcred/(?P[0-9]+)$', views.del_switchmanagementcred, name='del-switchmanagementcred'), url(r'^$', views.display_options, name='display-options'), ] diff --git a/preferences/views.py b/preferences/views.py index 726e430e..181434ea 100644 --- a/preferences/views.py +++ b/preferences/views.py @@ -261,8 +261,12 @@ def edit_radiuskey(request, radiuskey_instance, **_kwargs): def del_radiuskey(request, radiuskey_instance, **_kwargs): """Destruction d'un radiuskey""" if request.method == "POST": - radiuskey_instance.delete() - messages.success(request, "La radiuskey a été détruite") + try: + radiuskey_instance.delete() + messages.success(request, "La radiuskey a été détruite") + except ProtectedError: + messages.error(request, "Erreur la\ + clef ne peut être supprimé, elle est affectée à des switchs") return redirect(reverse('preferences:display-options')) return form( {'objet': radiuskey_instance, 'objet_name': 'radiuskey'}, @@ -306,8 +310,12 @@ def edit_switchmanagementcred(request, switchmanagementcred_instance, **_kwargs) def del_switchmanagementcred(request, switchmanagementcred_instance, **_kwargs): """Destruction d'un switchmanagementcred""" if request.method == "POST": - switchmanagementcred_instance.delete() - messages.success(request, "Ce switchmanagementcred a été détruit") + try: + switchmanagementcred_instance.delete() + messages.success(request, "Ces creds ont été détruits") + except ProtectedError: + messages.error(request, "Erreur ces\ + creds ne peuvent être supprimés, ils sont affectés à des switchs") return redirect(reverse('preferences:display-options')) return form( {'objet': switchmanagementcred_instance, 'objet_name': 'switchmanagementcred'},