Compensation detail view

* adds compensation detail view (WIP)
* adds includes dir for related objects, similar to interventions
* adds functionality for
   * adding/removing before_states
   * adding/removing after_states
   * adding/removing deadlines
   * adding/removing documents
* refactors usage of BaseModalForm
   * holds now process_request() in base class for generic usage anywhere
* adds __str__() method for some models
* compensation__action is blank=True now
* renamed tooltips
* adds new routes for state/deadline/document handling inside of compensation/urls.py
* adds precalculation of before/after_states for detail view, so users will see directly if there are missing states
* removes unnecessary link for intervention detail payment
* adds missing tooltips for check and record icon on detail views
* refactors DeadlineTypeEnum into DeadlineType in konova/models.py, just as the django 3.x documentation suggests for model enumerations
* UuidModel id field is not editable anymore in the admin interface
* adds/updates translations
This commit is contained in:
mipel
2021-08-03 13:13:01 +02:00
parent 19f50baae4
commit 816600535a
22 changed files with 1010 additions and 236 deletions
+29 -2
View File
@@ -8,10 +8,10 @@ Created on: 17.11.20
import os
import uuid
from django.utils.translation import gettext_lazy as _
from django.contrib.gis.db.models import MultiPolygonField
from django.db import models
from konova.enums import DeadlineTypeEnum
from konova.settings import DEFAULT_SRID
from user.models import UserActionLogEntry
@@ -23,6 +23,7 @@ class UuidModel(models.Model):
id = models.UUIDField(
primary_key=True,
default=uuid.uuid4,
editable=False,
)
class Meta:
@@ -54,17 +55,43 @@ class BaseObject(BaseResource):
abstract = True
class DeadlineType(models.TextChoices):
"""
Django 3.x way of handling enums for models
"""
FINISHED = "finished", _("Finished")
MAINTAIN = "maintain", _("Maintain")
CONTROL = "control", _("Control")
OTHER = "other", _("Other")
class Deadline(BaseResource):
"""
Defines a deadline, which can be used to define dates with a semantic meaning
"""
type = models.CharField(max_length=255, null=True, blank=True, choices=DeadlineTypeEnum.as_choices(drop_empty_choice=True))
type = models.CharField(max_length=255, null=True, blank=True, choices=DeadlineType.choices)
date = models.DateField(null=True, blank=True)
comment = models.CharField(max_length=1000, null=True, blank=True)
def __str__(self):
return self.type
@property
def type_humanized(self):
""" Returns humanized version of enum
Used for template rendering
Returns:
"""
choices = DeadlineType.choices
for choice in choices:
if choice[0] == self.type:
return choice[1]
return None
class Document(BaseResource):
"""