Intervention model refactoring
* splits Intervention model into three main components * Intervention (main object) * LegalData (holds legal dates, laws, etc.) * ResponsibilityData (holds organizations and handler) * This way data can be extended more easily in the future * refactors admin.py and usages in templates * introduces UuidModel as a base class for BaseResource
This commit is contained in:
+43
-15
@@ -12,33 +12,61 @@ from django.utils import timezone
|
||||
from django.utils.timezone import now
|
||||
|
||||
from intervention.settings import INTERVENTION_IDENTIFIER_LENGTH, INTERVENTION_IDENTIFIER_TEMPLATE
|
||||
from konova.models import BaseObject, Geometry
|
||||
from konova.models import BaseObject, Geometry, UuidModel
|
||||
from konova.utils.generators import generate_random_string
|
||||
from organisation.models import Organisation
|
||||
from user.models import UserActionLogEntry
|
||||
|
||||
|
||||
class ResponsibilityData(UuidModel):
|
||||
"""
|
||||
Holds intervention data about responsible organizations and their file numbers for this case
|
||||
|
||||
"""
|
||||
registration_office = models.ForeignKey(Organisation, on_delete=models.SET_NULL, null=True, related_name="+")
|
||||
registration_file_number = models.CharField(max_length=1000, blank=True, null=True)
|
||||
conservation_office = models.ForeignKey(Organisation, on_delete=models.SET_NULL, null=True, related_name="+")
|
||||
conservation_file_number = models.CharField(max_length=1000, blank=True, null=True)
|
||||
handler = models.CharField(max_length=500, null=True, blank=True, help_text="Refers to 'Eingriffsverursacher'")
|
||||
|
||||
|
||||
class LegalData(UuidModel):
|
||||
"""
|
||||
Holds intervention legal data such as important dates, laws or responsible handler
|
||||
"""
|
||||
# Refers to "zugelassen am"
|
||||
registration_date = models.DateField(null=True, blank=True, help_text="Refers to 'Zugelassen am'")
|
||||
|
||||
# Refers to "Bestandskraft am"
|
||||
binding_date = models.DateField(null=True, blank=True, help_text="Refers to 'Bestandskraft am'")
|
||||
|
||||
process_type = models.CharField(max_length=500, null=True, blank=True)
|
||||
law = models.CharField(max_length=500, null=True, blank=True)
|
||||
|
||||
|
||||
class Intervention(BaseObject):
|
||||
"""
|
||||
Interventions are e.g. construction sites where nature used to be.
|
||||
"""
|
||||
registration_office = models.ForeignKey(Organisation, on_delete=models.SET_NULL, null=True, related_name="+")
|
||||
registration_file_number = models.CharField(max_length=1000, blank=True, null=True)
|
||||
conservation_office = models.ForeignKey(Organisation, on_delete=models.SET_NULL, null=True, related_name="+")
|
||||
conservation_file_number = models.CharField(max_length=1000, blank=True, null=True)
|
||||
|
||||
process_type = models.CharField(max_length=500, null=True, blank=True)
|
||||
law = models.CharField(max_length=500, null=True, blank=True)
|
||||
handler = models.CharField(max_length=500, null=True, blank=True, help_text="Who is responsible for this intervention?")
|
||||
responsible = models.OneToOneField(
|
||||
ResponsibilityData,
|
||||
on_delete=models.SET_NULL,
|
||||
null=True,
|
||||
blank=True,
|
||||
related_name='+',
|
||||
help_text="Holds data on responsible organizations ('Zulassungsbehörde', 'Eintragungsstelle')"
|
||||
)
|
||||
legal = models.OneToOneField(
|
||||
LegalData,
|
||||
on_delete=models.SET_NULL,
|
||||
null=True,
|
||||
blank=True,
|
||||
related_name='+',
|
||||
help_text="Holds data on legal dates or law"
|
||||
)
|
||||
geometry = models.ForeignKey(Geometry, null=True, blank=True, on_delete=models.SET_NULL)
|
||||
documents = models.ManyToManyField("konova.Document", blank=True)
|
||||
|
||||
# Refers to "zugelassen am"
|
||||
registration_date = models.DateField(null=True, blank=True)
|
||||
|
||||
# Refers to "Bestandskraft am"
|
||||
binding_on = models.DateField(null=True, blank=True)
|
||||
|
||||
# Checks - Refers to "Genehmigen" but optional
|
||||
checked = models.OneToOneField(
|
||||
UserActionLogEntry,
|
||||
|
||||
Reference in New Issue
Block a user