mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-09-12 01:03:09 +00:00
Evaluation dynamique de la date
This commit is contained in:
parent
e6c5e0c3f9
commit
d36a971378
1 changed files with 7 additions and 9 deletions
|
@ -82,8 +82,6 @@ from machines.models import Domain, Interface, Machine, regen
|
|||
from preferences.models import GeneralOption, AssoOption, OptionalUser
|
||||
from preferences.models import OptionalMachine, MailMessageOption
|
||||
|
||||
DT_NOW = timezone.now()
|
||||
|
||||
|
||||
# Utilitaires généraux
|
||||
|
||||
|
@ -334,7 +332,7 @@ class User(FieldPermissionModelMixin, AbstractBaseUser, PermissionsMixin):
|
|||
end = self.end_adhesion()
|
||||
if not end:
|
||||
return False
|
||||
elif end < DT_NOW:
|
||||
elif end < timezone.now():
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
@ -345,7 +343,7 @@ class User(FieldPermissionModelMixin, AbstractBaseUser, PermissionsMixin):
|
|||
end = self.end_connexion()
|
||||
if not end:
|
||||
return False
|
||||
elif end < DT_NOW:
|
||||
elif end < timezone.now():
|
||||
return False
|
||||
else:
|
||||
return self.is_adherent()
|
||||
|
@ -369,7 +367,7 @@ class User(FieldPermissionModelMixin, AbstractBaseUser, PermissionsMixin):
|
|||
end = self.end_ban()
|
||||
if not end:
|
||||
return False
|
||||
elif end < DT_NOW:
|
||||
elif end < timezone.now():
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
@ -379,7 +377,7 @@ class User(FieldPermissionModelMixin, AbstractBaseUser, PermissionsMixin):
|
|||
end = self.end_whitelist()
|
||||
if not end:
|
||||
return False
|
||||
elif end < DT_NOW:
|
||||
elif end < timezone.now():
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
@ -1282,7 +1280,7 @@ class Ban(models.Model):
|
|||
|
||||
def is_active(self):
|
||||
"""Ce ban est-il actif?"""
|
||||
return self.date_end > DT_NOW
|
||||
return self.date_end > timezone.now()
|
||||
|
||||
def get_instance(banid, *args, **kwargs):
|
||||
return Ban.objects.get(pk=banid)
|
||||
|
@ -1388,7 +1386,7 @@ class Whitelist(models.Model):
|
|||
)
|
||||
|
||||
def is_active(self):
|
||||
return self.date_end > DT_NOW
|
||||
return self.date_end > timezone.now()
|
||||
|
||||
def get_instance(whitelistid, *args, **kwargs):
|
||||
return Whitelist.objects.get(pk=whitelistid)
|
||||
|
@ -1497,7 +1495,7 @@ class Request(models.Model):
|
|||
def save(self):
|
||||
if not self.expires_at:
|
||||
options, _created = GeneralOption.objects.get_or_create()
|
||||
self.expires_at = DT_NOW \
|
||||
self.expires_at = timezone.now() \
|
||||
+ datetime.timedelta(hours=options.req_expire_hrs)
|
||||
if not self.token:
|
||||
self.token = str(uuid.uuid4()).replace('-', '') # remove hyphens
|
||||
|
|
Loading…
Reference in a new issue