diff --git a/intervention/admin.py b/intervention/admin.py index 6d0df042..4adf095e 100644 --- a/intervention/admin.py +++ b/intervention/admin.py @@ -1,17 +1,38 @@ from django.contrib import admin -from intervention.models import Intervention +from intervention.models import Intervention, ResponsibilityData, LegalData class InterventionAdmin(admin.ModelAdmin): list_display = [ "id", "title", - "process_type", - "handler", "created_on", "deleted_on", ] +class ResponsibilityAdmin(admin.ModelAdmin): + list_display = [ + "id", + "registration_office", + "registration_file_number", + "conservation_office", + "conservation_file_number", + "handler", + ] + + +class LegalAdmin(admin.ModelAdmin): + list_display = [ + "id", + "process_type", + "law", + "registration_date", + "binding_date", + ] + + admin.site.register(Intervention, InterventionAdmin) +admin.site.register(ResponsibilityData, ResponsibilityAdmin) +admin.site.register(LegalData, LegalAdmin) diff --git a/intervention/models.py b/intervention/models.py index 5280c840..67fd83a4 100644 --- a/intervention/models.py +++ b/intervention/models.py @@ -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, diff --git a/intervention/templates/intervention/detail/view.html b/intervention/templates/intervention/detail/view.html index e19d3c16..7354bca1 100644 --- a/intervention/templates/intervention/detail/view.html +++ b/intervention/templates/intervention/detail/view.html @@ -64,31 +64,31 @@