* introduces bootstrap class form-control for proper html form input rendering
* fixes bug where missing shared users for an entry resulted in a None exception
* adds GenerateInput with template in generate-content-input.html, which provides a generate button for fetching server-side content
* adds/updates translations
This commit is contained in:
2021-09-27 13:57:56 +02:00
parent 78ef1b79af
commit ea0a07890c
12 changed files with 277 additions and 193 deletions

View File

@@ -9,13 +9,14 @@ from dal import autocomplete
from django import forms
from django.contrib.auth.models import User
from django.db import transaction
from django.urls import reverse
from django.urls import reverse, reverse_lazy
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from codelist.models import KonovaCode
from codelist.settings import CODELIST_PROCESS_TYPE_ID, CODELIST_LAW_ID, \
CODELIST_REGISTRATION_OFFICE_ID, CODELIST_CONSERVATION_OFFICE_ID
from intervention.inputs import GenerateInput
from intervention.models import Intervention, LegalData, ResponsibilityData
from konova.forms import BaseForm, SimpleGeomForm
from user.models import UserActionLogEntry, UserAction
@@ -27,6 +28,12 @@ class NewInterventionForm(BaseForm):
label_suffix="",
max_length=255,
help_text=_("Generated automatically"),
widget=GenerateInput(
attrs={
"class": "form-control",
"url": reverse_lazy("intervention:new-id"),
}
)
)
title = forms.CharField(
label=_("Title"),
@@ -35,7 +42,8 @@ class NewInterventionForm(BaseForm):
max_length=255,
widget=forms.TextInput(
attrs={
"placeholder": _("Construction XY; Location ABC")
"placeholder": _("Construction XY; Location ABC"),
"class": "form-control",
}
)
)
@@ -108,7 +116,8 @@ class NewInterventionForm(BaseForm):
required=False,
widget=forms.TextInput(
attrs={
"placeholder": _("ZB-123/ABC.456")
"placeholder": _("ZB-123/ABC.456"),
"class": "form-control",
}
)
)
@@ -119,7 +128,8 @@ class NewInterventionForm(BaseForm):
required=False,
widget=forms.TextInput(
attrs={
"placeholder": _("ETS-123/ABC.456")
"placeholder": _("ETS-123/ABC.456"),
"class": "form-control",
}
)
)
@@ -131,7 +141,8 @@ class NewInterventionForm(BaseForm):
help_text=_("Who performs the intervention"),
widget=forms.TextInput(
attrs={
"placeholder": _("Company Mustermann")
"placeholder": _("Company Mustermann"),
"class": "form-control",
}
)
)
@@ -142,6 +153,7 @@ class NewInterventionForm(BaseForm):
widget=forms.DateInput(
attrs={
"type": "date",
"class": "form-control",
},
format="%d.%m.%Y"
)
@@ -153,6 +165,7 @@ class NewInterventionForm(BaseForm):
widget=forms.DateInput(
attrs={
"type": "date",
"class": "form-control",
},
format="%d.%m.%Y"
)
@@ -165,14 +178,11 @@ class NewInterventionForm(BaseForm):
widget=forms.Textarea(
attrs={
"rows": 5,
"class": "w-100"
"class": "form-control"
}
)
)
# Define w-100 for all form fields
full_width_fields = True
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.form_title = _("New intervention")
@@ -281,12 +291,10 @@ class EditInterventionForm(NewInterventionForm):
"binding_date": bind_date,
"comment": self.instance.comment,
}
disabled_fields = [
"identifier",
]
disabled_fields = []
self.load_initial_data(
form_data,
disabled_fields,
disabled_fields
)
def save(self, user: User, geom_form: SimpleGeomForm):

View File

@@ -31,7 +31,8 @@ class ShareInterventionModalForm(BaseModalForm):
required=False,
widget=TextToClipboardInput(
attrs={
"readonly": True
"readonly": True,
"class": "form-control",
}
)
)
@@ -109,6 +110,7 @@ class NewRevocationModalForm(BaseModalForm):
attrs={
"type": "date",
"data-provide": "datepicker",
"class": "form-control",
},
format="%d.%m.%Y"
)
@@ -120,7 +122,7 @@ class NewRevocationModalForm(BaseModalForm):
help_text=_("Must be smaller than 15 Mb"),
widget=forms.FileInput(
attrs={
"class": "w-75"
"class": "form-control-file"
}
)
)
@@ -134,13 +136,11 @@ class NewRevocationModalForm(BaseModalForm):
attrs={
"cols": 30,
"rows": 5,
"class": "form-control",
}
)
)
# Define w-100 for all form fields
full_width_fields = True
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.form_title = _("Add revocation")
@@ -274,6 +274,11 @@ class NewDeductionModalForm(BaseModalForm):
label=_("Surface"),
label_suffix="",
help_text=_("in m²"),
widget=forms.NumberInput(
attrs={
"class": "form-control",
}
)
)
intervention = forms.ModelChoiceField(
label=_("Intervention"),
@@ -289,9 +294,6 @@ class NewDeductionModalForm(BaseModalForm):
),
)
# Define w-100 for all form fields
full_width_fields = True
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.form_title = _("New Deduction")