8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-23 15:33:45 +00:00

Merge branch 'moamoak/89_move_building_and_switchbay_info' into 'master'

Fix #89 : Move building and switchbay info

Closes #89

See merge request federez/re2o!116
This commit is contained in:
chirac 2018-04-10 18:40:55 +02:00
commit 304ca82eca
5 changed files with 83 additions and 74 deletions

View file

@ -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 %}
<h2>Modèles de switches</h2>
{% can_create ModelSwitch %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:new-model-switch' %}"><i class="fa fa-plus"></i> Ajouter un modèle</a>
<hr>
{% acl_end %}
{% include "topologie/aff_model_switch.html" with model_switch_list=model_switch_list %}
<h2>Constructeurs de switches</h2>
{% can_create ConstructorSwitch %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:new-constructor-switch' %}"><i class="fa fa-plus"></i> Ajouter un constructeur</a>
<hr>
{% acl_end %}
{% include "topologie/aff_constructor_switch.html" with constructor_switch_list=constructor_switch_list %}
<h2>Baie de brassage</h2>
{% can_create SwitchBay %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:new-switch-bay' %}"><i class="fa fa-plus"></i> Ajouter une baie de brassage</a>
<hr>
{% acl_end %}
{% include "topologie/aff_switch_bay.html" with switch_bay_list=switch_bay_list %}
<h2>Batiment</h2>
{% can_create Building %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:new-building' %}"><i class="fa fa-plus"></i> Ajouter un bâtiment</a>
<hr>
{% acl_end %}
{% include "topologie/aff_building.html" with building_list=building_list %}
<br />
<br />
<br />
<h2>Modèles de switches</h2>
{% can_create ModelSwitch %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:new-model-switch' %}">
<i class="fa fa-plus"></i> Ajouter un modèle
</a>
<hr>
{% acl_end %}
{% include "topologie/aff_model_switch.html" with model_switch_list=model_switch_list %}
<h2>Constructeurs de switches</h2>
{% can_create ConstructorSwitch %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:new-constructor-switch' %}">
<i class="fa fa-plus"></i> Ajouter un constructeur
</a>
<hr>
{% acl_end %}
{% include "topologie/aff_constructor_switch.html" with constructor_switch_list=constructor_switch_list %}
{% endblock %}

View file

@ -29,12 +29,29 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% block title %}Stacks{% endblock %}
{% block content %}
<h2>Stacks</h2>
{% can_create Stack %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:new-stack' %}"><i class="fa fa-plus"></i> Ajouter une stack</a>
{% acl_end %}
<h2>Stacks</h2>
{% can_create Stack %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:new-stack' %}">
<i class="fa fa-plus"></i> Ajouter une stack
</a>
{% acl_end %}
{% include "topologie/aff_stacks.html" with stack_list=stack_list %}
<br />
<br />
<br />
<h2>Baie de brassage</h2>
{% can_create SwitchBay %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:new-switch-bay' %}">
<i class="fa fa-plus"></i> Ajouter une baie de brassage
</a>
<hr>
{% acl_end %}
{% include "topologie/aff_switch_bay.html" with switch_bay_list=switch_bay_list %}
<h2>Batiment</h2>
{% can_create Building %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:new-building' %}">
<i class="fa fa-plus"></i> Ajouter un bâtiment
</a>
<hr>
{% acl_end %}
{% include "topologie/aff_building.html" with building_list=building_list %}
{% endblock %}

View file

@ -37,9 +37,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<i class="fa fa-wifi"></i>
Bornes WiFi
</a>
<a class="list-group-item list-group-item-info" href="{% url "topologie:index-stack" %}">
<a class="list-group-item list-group-item-info" href="{% url "topologie:index-physical-grouping" %}">
<i class="fa fa-list-ul"></i>
Stacks
Groupements physiques
</a>
<a class="list-group-item list-group-item-info" href="{% url "topologie:index-model-switch" %}">
<i class="fa fa-list-ul"></i>

View file

@ -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<stackid>[0-9]+)$',
views.edit_stack,
name='edit-stack'),

View file

@ -182,42 +182,20 @@ def index_ap(request):
@login_required
@can_view_all(Stack)
def index_stack(request):
@can_view_all(Building)
@can_view_all(SwitchBay)
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')
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_physical_grouping.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,
})
@ -318,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)
@ -333,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)
@ -663,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)
@ -676,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)
@ -691,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'
@ -706,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)
@ -719,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)
@ -734,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'