mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-22 11:23:10 +00:00
Suppression de la mise en cache sur les ban et whitelist
This commit is contained in:
parent
d570ba45ad
commit
3b2ec6c9c9
2 changed files with 9 additions and 13 deletions
|
@ -350,7 +350,6 @@ class User(FieldPermissionModelMixin, AbstractBaseUser, PermissionsMixin):
|
|||
else:
|
||||
return self.is_adherent()
|
||||
|
||||
@cached_property
|
||||
def end_ban(self):
|
||||
""" Renvoie la date de fin de ban d'un user, False sinon """
|
||||
date_max = Ban.objects.filter(
|
||||
|
@ -358,7 +357,6 @@ class User(FieldPermissionModelMixin, AbstractBaseUser, PermissionsMixin):
|
|||
).aggregate(models.Max('date_end'))['date_end__max']
|
||||
return date_max
|
||||
|
||||
@cached_property
|
||||
def end_whitelist(self):
|
||||
""" Renvoie la date de fin de whitelist d'un user, False sinon """
|
||||
date_max = Whitelist.objects.filter(
|
||||
|
@ -366,10 +364,9 @@ class User(FieldPermissionModelMixin, AbstractBaseUser, PermissionsMixin):
|
|||
).aggregate(models.Max('date_end'))['date_end__max']
|
||||
return date_max
|
||||
|
||||
@cached_property
|
||||
def is_ban(self):
|
||||
""" Renvoie si un user est banni ou non """
|
||||
end = self.end_ban
|
||||
end = self.end_ban()
|
||||
if not end:
|
||||
return False
|
||||
elif end < DT_NOW:
|
||||
|
@ -377,10 +374,9 @@ class User(FieldPermissionModelMixin, AbstractBaseUser, PermissionsMixin):
|
|||
else:
|
||||
return True
|
||||
|
||||
@cached_property
|
||||
def is_whitelisted(self):
|
||||
""" Renvoie si un user est whitelisté ou non """
|
||||
end = self.end_whitelist
|
||||
end = self.end_whitelist()
|
||||
if not end:
|
||||
return False
|
||||
elif end < DT_NOW:
|
||||
|
@ -391,20 +387,20 @@ class User(FieldPermissionModelMixin, AbstractBaseUser, PermissionsMixin):
|
|||
def has_access(self):
|
||||
""" Renvoie si un utilisateur a accès à internet """
|
||||
return self.state == User.STATE_ACTIVE\
|
||||
and not self.is_ban and (self.is_connected() or self.is_whitelisted)
|
||||
and not self.is_ban() and (self.is_connected() or self.is_whitelisted())
|
||||
|
||||
def end_access(self):
|
||||
""" Renvoie la date de fin normale d'accès (adhésion ou whiteliste)"""
|
||||
if not self.end_connexion():
|
||||
if not self.end_whitelist:
|
||||
if not self.end_whitelist():
|
||||
return None
|
||||
else:
|
||||
return self.end_whitelist
|
||||
return self.end_whitelist()
|
||||
else:
|
||||
if not self.end_whitelist:
|
||||
if not self.end_whitelist():
|
||||
return self.end_connexion()
|
||||
else:
|
||||
return max(self.end_connexion(), self.end_whitelist)
|
||||
return max(self.end_connexion(), self.end_whitelist())
|
||||
|
||||
@cached_property
|
||||
def solde(self):
|
||||
|
|
|
@ -359,7 +359,7 @@ def add_ban(request, user, userid):
|
|||
'users:profil',
|
||||
kwargs={'userid':str(userid)}
|
||||
))
|
||||
if user.is_ban:
|
||||
if user.is_ban():
|
||||
messages.error(
|
||||
request,
|
||||
"Attention, cet utilisateur a deja un bannissement actif"
|
||||
|
@ -408,7 +408,7 @@ def add_whitelist(request, user, userid):
|
|||
'users:profil',
|
||||
kwargs={'userid':str(userid)}
|
||||
))
|
||||
if user.is_whitelisted:
|
||||
if user.is_whitelisted():
|
||||
messages.error(
|
||||
request,
|
||||
"Attention, cet utilisateur a deja un accès gracieux actif"
|
||||
|
|
Loading…
Reference in a new issue