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

Remplace admin par infra pour les modifications de topologie

This commit is contained in:
chirac 2016-07-09 15:47:10 +02:00
parent d6150c7e68
commit 765e06d0c6
9 changed files with 25 additions and 25 deletions

View file

@ -8,7 +8,7 @@
{% for extension in extension_list %}
<tr>
<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>
{% endfor %}
</table>

View file

@ -10,7 +10,7 @@
<tr>
<td>{{ type.type }}</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>
{% endfor %}
</table>

View file

@ -5,7 +5,7 @@
{% block content %}
<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:del-extension' %}"><i class="glyphicon glyphicon-trash"></i> Supprimer une ou plusieurs extensions</a>
{% endif %}

View file

@ -5,7 +5,7 @@
{% block content %}
<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:del-machinetype' %}"><i class="glyphicon glyphicon-trash"></i> Supprimer un ou plusieurs types de machines</a>
{% endif %}

View file

@ -111,7 +111,7 @@ def new_interface(request, machineid):
return form({'machineform': machine_form, 'interfaceform': interface_form}, 'machines/machine.html', request)
@login_required
@permission_required('admin')
@permission_required('infra')
def add_machinetype(request):
machinetype = MachineTypeForm(request.POST or None)
if machinetype.is_valid():
@ -121,7 +121,7 @@ def add_machinetype(request):
return form({'machineform': machinetype, 'interfaceform': None}, 'machines/machine.html', request)
@login_required
@permission_required('admin')
@permission_required('infra')
def edit_machinetype(request, machinetypeid):
try:
machinetype_instance = MachineType.objects.get(pk=machinetypeid)
@ -136,7 +136,7 @@ def edit_machinetype(request, machinetypeid):
return form({'machineform': machinetype}, 'machines/machine.html', request)
@login_required
@permission_required('admin')
@permission_required('infra')
def del_machinetype(request):
machinetype = DelMachineTypeForm(request.POST or None)
if machinetype.is_valid():
@ -151,7 +151,7 @@ def del_machinetype(request):
return form({'machineform': machinetype, 'interfaceform': None}, 'machines/machine.html', request)
@login_required
@permission_required('admin')
@permission_required('infra')
def add_extension(request):
extension = ExtensionForm(request.POST or None)
if extension.is_valid():
@ -161,7 +161,7 @@ def add_extension(request):
return form({'machineform': extension, 'interfaceform': None}, 'machines/machine.html', request)
@login_required
@permission_required('admin')
@permission_required('infra')
def edit_extension(request, extensionid):
try:
extension_instance = Extension.objects.get(pk=extensionid)
@ -176,7 +176,7 @@ def edit_extension(request, extensionid):
return form({'machineform': extension}, 'machines/machine.html', request)
@login_required
@permission_required('admin')
@permission_required('infra')
def del_extension(request):
extension = DelExtensionForm(request.POST or None)
if extension.is_valid():
@ -197,12 +197,12 @@ def index(request):
@login_required
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')
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
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')
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})

View file

@ -16,7 +16,7 @@
<td>{{ port.machine_interface }}</td>
<td>{{ port.related }}</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>
{% endfor %}
</table>

View file

@ -4,7 +4,7 @@
{% block title %}Switchs{% endblock %}
{% 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>
{% endif %}
{% include "topologie/aff_switch.html" with switch_list=switch_list %}

View file

@ -5,7 +5,7 @@
{% block content %}
<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:new-port' id_switch %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un port</a>
{% endif %}

View file

@ -9,23 +9,23 @@ from users.views import form
@login_required
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')
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
def index_port(request, switch_id):
is_admin = request.user.has_perms(('admin',))
is_infra = request.user.has_perms(('infra',))
try:
switch = Switch.objects.get(pk=switch_id)
except Switch.DoesNotExist:
messages.error(request, u"Switch inexistant")
return redirect("/topologie/")
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
@permission_required('admin')
@permission_required('infra')
def new_port(request, switch_id):
try:
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)
@login_required
@permission_required('admin')
@permission_required('infra')
def edit_port(request, port_id):
try:
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)
@login_required
@permission_required('admin')
@permission_required('infra')
def new_switch(request):
switch = EditSwitchForm(request.POST or None)
if switch.is_valid():
@ -70,7 +70,7 @@ def new_switch(request):
return form({'topoform':switch}, 'topologie/port.html', request)
@login_required
@permission_required('admin')
@permission_required('infra')
def edit_switch(request, switch_id):
try:
switch = Switch.objects.get(pk=switch_id)