8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2025-01-12 03:04:30 +00:00

Format les macs en EUI et corrige une erreur d'acl

This commit is contained in:
Gabriel Detraz 2016-11-12 09:09:28 +01:00
parent c42e61f8c7
commit bf932cf905
2 changed files with 5 additions and 1 deletions

View file

@ -3,6 +3,7 @@ from django.db.models.signals import post_save, post_delete
from django.dispatch import receiver from django.dispatch import receiver
from django.forms import ValidationError from django.forms import ValidationError
from macaddress.fields import MACAddressField from macaddress.fields import MACAddressField
from netaddr import EUI
from re2o.settings import MAIN_EXTENSION from re2o.settings import MAIN_EXTENSION
@ -61,6 +62,9 @@ class Interface(models.Model):
user = self.machine.user user = self.machine.user
return machine.active and user.has_access() return machine.active and user.has_access()
def clean(self, *args, **kwargs):
self.mac_address = str(EUI(self.mac_address)) or None
def __str__(self): def __str__(self):
return self.dns return self.dns

View file

@ -122,7 +122,7 @@ def edit_interface(request, interfaceid):
messages.error(request, u"Interface inexistante" ) messages.error(request, u"Interface inexistante" )
return redirect("/machines") return redirect("/machines")
if not request.user.has_perms(('infra',)): if not request.user.has_perms(('infra',)):
if interface.machine.user != request.user: if not request.user.has_perms(('cableur',)) and interface.machine.user != request.user:
messages.error(request, "Vous ne pouvez pas éditer une machine d'un autre user que vous sans droit") messages.error(request, "Vous ne pouvez pas éditer une machine d'un autre user que vous sans droit")
return redirect("/users/profil/" + str(request.user.id)) return redirect("/users/profil/" + str(request.user.id))
machine_form = BaseEditMachineForm(request.POST or None, instance=interface.machine) machine_form = BaseEditMachineForm(request.POST or None, instance=interface.machine)