forked from DGNum/gestioCOF
Switch back from config to settings
This commit is contained in:
parent
cc7c4306f4
commit
23f7865140
5 changed files with 22 additions and 18 deletions
|
@ -2,6 +2,7 @@ from datetime import timedelta
|
|||
from decimal import Decimal
|
||||
|
||||
from django import forms
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from django.core import validators
|
||||
from django.core.exceptions import ValidationError
|
||||
|
@ -481,16 +482,6 @@ class KFetConfigForm(ConfigForm):
|
|||
label="Durée pour annuler une commande sans mot de passe",
|
||||
initial=timedelta(minutes=5),
|
||||
)
|
||||
kfet_history_limit = forms.DurationField(
|
||||
label="Limite de confidentialité de l'historique",
|
||||
initial=timedelta(days=7),
|
||||
help_text="Les éléments plus vieux que cette durée seront masqués",
|
||||
)
|
||||
kfet_history_long_limit = forms.DurationField(
|
||||
label="Limite de confidentialité de l'historique pour chef/trez",
|
||||
initial=timedelta(days=30),
|
||||
help_text="Limite plus longue en cas de problème de compta",
|
||||
)
|
||||
|
||||
|
||||
class FilterHistoryForm(forms.Form):
|
||||
|
@ -498,7 +489,10 @@ class FilterHistoryForm(forms.Form):
|
|||
label=_("De"),
|
||||
widget=DateTimeWidget,
|
||||
required=False,
|
||||
help_text="Limité pour raisons de confidentialité",
|
||||
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)
|
||||
checkout = forms.ModelChoiceField(
|
||||
|
|
|
@ -4310,8 +4310,6 @@ class SettingsUpdateViewTests(ViewTestCaseMixin, TestCase):
|
|||
"kfet_overdraft_duration": "2 00:00:00",
|
||||
"kfet_overdraft_amount": "25",
|
||||
"kfet_cancel_duration": "00:20:00",
|
||||
"kfet_history_limit": "5 00:00:00",
|
||||
"kfet_history_long_limit": "60 00:00:00",
|
||||
}
|
||||
|
||||
def get_users_extra(self):
|
||||
|
@ -4333,8 +4331,6 @@ class SettingsUpdateViewTests(ViewTestCaseMixin, TestCase):
|
|||
"overdraft_duration": timedelta(days=2),
|
||||
"overdraft_amount": Decimal("25"),
|
||||
"cancel_duration": timedelta(minutes=20),
|
||||
"history_limit": timedelta(days=5),
|
||||
"history_long_limit": timedelta(days=60),
|
||||
}
|
||||
|
||||
for key, expected in expected_config.items():
|
||||
|
|
|
@ -6,6 +6,7 @@ from decimal import Decimal
|
|||
from typing import List
|
||||
from urllib.parse import urlencode
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth.decorators import login_required, permission_required
|
||||
from django.contrib.auth.mixins import PermissionRequiredMixin
|
||||
|
@ -1415,9 +1416,9 @@ def get_history_limit(user) -> datetime:
|
|||
according to his/her permissions"""
|
||||
now = timezone.now()
|
||||
if user.has_perm("kfet.access_old_history"):
|
||||
return now - kfet_config.history_long_limit
|
||||
return now - settings.KFET_HISTORY_LONG_DATE_LIMIT
|
||||
if user.has_perm("kfet.is_team"):
|
||||
return now - kfet_config.history_limit
|
||||
return now - settings.KFET_HISTORY_LONG_DATE_LIMIT
|
||||
# should not happen - future earliest date
|
||||
return now + timedelta(days=1)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue