mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-04 17:06:27 +00:00
fix acl functions in topologie models inheriting from Machine
This commit is contained in:
parent
bf55bf0fa9
commit
367e306145
3 changed files with 59 additions and 13 deletions
|
@ -130,6 +130,7 @@ class Machine(RevMixin, FieldPermissionModelMixin, AclMixin, models.Model):
|
|||
:param user_request: Utilisateur qui fait la requête
|
||||
:param userid: id de l'user dont on va créer une machine
|
||||
:return: soit True, soit False avec la raison de l'échec"""
|
||||
raise ValueError("Now you see me.")
|
||||
try:
|
||||
user = users.models.User.objects.get(pk=userid)
|
||||
except users.models.User.DoesNotExist:
|
||||
|
|
|
@ -135,11 +135,26 @@ class AccessPoint(Machine):
|
|||
def __str__(self):
|
||||
return str(self.interface_set.first())
|
||||
|
||||
# We want to retrieve the default behaviour given by AclMixin rather
|
||||
# than the one overwritten by Machine. If you are not familiar with
|
||||
# the behaviour of `super`, please check https://docs.python.org/3/library/functions.html#super
|
||||
|
||||
@classmethod
|
||||
def get_instance(cls, object_id, *_args, **kwargs):
|
||||
"""Récupère une instance
|
||||
:return: Une instance de la classe évidemment"""
|
||||
return cls.objects.get(pk=object_id)
|
||||
def get_instance(cls, *args, **kwargs):
|
||||
return super(Machine, cls).get_instance(*args, **kwargs)
|
||||
|
||||
@classmethod
|
||||
def can_create(cls, *args, **kwargs):
|
||||
return super(Machine, cls).can_create(*args, **kwargs)
|
||||
|
||||
def can_edit(self, *args, **kwargs):
|
||||
return super(Machine, self).can_edit(*args, **kwargs)
|
||||
|
||||
def can_delete(self, *args, **kwargs):
|
||||
return super(Machine, self).can_delete(*args, **kwargs)
|
||||
|
||||
def can_view(self, *args, **kwargs):
|
||||
return super(Machine, self).can_view(*args, **kwargs)
|
||||
|
||||
|
||||
class Server(Machine):
|
||||
|
@ -179,11 +194,26 @@ class Server(Machine):
|
|||
def __str__(self):
|
||||
return str(self.interface_set.first())
|
||||
|
||||
# We want to retrieve the default behaviour given by AclMixin rather
|
||||
# than the one overwritten by Machine. If you are not familiar with
|
||||
# the behaviour of `super`, please check https://docs.python.org/3/library/functions.html#super
|
||||
|
||||
@classmethod
|
||||
def get_instance(cls, object_id, *_args, **kwargs):
|
||||
"""Récupère une instance
|
||||
:return: Une instance de la classe évidemment"""
|
||||
return cls.objects.get(pk=object_id)
|
||||
def get_instance(cls, *args, **kwargs):
|
||||
return super(Machine, cls).get_instance(*args, **kwargs)
|
||||
|
||||
@classmethod
|
||||
def can_create(cls, *args, **kwargs):
|
||||
return super(Machine, cls).can_create(*args, **kwargs)
|
||||
|
||||
def can_edit(self, *args, **kwargs):
|
||||
return super(Machine, self).can_edit(*args, **kwargs)
|
||||
|
||||
def can_delete(self, *args, **kwargs):
|
||||
return super(Machine, self).can_delete(*args, **kwargs)
|
||||
|
||||
def can_view(self, *args, **kwargs):
|
||||
return super(Machine, self).can_view(*args, **kwargs)
|
||||
|
||||
|
||||
class Switch(Machine):
|
||||
|
@ -469,11 +499,26 @@ class Switch(Machine):
|
|||
def __str__(self):
|
||||
return str(self.get_name)
|
||||
|
||||
# We want to retrieve the default behaviour given by AclMixin rather
|
||||
# than the one overwritten by Machine. If you are not familiar with
|
||||
# the behaviour of `super`, please check https://docs.python.org/3/library/functions.html#super
|
||||
|
||||
@classmethod
|
||||
def get_instance(cls, object_id, *_args, **kwargs):
|
||||
"""Récupère une instance
|
||||
:return: Une instance de la classe évidemment"""
|
||||
return cls.objects.get(pk=object_id)
|
||||
def get_instance(cls, *args, **kwargs):
|
||||
return super(Machine, cls).get_instance(*args, **kwargs)
|
||||
|
||||
@classmethod
|
||||
def can_create(cls, *args, **kwargs):
|
||||
return super(Machine, cls).can_create(*args, **kwargs)
|
||||
|
||||
def can_edit(self, *args, **kwargs):
|
||||
return super(Machine, self).can_edit(*args, **kwargs)
|
||||
|
||||
def can_delete(self, *args, **kwargs):
|
||||
return super(Machine, self).can_delete(*args, **kwargs)
|
||||
|
||||
def can_view(self, *args, **kwargs):
|
||||
return super(Machine, self).can_view(*args, **kwargs)
|
||||
|
||||
|
||||
class ModelSwitch(AclMixin, RevMixin, models.Model):
|
||||
|
|
Loading…
Reference in a new issue