From e924e9196470e8ab43e7692b0add5cd8c01e7974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Kervella?= Date: Tue, 10 Apr 2018 11:56:17 +0000 Subject: [PATCH 1/2] Move Building and SwitchBay infos on the Stack info page --- .../topologie/index_model_switch.html | 44 ++++++-------- .../templates/topologie/index_stack.html | 31 +++++++--- topologie/views.py | 58 ++++++++++--------- 3 files changed, 71 insertions(+), 62 deletions(-) diff --git a/topologie/templates/topologie/index_model_switch.html b/topologie/templates/topologie/index_model_switch.html index 19752b2a..7c1a15f8 100644 --- a/topologie/templates/topologie/index_model_switch.html +++ b/topologie/templates/topologie/index_model_switch.html @@ -29,31 +29,21 @@ with this program; if not, write to the Free Software Foundation, Inc., {% block title %}Modèles de switches{% endblock %} {% block content %} -

Modèles de switches

-{% can_create ModelSwitch %} - Ajouter un modèle -
-{% acl_end %} -{% include "topologie/aff_model_switch.html" with model_switch_list=model_switch_list %} -

Constructeurs de switches

-{% can_create ConstructorSwitch %} - Ajouter un constructeur -
-{% acl_end %} -{% include "topologie/aff_constructor_switch.html" with constructor_switch_list=constructor_switch_list %} -

Baie de brassage

-{% can_create SwitchBay %} - Ajouter une baie de brassage -
-{% acl_end %} -{% include "topologie/aff_switch_bay.html" with switch_bay_list=switch_bay_list %} -

Batiment

-{% can_create Building %} - Ajouter un bâtiment -
-{% acl_end %} -{% include "topologie/aff_building.html" with building_list=building_list %} -
-
-
+

Modèles de switches

+ {% can_create ModelSwitch %} + + Ajouter un modèle + +
+ {% acl_end %} + {% include "topologie/aff_model_switch.html" with model_switch_list=model_switch_list %} + +

Constructeurs de switches

+ {% can_create ConstructorSwitch %} + + Ajouter un constructeur + +
+ {% acl_end %} + {% include "topologie/aff_constructor_switch.html" with constructor_switch_list=constructor_switch_list %} {% endblock %} diff --git a/topologie/templates/topologie/index_stack.html b/topologie/templates/topologie/index_stack.html index 1ba49b5a..2470c019 100644 --- a/topologie/templates/topologie/index_stack.html +++ b/topologie/templates/topologie/index_stack.html @@ -29,12 +29,29 @@ with this program; if not, write to the Free Software Foundation, Inc., {% block title %}Stacks{% endblock %} {% block content %} -

Stacks

-{% can_create Stack %} - Ajouter une stack -{% acl_end %} +

Stacks

+ {% can_create Stack %} + + Ajouter une stack + + {% acl_end %} {% include "topologie/aff_stacks.html" with stack_list=stack_list %} -
-
-
+ +

Baie de brassage

+ {% can_create SwitchBay %} + + Ajouter une baie de brassage + +
+ {% acl_end %} + {% include "topologie/aff_switch_bay.html" with switch_bay_list=switch_bay_list %} + +

Batiment

