Payments add modal form
* adds help texts to add payment form * adds removing button for payments * refactors user fetching into BaseForm * adds generic RemoveModalForm which is intended to be used for every modal form which shall remove something * adds translations * removes unused html * prepares payment amount field to be able to process german inputs like '1.000,50' which is not the international default
This commit is contained in:
@@ -29,6 +29,7 @@ class BaseForm(forms.Form):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.instance = kwargs.pop("instance", None)
|
||||
self.user = kwargs.pop("user", None)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
@abstractmethod
|
||||
@@ -137,6 +138,34 @@ class SimpleGeomForm(BaseForm):
|
||||
self.area = geom.area
|
||||
|
||||
|
||||
class RemoveModalForm(BaseModalForm):
|
||||
""" Generic removing modal form
|
||||
|
||||
Can be used for anything, where removing shall be confirmed by the user a second time.
|
||||
|
||||
"""
|
||||
confirm = forms.BooleanField(
|
||||
label=_("Confirm"),
|
||||
label_suffix=_(""),
|
||||
widget=forms.CheckboxInput(),
|
||||
required=True,
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.form_title = _("Remove")
|
||||
self.form_caption = _("Are you sure?")
|
||||
|
||||
def save(self):
|
||||
if hasattr(self.instance, "deleted_on"):
|
||||
self.instance.deleted_on = timezone.now()
|
||||
self.instance.deleted_by = self.user
|
||||
self.instance.save()
|
||||
else:
|
||||
# If the class does not provide restorable delete functionality, we must delete the entry finally
|
||||
self.instance.delete()
|
||||
|
||||
|
||||
class RemoveDocumentForm(BaseModalForm):
|
||||
confirm = forms.BooleanField(
|
||||
label=_("Confirm"),
|
||||
|
||||
Reference in New Issue
Block a user