#140 Enhancements

* fixes InterventionAutocomplete bug, where team-shared entries would not pop up as valid option
* fixes bug where form opening for new compensation without direct intervention link resulted in 404
* adds intervention-recorded check on deduction forms: Form is invalid if intervention is currently recorded and therefore blocked for any editing
* extends basic check_for_recorded_instance() method to let some forms pass, e.g. deduction related forms on ecoaccounts which only have a reason to be rendered IF the entry is recorded
* adds/updates translations
This commit is contained in:
2022-04-19 13:37:29 +02:00
parent 090f6faa4e
commit 3b36193566
6 changed files with 164 additions and 122 deletions

View File

@@ -52,14 +52,16 @@ class InterventionAutocomplete(Select2QuerySetView):
"""
def get_queryset(self):
if self.request.user.is_anonymous:
user = self.request.user
if user.is_anonymous:
return Intervention.objects.none()
qs = Intervention.objects.filter(
deleted=None,
users__in=[self.request.user],
Q(deleted=None) &
Q(users__in=[user]) |
Q(teams__in=user.teams.all())
).order_by(
"identifier"
)
).distinct()
if self.q:
qs = qs.filter(
Q(identifier__icontains=self.q) |

View File

@@ -142,12 +142,28 @@ class BaseForm(forms.Form):
""" Checks if the instance is recorded and runs some special logic if yes
If the instance is recorded, the form shall not display any possibility to
edit any data. Instead, the users should get some information about why they can not edit anything
edit any data. Instead, the users should get some information about why they can not edit anything.
There are situations where the form should be rendered regularly,
e.g deduction forms for (recorded) eco accounts.
Returns:
"""
if self.instance is None or not isinstance(self.instance, BaseObject):
from intervention.forms.modalForms import NewDeductionModalForm, EditEcoAccountDeductionModalForm, \
RemoveEcoAccountDeductionModalForm
is_none = self.instance is None
is_other_data_type = not isinstance(self.instance, BaseObject)
is_deduction_form = isinstance(
self,
(
NewDeductionModalForm,
EditEcoAccountDeductionModalForm,
RemoveEcoAccountDeductionModalForm,
)
)
if is_none or is_other_data_type or is_deduction_form:
# Do nothing
return