8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-26 06:32:26 +00:00

Rapid fix, regen dhcp et mac-ip quand modification de l'accès internet

This commit is contained in:
Gabriel Detraz 2017-09-01 03:15:54 +02:00 committed by root
parent 91a5a01930
commit 7d7759a7c1
3 changed files with 36 additions and 3 deletions

View file

@ -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')

View file

@ -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):

View file

@ -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'