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:
mipel
2021-07-26 11:29:05 +02:00
parent 4fb2ef26d0
commit a6c51aede6
12 changed files with 174 additions and 64 deletions

View File

@@ -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"),

View File

@@ -194,4 +194,13 @@ input:focus, textarea:focus, select:focus{
.page-item.active > .page-link{
background-color: var(--rlp-red);
border-color: var(--rlp-red);
}
.label-required{
color: var(--rlp-red);
}
.scroll-300{
max-height: 300px;
overflow: auto;
}

View File

@@ -53,6 +53,7 @@ INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.gis',
'django.contrib.humanize',
'simple_sso.sso_server',
'django_tables2',
'bootstrap_modal_forms',
@@ -143,9 +144,12 @@ AUTH_PASSWORD_VALIDATORS = [
# Internationalization
# https://docs.djangoproject.com/en/3.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
LANGUAGE_CODE = 'de'
USE_THOUSAND_SEPARATOR = True
DEFAULT_DATE_TIME_FORMAT = '%d.%m.%Y %H:%M:%S'
DATE_FORMAT = '%d.%m.%Y'
TIME_ZONE = 'Europe/Berlin'