+ {% can_create Building %} + + Ajouter un bâtiment + +
+ {% acl_end %} + {% include "topologie/aff_building.html" with building_list=building_list %} {% endblock %} diff --git a/topologie/views.py b/topologie/views.py index 51c00aa8..3a215c07 100644 --- a/topologie/views.py +++ b/topologie/views.py @@ -182,42 +182,20 @@ def index_ap(request): @login_required @can_view_all(Stack) +@can_view_all(Building) +@can_view_all(SwitchBay) def index_stack(request): """Affichage de la liste des stacks (affiche l'ensemble des switches)""" stack_list = Stack.objects\ .prefetch_related('switch_set__interface_set__domain__extension') + building_list = Building.objects.all() + switch_bay_list = SwitchBay.objects.select_related('building') stack_list = SortTable.sort( stack_list, request.GET.get('col'), request.GET.get('order'), SortTable.TOPOLOGIE_INDEX_STACK ) - return render(request, 'topologie/index_stack.html', { - 'stack_list': stack_list - }) - - -@login_required -@can_view_all(ModelSwitch) -@can_view_all(ConstructorSwitch) -def index_model_switch(request): - """ Affichage de l'ensemble des modèles de switches""" - model_switch_list = ModelSwitch.objects.select_related('constructor') - constructor_switch_list = ConstructorSwitch.objects - switch_bay_list = SwitchBay.objects.select_related('building') - building_list = Building.objects.all() - model_switch_list = SortTable.sort( - model_switch_list, - request.GET.get('col'), - request.GET.get('order'), - SortTable.TOPOLOGIE_INDEX_MODEL_SWITCH - ) - constructor_switch_list = SortTable.sort( - constructor_switch_list, - request.GET.get('col'), - request.GET.get('order'), - SortTable.TOPOLOGIE_INDEX_CONSTRUCTOR_SWITCH - ) building_list = SortTable.sort( building_list, request.GET.get('col'), @@ -230,11 +208,35 @@ def index_model_switch(request): request.GET.get('order'), SortTable.TOPOLOGIE_INDEX_SWITCH_BAY ) + return render(request, 'topologie/index_stack.html', { + 'stack_list': stack_list, + 'switch_bay_list': switch_bay_list, + 'building_list' : building_list, + }) + + +@login_required +@can_view_all(ModelSwitch) +@can_view_all(ConstructorSwitch) +def index_model_switch(request): + """ Affichage de l'ensemble des modèles de switches""" + model_switch_list = ModelSwitch.objects.select_related('constructor') + constructor_switch_list = ConstructorSwitch.objects + model_switch_list = SortTable.sort( + model_switch_list, + request.GET.get('col'), + request.GET.get('order'), + SortTable.TOPOLOGIE_INDEX_MODEL_SWITCH + ) + constructor_switch_list = SortTable.sort( + constructor_switch_list, + request.GET.get('col'), + request.GET.get('order'), + SortTable.TOPOLOGIE_INDEX_CONSTRUCTOR_SWITCH + ) return render(request, 'topologie/index_model_switch.html', { 'model_switch_list': model_switch_list, 'constructor_switch_list': constructor_switch_list, - 'switch_bay_list': switch_bay_list, - 'building_list' : building_list, }) From b805ca94d7645be5498d71db811d2af1cc22c1fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Kervella?= Date: Tue, 10 Apr 2018 12:11:48 +0000 Subject: [PATCH 2/2] Rename index_stack into index_physical_grouping --- ...tack.html => index_physical_grouping.html} | 0 topologie/templates/topologie/sidebar.html | 4 ++-- topologie/urls.py | 2 +- topologie/views.py | 20 +++++++++---------- 4 files changed, 13 insertions(+), 13 deletions(-) rename topologie/templates/topologie/{index_stack.html => index_physical_grouping.html} (100%) diff --git a/topologie/templates/topologie/index_stack.html b/topologie/templates/topologie/index_physical_grouping.html similarity index 100% rename from topologie/templates/topologie/index_stack.html rename to topologie/templates/topologie/index_physical_grouping.html diff --git a/topologie/templates/topologie/sidebar.html b/topologie/templates/topologie/sidebar.html index bdbcf7fc..ce7b4114 100644 --- a/topologie/templates/topologie/sidebar.html +++ b/topologie/templates/topologie/sidebar.html @@ -37,9 +37,9 @@ with this program; if not, write to the Free Software Foundation, Inc., Bornes WiFi - + - Stacks + Groupements physiques diff --git a/topologie/urls.py b/topologie/urls.py index 66da7642..9b0a7065 100644 --- a/topologie/urls.py +++ b/topologie/urls.py @@ -64,7 +64,7 @@ urlpatterns = [ views.edit_switch, name='edit-switch'), url(r'^new_stack/$', views.new_stack, name='new-stack'), - url(r'^index_stack/$', views.index_stack, name='index-stack'), + url(r'^index_physical_grouping/$', views.index_physical_grouping, name='index-physical-grouping'), url(r'^edit_stack/(?P[0-9]+)$', views.edit_stack, name='edit-stack'), diff --git a/topologie/views.py b/topologie/views.py index 3a215c07..6c18721f 100644 --- a/topologie/views.py +++ b/topologie/views.py @@ -184,7 +184,7 @@ def index_ap(request): @can_view_all(Stack) @can_view_all(Building) @can_view_all(SwitchBay) -def index_stack(request): +def index_physical_grouping(request): """Affichage de la liste des stacks (affiche l'ensemble des switches)""" stack_list = Stack.objects\ .prefetch_related('switch_set__interface_set__domain__extension') @@ -208,7 +208,7 @@ def index_stack(request): request.GET.get('order'), SortTable.TOPOLOGIE_INDEX_SWITCH_BAY ) - return render(request, 'topologie/index_stack.html', { + return render(request, 'topologie/index_physical_grouping.html', { 'stack_list': stack_list, 'switch_bay_list': switch_bay_list, 'building_list' : building_list, @@ -320,7 +320,7 @@ def edit_stack(request, stack, stackid): if stack.is_valid(): if stack.changed_data: stack.save() - return redirect(reverse('topologie:index-stack')) + return redirect(reverse('topologie:index-physical-grouping')) return form({'topoform': stack, 'action_name' : 'Editer'}, 'topologie/topo.html', request) @@ -335,7 +335,7 @@ def del_stack(request, stack, stackid): except ProtectedError: messages.error(request, "La stack %s est affectée à un autre\ objet, impossible de la supprimer" % stack) - return redirect(reverse('topologie:index-stack')) + return redirect(reverse('topologie:index-physical-grouping')) return form({'objet': stack}, 'topologie/delete.html', request) @@ -665,7 +665,7 @@ def new_switch_bay(request): if switch_bay.is_valid(): switch_bay.save() messages.success(request, "La baie a été créé") - return redirect(reverse('topologie:index-model-switch')) + return redirect(reverse('topologie:index-physical-grouping')) return form({'topoform': switch_bay, 'action_name' : 'Ajouter'}, 'topologie/topo.html', request) @@ -678,7 +678,7 @@ def edit_switch_bay(request, switch_bay, switchbayid): if switch_bay.changed_data: switch_bay.save() messages.success(request, "Le switch a bien été modifié") - return redirect(reverse('topologie:index-model-switch')) + return redirect(reverse('topologie:index-physical-grouping')) return form({'topoform': switch_bay, 'action_name' : 'Editer'}, 'topologie/topo.html', request) @@ -693,7 +693,7 @@ def del_switch_bay(request, switch_bay, switchbayid): except ProtectedError: messages.error(request, "La baie %s est affecté à un autre objet,\ impossible de la supprimer (switch ou user)" % switch_bay) - return redirect(reverse('topologie:index-model-switch')) + return redirect(reverse('topologie:index-physical-grouping')) return form({ 'objet': switch_bay, 'objet_name': 'Baie de switch' @@ -708,7 +708,7 @@ def new_building(request): if building.is_valid(): building.save() messages.success(request, "Le batiment a été créé") - return redirect(reverse('topologie:index-model-switch')) + return redirect(reverse('topologie:index-physical-grouping')) return form({'topoform': building, 'action_name' : 'Ajouter'}, 'topologie/topo.html', request) @@ -721,7 +721,7 @@ def edit_building(request, building, buildingid): if building.changed_data: building.save() messages.success(request, "Le batiment a bien été modifié") - return redirect(reverse('topologie:index-model-switch')) + return redirect(reverse('topologie:index-physical-grouping')) return form({'topoform': building, 'action_name' : 'Editer'}, 'topologie/topo.html', request) @@ -736,7 +736,7 @@ def del_building(request, building, buildingid): except ProtectedError: messages.error(request, "Le batiment %s est affecté à un autre objet,\ impossible de la supprimer (switch ou user)" % building) - return redirect(reverse('topologie:index-model-switch')) + return redirect(reverse('topologie:index-physical-grouping')) return form({ 'objet': building, 'objet_name': 'Bâtiment'