From 751e0530e89cca1023a72c997f5776549cf51b3a Mon Sep 17 00:00:00 2001 From: bashmak Date: Wed, 14 Jun 2017 18:02:09 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5?= =?UTF-8?q?=D1=80=D0=BA=D0=B8=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20?= =?UTF-8?q?=D0=BF=D0=BE=20=20dhcp,=20=D0=B8=20=D0=B2=D1=8B=D0=B2=D0=B5?= =?UTF-8?q?=D0=BB=20=D0=B7=D0=BD=D0=B0=D1=87=D0=B5=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D1=82=D0=B0=D0=B9=D0=BC=D0=B0=D1=83=D1=82=D0=B0=20dhcp=20?= =?UTF-8?q?=D0=B2=20=D0=B3=D0=BB=D0=BE=D0=B1=D0=B0=D0=BB=D1=8C=D0=BD=D1=8B?= =?UTF-8?q?=D0=B5=20=D0=BD=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- abonapp/models.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/abonapp/models.py b/abonapp/models.py index 01899cb..c9e76b5 100644 --- a/abonapp/models.py +++ b/abonapp/models.py @@ -9,6 +9,7 @@ from tariff_app.models import Tariff from accounts_app.models import UserProfile from .fields import MACAddressField from mydefs import MyGenericIPAddressField, ip2int, LogicError, ip_addr_regex +from djing import settings class AbonGroup(models.Model): @@ -248,6 +249,9 @@ class Abon(UserProfile): self.ballance -= how_match_to_pay self.save(update_fields=['ballance']) + def is_dhcp(self): + return self.opt82 is not None + # Пополняем счёт def add_ballance(self, current_user, amount, comment): AbonLog.objects.create( @@ -320,10 +324,7 @@ class Abon(UserProfile): return False trf = ats[0].tariff ct = trf.get_calc_type()(ats[0]) - if ct.manage_access(self): - return True - else: - return False + return ct.manage_access(self) # создаём абонента из структуры агента def build_agent_struct(self): @@ -435,8 +436,8 @@ class AbonRawPassword(models.Model): def abon_post_save(sender, instance, **kwargs): timeout = None - if hasattr(instance, 'is_dhcp') and instance.is_dhcp: - timeout = 14400 + if hasattr(instance, 'is_dhcp') and instance.is_dhcp(): + timeout = getattr(settings, 'DHCP_TIMEOUT', 14400) agent_abon = instance.build_agent_struct() if agent_abon is None: return True