Switched from datetime.today() to timezone.now()

This commit is contained in:
Dorian Lesbre 2021-02-19 12:13:23 +01:00
parent 4b95b65be2
commit 9a635148bb

View file

@ -1413,12 +1413,13 @@ def cancel_operations(request):
def get_history_limit(user) -> datetime: def get_history_limit(user) -> datetime:
"""returns the earliest date the given user can view history """returns the earliest date the given user can view history
according to his/her permissions""" according to his/her permissions"""
now = timezone.now()
if user.has_perm("kfet.access_old_history"): if user.has_perm("kfet.access_old_history"):
return datetime.today() - kfet_config.history_long_limit return now - kfet_config.history_long_limit
if user.has_perm("kfet.is_team"): if user.has_perm("kfet.is_team"):
return datetime.today() - kfet_config.history_limit return now - kfet_config.history_limit
# should not happen - future earliest date # should not happen - future earliest date
return datetime.today() + timedelta(days=1) return now + timedelta(days=1)
@login_required @login_required