Compensation model refactoring
* splits Intervention model into main components * Compensation (main object) * ResponsibilityData (holds organizations and handler) - same as used for intervention * This way data can be extended more easily in the future * refactors deadlines
This commit is contained in:
parent
e327f03893
commit
e9f25e50ac
@ -12,8 +12,8 @@ from django.utils import timezone
|
||||
from django.utils.timezone import now
|
||||
|
||||
from compensation.settings import COMPENSATION_IDENTIFIER_LENGTH, COMPENSATION_IDENTIFIER_TEMPLATE
|
||||
from intervention.models import Intervention
|
||||
from konova.models import BaseObject, BaseResource, Geometry
|
||||
from intervention.models import Intervention, ResponsibilityData
|
||||
from konova.models import BaseObject, BaseResource, Geometry, UuidModel
|
||||
from konova.utils.generators import generate_random_string
|
||||
from organisation.models import Organisation
|
||||
|
||||
@ -73,18 +73,19 @@ class Compensation(BaseObject):
|
||||
The compensation holds information about which actions have to be performed until which date, who is in charge
|
||||
of this, which legal authority is the point of contact, and so on.
|
||||
"""
|
||||
registration_office = models.ForeignKey(Organisation, on_delete=models.SET_NULL, null=True, related_name="+")
|
||||
conservation_office = models.ForeignKey(Organisation, on_delete=models.SET_NULL, null=True, related_name="+")
|
||||
responsible = models.OneToOneField(
|
||||
ResponsibilityData,
|
||||
on_delete=models.SET_NULL,
|
||||
null=True,
|
||||
blank=True,
|
||||
help_text="Holds data on responsible organizations ('Zulassungsbehörde', 'Eintragungsstelle') and handler",
|
||||
)
|
||||
|
||||
ground_definitions = models.CharField(max_length=500, null=True, blank=True) # ToDo: Need to be M2M to laws!
|
||||
action_definitions = models.CharField(max_length=500, null=True, blank=True) # ToDo: Need to be M2M to laws!
|
||||
before_states = models.ManyToManyField(CompensationState, blank=True, related_name='+', help_text="Refers to 'Ausgangszustand Biotop'")
|
||||
after_states = models.ManyToManyField(CompensationState, blank=True, related_name='+', help_text="Refers to 'Zielzustand Biotop'")
|
||||
actions = models.ManyToManyField(CompensationAction, help_text="Refers to 'Maßnahmen'")
|
||||
|
||||
before_states = models.ManyToManyField(CompensationState, blank=True, related_name='+')
|
||||
after_states = models.ManyToManyField(CompensationState, blank=True, related_name='+')
|
||||
actions = models.ManyToManyField(CompensationAction)
|
||||
|
||||
deadline_creation = models.ForeignKey("konova.Deadline", on_delete=models.SET_NULL, null=True, blank=True, related_name="+")
|
||||
deadline_maintaining = models.ForeignKey("konova.Deadline", on_delete=models.SET_NULL, null=True, blank=True, related_name="+")
|
||||
deadlines = models.ManyToManyField("konova.Deadline", null=True, blank=True, related_name="+")
|
||||
|
||||
geometry = models.ForeignKey(Geometry, null=True, blank=True, on_delete=models.SET_NULL)
|
||||
documents = models.ManyToManyField("konova.Document", blank=True)
|
||||
@ -149,7 +150,5 @@ class EcoAccount(Compensation):
|
||||
An eco account is a kind of 'prepaid' compensation. It can be compared to an account that already has been filled
|
||||
with some kind of currency. From this account one is able to 'withdraw' currency for current projects.
|
||||
"""
|
||||
handler = models.CharField(max_length=500, null=True, blank=True, help_text="Who is responsible for handling the actions")
|
||||
|
||||
# Users having access on this object
|
||||
users = models.ManyToManyField(User)
|
||||
|
@ -7,7 +7,7 @@ Created on: 22.07.21
|
||||
"""
|
||||
from django.contrib import admin
|
||||
|
||||
from konova.models import Geometry, Document
|
||||
from konova.models import Geometry, Document, Deadline
|
||||
|
||||
|
||||
class GeometryAdmin(admin.ModelAdmin):
|
||||
@ -28,5 +28,15 @@ class DocumentAdmin(admin.ModelAdmin):
|
||||
]
|
||||
|
||||
|
||||
class DeadlineAdmin(admin.ModelAdmin):
|
||||
list_display = [
|
||||
"id",
|
||||
"type",
|
||||
"date",
|
||||
"comment",
|
||||
]
|
||||
|
||||
|
||||
admin.site.register(Geometry, GeometryAdmin)
|
||||
admin.site.register(Document, DocumentAdmin)
|
||||
admin.site.register(Deadline, DeadlineAdmin)
|
||||
|
@ -55,3 +55,9 @@ class UserActionLogEntryEnum(BaseEnum):
|
||||
"""
|
||||
CHECKED = "Checked"
|
||||
RECORDED = "Recorded"
|
||||
|
||||
|
||||
class DeadlineTypeEnum(BaseEnum):
|
||||
MAINTAIN = "Maintain"
|
||||
CONTROL = "Control"
|
||||
OTHER = "Other"
|
@ -12,6 +12,7 @@ from django.contrib.auth.models import User
|
||||
from django.contrib.gis.db.models import MultiPolygonField
|
||||
from django.db import models
|
||||
|
||||
from konova.enums import DeadlineTypeEnum
|
||||
from konova.settings import DEFAULT_SRID
|
||||
|
||||
|
||||
@ -59,8 +60,9 @@ class Deadline(BaseResource):
|
||||
"""
|
||||
Defines a deadline, which can be used to define dates with a semantic meaning
|
||||
"""
|
||||
type = models.CharField(max_length=500, null=True, blank=True)
|
||||
type = models.CharField(max_length=255, null=True, blank=True, choices=DeadlineTypeEnum.as_choices(drop_empty_choice=True))
|
||||
date = models.DateField(null=True, blank=True)
|
||||
comment = models.CharField(max_length=1000, null=True, blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.type
|
||||
|
Loading…
Reference in New Issue
Block a user