mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-05 01:16:27 +00:00
Rapid fix, regen dhcp et mac-ip quand modification de l'accès internet
This commit is contained in:
parent
45bf4cbb1e
commit
73513c0bb7
3 changed files with 36 additions and 3 deletions
|
@ -30,6 +30,8 @@ from django.core.validators import MinValueValidator
|
|||
|
||||
from django.utils import timezone
|
||||
|
||||
from machines.models import regen
|
||||
|
||||
class Facture(models.Model):
|
||||
PRETTY_NAME = "Factures émises"
|
||||
|
||||
|
@ -180,3 +182,14 @@ class Cotisation(models.Model):
|
|||
def __str__(self):
|
||||
return str(self.vente)
|
||||
|
||||
@receiver(post_save, sender=Cotisation)
|
||||
def cotisation_post_save(sender, **kwargs):
|
||||
regen('dns')
|
||||
regen('dhcp')
|
||||
regen('mac_ip_list')
|
||||
|
||||
@receiver(post_delete, sender=Cotisation)
|
||||
def vente_post_delete(sender, **kwargs):
|
||||
cotisation = kwargs['instance']
|
||||
if not cotisation.vente.facture.user.has_access():
|
||||
regen('mac_ip_list')
|
||||
|
|
|
@ -320,8 +320,9 @@ class Service(models.Model):
|
|||
|
||||
def regen(service):
|
||||
""" Fonction externe pour régérération d'un service, prend un objet service en arg"""
|
||||
obj, created = Service.objects.get_or_create(service_type=service)
|
||||
obj.ask_regen()
|
||||
obj = Service.objects.filter(service_type=service)
|
||||
if obj:
|
||||
obj[0].ask_regen()
|
||||
return
|
||||
|
||||
class Service_link(models.Model):
|
||||
|
@ -360,6 +361,9 @@ def machine_post_delete(sender, **kwargs):
|
|||
machine = kwargs['instance']
|
||||
user = machine.user
|
||||
user.ldap_sync(base=False, access_refresh=False, mac_refresh=True)
|
||||
regen('dns')
|
||||
regen('dhcp')
|
||||
regen('mac_ip_list')
|
||||
|
||||
@receiver(post_save, sender=Interface)
|
||||
def interface_post_save(sender, **kwargs):
|
||||
|
|
|
@ -46,7 +46,7 @@ from django.contrib.auth.models import AbstractBaseUser, BaseUserManager
|
|||
from django.core.validators import MinLengthValidator
|
||||
from topologie.models import Room
|
||||
from cotisations.models import Cotisation, Facture, Paiement, Vente
|
||||
from machines.models import Interface, Machine
|
||||
from machines.models import Interface, Machine, regen
|
||||
from preferences.models import GeneralOption, AssoOption, OptionalUser
|
||||
|
||||
now = timezone.now()
|
||||
|
@ -640,11 +640,18 @@ def ban_post_save(sender, **kwargs):
|
|||
user.ldap_sync(base=False, access_refresh=True, mac_refresh=False)
|
||||
if is_created:
|
||||
ban.notif_ban()
|
||||
regen('dhcp')
|
||||
regen('mac_ip_list')
|
||||
if user.has_access():
|
||||
regen('dhcp')
|
||||
regen('mac_ip_list')
|
||||
|
||||
@receiver(post_delete, sender=Ban)
|
||||
def ban_post_delete(sender, **kwargs):
|
||||
user = kwargs['instance'].user
|
||||
user.ldap_sync(base=False, access_refresh=True, mac_refresh=False)
|
||||
regen('dhcp')
|
||||
regen('mac_ip_list')
|
||||
|
||||
class Whitelist(models.Model):
|
||||
PRETTY_NAME = "Liste des accès gracieux"
|
||||
|
@ -662,11 +669,20 @@ def whitelist_post_save(sender, **kwargs):
|
|||
whitelist = kwargs['instance']
|
||||
user = whitelist.user
|
||||
user.ldap_sync(base=False, access_refresh=True, mac_refresh=False)
|
||||
is_created = kwargs['created']
|
||||
if is_created:
|
||||
regen('dhcp')
|
||||
regen('mac_ip_list')
|
||||
if user.has_access():
|
||||
regen('dhcp')
|
||||
regen('mac_ip_list')
|
||||
|
||||
@receiver(post_delete, sender=Whitelist)
|
||||
def whitelist_post_delete(sender, **kwargs):
|
||||
user = kwargs['instance'].user
|
||||
user.ldap_sync(base=False, access_refresh=True, mac_refresh=False)
|
||||
regen('dhcp')
|
||||
regen('mac_ip_list')
|
||||
|
||||
class Request(models.Model):
|
||||
PASSWD = 'PW'
|
||||
|
|
Loading…
Reference in a new issue