diff --git a/machines/models.py b/machines/models.py index 7d083e09..a638bb47 100644 --- a/machines/models.py +++ b/machines/models.py @@ -3,6 +3,7 @@ from django.db.models.signals import post_save, post_delete from django.dispatch import receiver from django.forms import ValidationError from macaddress.fields import MACAddressField +from netaddr import EUI from re2o.settings import MAIN_EXTENSION @@ -61,6 +62,9 @@ class Interface(models.Model): user = self.machine.user 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): return self.dns diff --git a/machines/views.py b/machines/views.py index ddfb4531..d33c30ba 100644 --- a/machines/views.py +++ b/machines/views.py @@ -122,7 +122,7 @@ def edit_interface(request, interfaceid): messages.error(request, u"Interface inexistante" ) return redirect("/machines") 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") return redirect("/users/profil/" + str(request.user.id)) machine_form = BaseEditMachineForm(request.POST or None, instance=interface.machine)