EMA Filter

* refactors EmaTableFilter to inherit from EcoAccountFilter
* refactors messages for recording/unrecording of EMA
* adds/updates translations
This commit is contained in:
mipel 2021-08-19 14:39:28 +02:00
parent 5137572127
commit 631b5d0ea6
4 changed files with 21 additions and 57 deletions

View File

@ -7,47 +7,12 @@ Created on: 19.08.21
""" """
from django.db.models import QuerySet from django.db.models import QuerySet
from compensation.filters import CompensationTableFilter from compensation.filters import EcoAccountTableFilter
class EmaTableFilter(CompensationTableFilter): class EmaTableFilter(EcoAccountTableFilter):
""" """
Since EMA and compensation are basically the same, we can reuse CompensationTableFilter and extend the MAE filter Since EMA and compensation are basically the same, we can reuse CompensationTableFilter and extend the MAE filter
in the future by inheriting. in the future by inheriting.
""" """
pass
def _filter_show_all(self, queryset, name, value) -> QuerySet:
""" Filters queryset depending on value of 'show_all' setting
Args:
queryset ():
name ():
value ():
Returns:
"""
if not value:
return queryset.filter(
users__in=[self.user], # requesting user has access
)
else:
return queryset
def _filter_show_recorded(self, queryset, name, value) -> QuerySet:
""" Filters queryset depending on value of 'show_recorded' setting
Args:
queryset ():
name ():
value ():
Returns:
"""
if not value:
return queryset.filter(
recorded=None,
)
else:
return queryset

View File

@ -167,10 +167,11 @@ def record_view(request: HttpRequest, id: str):
""" """
ema = get_object_or_404(Ema, id=id) ema = get_object_or_404(Ema, id=id)
msg_succ = _("{} unrecorded") if ema.recorded else _("{} recorded")
form = RecordForm(request.POST or None, instance=ema, user=request.user) form = RecordForm(request.POST or None, instance=ema, user=request.user)
return form.process_request( return form.process_request(
request=request, request=request,
msg_success=_("EMA recorded"), msg_success=msg_succ.format("EMA"),
) )

Binary file not shown.

View File

@ -16,7 +16,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-08-19 14:01+0200\n" "POT-Creation-Date: 2021-08-19 14:33+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -656,23 +656,23 @@ msgid "Compensation removed"
msgstr "Kompensation entfernt" msgstr "Kompensation entfernt"
#: compensation/views/compensation_views.py:162 #: compensation/views/compensation_views.py:162
#: compensation/views/eco_account_views.py:283 ema/views.py:248 #: compensation/views/eco_account_views.py:283 ema/views.py:249
#: intervention/views.py:93 #: intervention/views.py:93
msgid "Document added" msgid "Document added"
msgstr "Dokument hinzugefügt" msgstr "Dokument hinzugefügt"
#: compensation/views/compensation_views.py:181 #: compensation/views/compensation_views.py:181
#: compensation/views/eco_account_views.py:227 ema/views.py:192 #: compensation/views/eco_account_views.py:227 ema/views.py:193
msgid "State added" msgid "State added"
msgstr "Zustand hinzugefügt" msgstr "Zustand hinzugefügt"
#: compensation/views/compensation_views.py:200 #: compensation/views/compensation_views.py:200
#: compensation/views/eco_account_views.py:246 ema/views.py:211 #: compensation/views/eco_account_views.py:246 ema/views.py:212
msgid "Action added" msgid "Action added"
msgstr "Maßnahme hinzugefügt" msgstr "Maßnahme hinzugefügt"
#: compensation/views/compensation_views.py:219 #: compensation/views/compensation_views.py:219
#: compensation/views/eco_account_views.py:265 ema/views.py:230 #: compensation/views/eco_account_views.py:265 ema/views.py:231
msgid "Deadline added" msgid "Deadline added"
msgstr "Frist/Termin hinzugefügt" msgstr "Frist/Termin hinzugefügt"
@ -692,11 +692,13 @@ msgstr "Ökokonto entfernt"
msgid "Withdraw removed" msgid "Withdraw removed"
msgstr "Abbuchung entfernt" msgstr "Abbuchung entfernt"
#: compensation/views/eco_account_views.py:204 intervention/views.py:376 #: compensation/views/eco_account_views.py:204 ema/views.py:170
#: intervention/views.py:376
msgid "{} unrecorded" msgid "{} unrecorded"
msgstr "{} entzeichnet" msgstr "{} entzeichnet"
#: compensation/views/eco_account_views.py:204 intervention/views.py:376 #: compensation/views/eco_account_views.py:204 ema/views.py:170
#: intervention/views.py:376
msgid "{} recorded" msgid "{} recorded"
msgstr "{} verzeichnet" msgstr "{} verzeichnet"
@ -733,16 +735,8 @@ msgid "Payment funded compensation"
msgstr "Ersatzzahlungsmaßnahme" msgstr "Ersatzzahlungsmaßnahme"
#: ema/views.py:153 #: ema/views.py:153
#, fuzzy
#| msgid "{} removed"
msgid "EMA removed" msgid "EMA removed"
msgstr "{} entfernt" msgstr "EMA entfernt"
#: ema/views.py:173
#, fuzzy
#| msgid "{} recorded"
msgid "EMA recorded"
msgstr "{} verzeichnet"
#: intervention/filters.py:25 #: intervention/filters.py:25
msgid "Show unshared" msgid "Show unshared"
@ -909,6 +903,7 @@ msgid ""
"Eco-account {} is not recorded yet. You can only withdraw from recorded " "Eco-account {} is not recorded yet. You can only withdraw from recorded "
"accounts." "accounts."
msgstr "" msgstr ""
"Ökokonto {} ist noch nicht verzeichnet. Abbuchungen können nur von verzeichneten Ökokonten erfolgen."
#: intervention/forms.py:544 #: intervention/forms.py:544
msgid "" msgid ""
@ -1248,11 +1243,11 @@ msgstr "{} geprüft"
#: konova/utils/messenger.py:71 #: konova/utils/messenger.py:71
msgid "<a href=\"{}\">Check it out</a>" msgid "<a href=\"{}\">Check it out</a>"
msgstr "" msgstr "<a href=\"{}\">Schauen Sie rein</a>"
#: konova/utils/messenger.py:72 #: konova/utils/messenger.py:72
msgid "{} has been checked successfully by user {}! {}" msgid "{} has been checked successfully by user {}! {}"
msgstr "" msgstr "{} wurde erfolgreich vom Nutzer {} geprüft! {}"
#: konova/views.py:138 #: konova/views.py:138
msgid "Document '{}' deleted" msgid "Document '{}' deleted"
@ -2670,6 +2665,9 @@ msgstr ""
msgid "A fontawesome icon field" msgid "A fontawesome icon field"
msgstr "" msgstr ""
#~ msgid "EMA recorded"
#~ msgstr "EMA verzeichnet"
#~ msgid "Edit {}" #~ msgid "Edit {}"
#~ msgstr "Bearbeite {}" #~ msgstr "Bearbeite {}"