mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-27 07:02:26 +00:00
Remplace admin par infra pour les modifications de topologie
This commit is contained in:
parent
8f0b04df9e
commit
2ab15e27ef
9 changed files with 25 additions and 25 deletions
|
@ -8,7 +8,7 @@
|
||||||
{% for extension in extension_list %}
|
{% for extension in extension_list %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ extension.name }}</td>
|
<td>{{ extension.name }}</td>
|
||||||
<td>{% if is_admin %}<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:edit-extension' extension.id %}"><i class="glyphicon glyphicon-pushpin"></i> Editer</a>{% endif %}</td>
|
<td>{% if is_infra %}<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:edit-extension' extension.id %}"><i class="glyphicon glyphicon-pushpin"></i> Editer</a>{% endif %}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ type.type }}</td>
|
<td>{{ type.type }}</td>
|
||||||
<td>{{ type.extension }}</td>
|
<td>{{ type.extension }}</td>
|
||||||
<td>{% if is_admin %}<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:edit-machinetype' type.id %}"><i class="glyphicon glyphicon-pushpin"></i> Editer</a>{% endif %}</td>
|
<td>{% if is_infra %}<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:edit-machinetype' type.id %}"><i class="glyphicon glyphicon-pushpin"></i> Editer</a>{% endif %}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h2>Liste des extensions</h2>
|
<h2>Liste des extensions</h2>
|
||||||
{% if is_admin %}
|
{% if is_infra %}
|
||||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:add-extension' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter une extension</a>
|
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:add-extension' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter une extension</a>
|
||||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:del-extension' %}"><i class="glyphicon glyphicon-trash"></i> Supprimer une ou plusieurs extensions</a>
|
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:del-extension' %}"><i class="glyphicon glyphicon-trash"></i> Supprimer une ou plusieurs extensions</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h2>Liste des types de machines</h2>
|
<h2>Liste des types de machines</h2>
|
||||||
{% if is_admin %}
|
{% if is_infra %}
|
||||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:add-machinetype' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un type de machine</a>
|
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:add-machinetype' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un type de machine</a>
|
||||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:del-machinetype' %}"><i class="glyphicon glyphicon-trash"></i> Supprimer un ou plusieurs types de machines</a>
|
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:del-machinetype' %}"><i class="glyphicon glyphicon-trash"></i> Supprimer un ou plusieurs types de machines</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -111,7 +111,7 @@ def new_interface(request, machineid):
|
||||||
return form({'machineform': machine_form, 'interfaceform': interface_form}, 'machines/machine.html', request)
|
return form({'machineform': machine_form, 'interfaceform': interface_form}, 'machines/machine.html', request)
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required('admin')
|
@permission_required('infra')
|
||||||
def add_machinetype(request):
|
def add_machinetype(request):
|
||||||
machinetype = MachineTypeForm(request.POST or None)
|
machinetype = MachineTypeForm(request.POST or None)
|
||||||
if machinetype.is_valid():
|
if machinetype.is_valid():
|
||||||
|
@ -121,7 +121,7 @@ def add_machinetype(request):
|
||||||
return form({'machineform': machinetype, 'interfaceform': None}, 'machines/machine.html', request)
|
return form({'machineform': machinetype, 'interfaceform': None}, 'machines/machine.html', request)
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required('admin')
|
@permission_required('infra')
|
||||||
def edit_machinetype(request, machinetypeid):
|
def edit_machinetype(request, machinetypeid):
|
||||||
try:
|
try:
|
||||||
machinetype_instance = MachineType.objects.get(pk=machinetypeid)
|
machinetype_instance = MachineType.objects.get(pk=machinetypeid)
|
||||||
|
@ -136,7 +136,7 @@ def edit_machinetype(request, machinetypeid):
|
||||||
return form({'machineform': machinetype}, 'machines/machine.html', request)
|
return form({'machineform': machinetype}, 'machines/machine.html', request)
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required('admin')
|
@permission_required('infra')
|
||||||
def del_machinetype(request):
|
def del_machinetype(request):
|
||||||
machinetype = DelMachineTypeForm(request.POST or None)
|
machinetype = DelMachineTypeForm(request.POST or None)
|
||||||
if machinetype.is_valid():
|
if machinetype.is_valid():
|
||||||
|
@ -151,7 +151,7 @@ def del_machinetype(request):
|
||||||
return form({'machineform': machinetype, 'interfaceform': None}, 'machines/machine.html', request)
|
return form({'machineform': machinetype, 'interfaceform': None}, 'machines/machine.html', request)
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required('admin')
|
@permission_required('infra')
|
||||||
def add_extension(request):
|
def add_extension(request):
|
||||||
extension = ExtensionForm(request.POST or None)
|
extension = ExtensionForm(request.POST or None)
|
||||||
if extension.is_valid():
|
if extension.is_valid():
|
||||||
|
@ -161,7 +161,7 @@ def add_extension(request):
|
||||||
return form({'machineform': extension, 'interfaceform': None}, 'machines/machine.html', request)
|
return form({'machineform': extension, 'interfaceform': None}, 'machines/machine.html', request)
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required('admin')
|
@permission_required('infra')
|
||||||
def edit_extension(request, extensionid):
|
def edit_extension(request, extensionid):
|
||||||
try:
|
try:
|
||||||
extension_instance = Extension.objects.get(pk=extensionid)
|
extension_instance = Extension.objects.get(pk=extensionid)
|
||||||
|
@ -176,7 +176,7 @@ def edit_extension(request, extensionid):
|
||||||
return form({'machineform': extension}, 'machines/machine.html', request)
|
return form({'machineform': extension}, 'machines/machine.html', request)
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required('admin')
|
@permission_required('infra')
|
||||||
def del_extension(request):
|
def del_extension(request):
|
||||||
extension = DelExtensionForm(request.POST or None)
|
extension = DelExtensionForm(request.POST or None)
|
||||||
if extension.is_valid():
|
if extension.is_valid():
|
||||||
|
@ -197,12 +197,12 @@ def index(request):
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def index_machinetype(request):
|
def index_machinetype(request):
|
||||||
is_admin = request.user.has_perms(('admin',))
|
is_infra = request.user.has_perms(('infra',))
|
||||||
machinetype_list = MachineType.objects.order_by('type')
|
machinetype_list = MachineType.objects.order_by('type')
|
||||||
return render(request, 'machines/index_machinetype.html', {'machinetype_list':machinetype_list, 'is_admin':is_admin})
|
return render(request, 'machines/index_machinetype.html', {'machinetype_list':machinetype_list, 'is_infra':is_infra})
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def index_extension(request):
|
def index_extension(request):
|
||||||
is_admin = request.user.has_perms(('admin',))
|
is_infra = request.user.has_perms(('infra',))
|
||||||
extension_list = Extension.objects.order_by('name')
|
extension_list = Extension.objects.order_by('name')
|
||||||
return render(request, 'machines/index_extension.html', {'extension_list':extension_list, 'is_admin':is_admin})
|
return render(request, 'machines/index_extension.html', {'extension_list':extension_list, 'is_infra':is_infra})
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
<td>{{ port.machine_interface }}</td>
|
<td>{{ port.machine_interface }}</td>
|
||||||
<td>{{ port.related }}</td>
|
<td>{{ port.related }}</td>
|
||||||
<td>{{ port.details }}</td>
|
<td>{{ port.details }}</td>
|
||||||
<td>{% if is_admin %}<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:edit-port' port.id %}"><i class="glyphicon glyphicon-random"></i> Editer</a>{% endif %}</td>
|
<td>{% if is_infra %}<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:edit-port' port.id %}"><i class="glyphicon glyphicon-random"></i> Editer</a>{% endif %}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
{% block title %}Switchs{% endblock %}
|
{% block title %}Switchs{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% if is_admin %}
|
{% if is_infra %}
|
||||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:new-switch' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un switch</a>
|
<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:new-switch' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un switch</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% include "topologie/aff_switch.html" with switch_list=switch_list %}
|
{% include "topologie/aff_switch.html" with switch_list=switch_list %}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h2>Switch {{ nom_switch }}</h2>
|
<h2>Switch {{ nom_switch }}</h2>
|
||||||
{% if is_admin %}
|
{% if is_infra %}
|
||||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:edit-switch' id_switch %}"><i class="glyphicon glyphicon-edit"></i> Editer</a>
|
<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:edit-switch' id_switch %}"><i class="glyphicon glyphicon-edit"></i> Editer</a>
|
||||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:new-port' id_switch %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un port</a>
|
<a class="btn btn-primary btn-sm" role="button" href="{% url 'topologie:new-port' id_switch %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un port</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -9,23 +9,23 @@ from users.views import form
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def index(request):
|
def index(request):
|
||||||
is_admin = request.user.has_perms(('admin',))
|
is_infra = request.user.has_perms(('infra',))
|
||||||
switch_list = Switch.objects.order_by('building', 'number')
|
switch_list = Switch.objects.order_by('building', 'number')
|
||||||
return render(request, 'topologie/index.html', {'switch_list': switch_list, 'is_admin':is_admin})
|
return render(request, 'topologie/index.html', {'switch_list': switch_list, 'is_infra':is_infra})
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def index_port(request, switch_id):
|
def index_port(request, switch_id):
|
||||||
is_admin = request.user.has_perms(('admin',))
|
is_infra = request.user.has_perms(('infra',))
|
||||||
try:
|
try:
|
||||||
switch = Switch.objects.get(pk=switch_id)
|
switch = Switch.objects.get(pk=switch_id)
|
||||||
except Switch.DoesNotExist:
|
except Switch.DoesNotExist:
|
||||||
messages.error(request, u"Switch inexistant")
|
messages.error(request, u"Switch inexistant")
|
||||||
return redirect("/topologie/")
|
return redirect("/topologie/")
|
||||||
port_list = Port.objects.filter(switch = switch).order_by('port')
|
port_list = Port.objects.filter(switch = switch).order_by('port')
|
||||||
return render(request, 'topologie/index_p.html', {'port_list':port_list, 'id_switch':switch_id, 'nom_switch':switch, 'is_admin':is_admin})
|
return render(request, 'topologie/index_p.html', {'port_list':port_list, 'id_switch':switch_id, 'nom_switch':switch, 'is_infra':is_infra})
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required('admin')
|
@permission_required('infra')
|
||||||
def new_port(request, switch_id):
|
def new_port(request, switch_id):
|
||||||
try:
|
try:
|
||||||
switch = Switch.objects.get(pk=switch_id)
|
switch = Switch.objects.get(pk=switch_id)
|
||||||
|
@ -45,7 +45,7 @@ def new_port(request, switch_id):
|
||||||
return form({'topoform':port}, 'topologie/port.html', request)
|
return form({'topoform':port}, 'topologie/port.html', request)
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required('admin')
|
@permission_required('infra')
|
||||||
def edit_port(request, port_id):
|
def edit_port(request, port_id):
|
||||||
try:
|
try:
|
||||||
port = Port.objects.get(pk=port_id)
|
port = Port.objects.get(pk=port_id)
|
||||||
|
@ -60,7 +60,7 @@ def edit_port(request, port_id):
|
||||||
return form({'topoform':port}, 'topologie/port.html', request)
|
return form({'topoform':port}, 'topologie/port.html', request)
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required('admin')
|
@permission_required('infra')
|
||||||
def new_switch(request):
|
def new_switch(request):
|
||||||
switch = EditSwitchForm(request.POST or None)
|
switch = EditSwitchForm(request.POST or None)
|
||||||
if switch.is_valid():
|
if switch.is_valid():
|
||||||
|
@ -70,7 +70,7 @@ def new_switch(request):
|
||||||
return form({'topoform':switch}, 'topologie/port.html', request)
|
return form({'topoform':switch}, 'topologie/port.html', request)
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required('admin')
|
@permission_required('infra')
|
||||||
def edit_switch(request, switch_id):
|
def edit_switch(request, switch_id):
|
||||||
try:
|
try:
|
||||||
switch = Switch.objects.get(pk=switch_id)
|
switch = Switch.objects.get(pk=switch_id)
|
||||||
|
|
Loading…
Reference in a new issue