diff --git a/gestioasso/settings/cof_prod.py b/gestioasso/settings/cof_prod.py index 6121c98d..4089f8cf 100644 --- a/gestioasso/settings/cof_prod.py +++ b/gestioasso/settings/cof_prod.py @@ -206,3 +206,5 @@ MAIL_DATA = { # Max lookback date into kfet history KFET_HISTORY_DATE_LIMIT = timedelta(weeks=1) +# limite plus longue pour les chef/trez +KFET_HISTORY_LONG_DATE_LIMIT = timedelta(days=30) diff --git a/kfet/forms.py b/kfet/forms.py index 6623ad0e..f93ff068 100644 --- a/kfet/forms.py +++ b/kfet/forms.py @@ -489,8 +489,9 @@ class FilterHistoryForm(forms.Form): label=_("De"), widget=DateTimeWidget, required=False, - help_text="L'historique est limité à {} jours".format( - settings.KFET_HISTORY_DATE_LIMIT.days + help_text="Limité à {} jours ({} pour les chefs/trez)".format( + settings.KFET_HISTORY_DATE_LIMIT.days, + settings.KFET_HISTORY_LONG_DATE_LIMIT.days, ), ) end = forms.DateTimeField(label=_("À"), widget=DateTimeWidget, required=False) diff --git a/kfet/models.py b/kfet/models.py index 2eacf06f..622c0ac9 100644 --- a/kfet/models.py +++ b/kfet/models.py @@ -89,6 +89,7 @@ class Account(models.Model): ("can_force_close", "Fermer manuellement la K-Fêt"), ("see_config", "Voir la configuration K-Fêt"), ("change_config", "Modifier la configuration K-Fêt"), + ("access_old_history", "Peut accéder à l'historique plus ancien"), ) def __str__(self): diff --git a/kfet/views.py b/kfet/views.py index 10576d39..ca280728 100644 --- a/kfet/views.py +++ b/kfet/views.py @@ -1411,6 +1411,13 @@ def cancel_operations(request): return JsonResponse(data) +def get_history_limit(user) -> timedelta: + """returns the earliest date the user can view history""" + if user.has_perm("access_old_history"): + return datetime.today() - settings.KFET_HISTORY_LONG_DATE_LIMIT + return datetime.today() - settings.KFET_HISTORY_DATE_LIMIT + + @login_required def history_json(request): # Récupération des paramètres @@ -1497,7 +1504,7 @@ def history_json(request): return JsonResponse({}, status=403) if limit_date: # limiter l'accès à l'historique ancien pour confidentialité - earliest_date = datetime.today() - settings.KFET_HISTORY_DATE_LIMIT + earliest_date = get_history_limit(request.user) opegroups = opegroups.filter(at__gte=earliest_date) transfergroups = transfergroups.filter(at__gte=earliest_date) @@ -1589,7 +1596,7 @@ def kpsul_articles_data(request): @teamkfet_required def history(request): - history_limit = timezone.now() - settings.KFET_HISTORY_DATE_LIMIT + history_limit = get_history_limit(request.user) data = { "filter_form": FilterHistoryForm(), "history_limit": history_limit.strftime("%Y-%m-%d %H:%M"),