* adds NewEcoAccountForm
* refactors NewCompensationForm into AbstractCompensationForm so main fields can be reused again
* fixes template bug in account detail view where the amount of deductions has been displayed instead of the available rest
* refactors _generate_new_identifier() into generate_new_identifier()
* refactors get_available_rest() into returning both, the total and relative amount
* improves saving of SimpleGeometryForm()
* adds/updates translations
This commit is contained in:
mipel
2021-10-05 16:35:24 +02:00
parent 0342d96a1f
commit ac665c9268
16 changed files with 416 additions and 174 deletions

View File

@@ -285,18 +285,17 @@ class SimpleGeomForm(BaseForm):
Returns:
"""
if self.instance.geometry is None:
geometry = Geometry.objects.create(
geom=self.cleaned_data.get("geom", MultiPolygon(srid=DEFAULT_SRID)),
created=action,
)
self.instance.geometry = geometry
self.instance.save()
else:
try:
geometry = self.instance.geometry
geometry.geom = self.cleaned_data.get("geom", MultiPolygon(srid=DEFAULT_SRID))
geometry.modified = action
geometry.save()
except (AttributeError) as e:
# No geometry or linked instance holding a geometry exist --> create a new one!
geometry = Geometry.objects.create(
geom=self.cleaned_data.get("geom", MultiPolygon(srid=DEFAULT_SRID)),
created=action,
)
return geometry

View File

@@ -21,7 +21,7 @@ class Command(BaseCommand):
len_ids = len(identifiers)
while len_ids < max_iterations:
tmp_intervention = Intervention()
_id = tmp_intervention._generate_new_identifier()
_id = tmp_intervention.generate_new_identifier()
len_ids = len(identifiers)
if _id not in identifiers:
if len_ids % (max_iterations/5) == 0:

View File

@@ -153,7 +153,7 @@ class BaseObject(BaseResource):
else:
return User.objects.none()
def _generate_new_identifier(self) -> str:
def generate_new_identifier(self) -> str:
""" Generates a new identifier for the intervention object
Returns: