2021-11-15 17:19:06 +01:00
|
|
|
"""
|
|
|
|
Author: Michel Peltriaux
|
|
|
|
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
|
|
|
|
Contact: michel.peltriaux@sgdnord.rlp.de
|
|
|
|
Created on: 15.11.21
|
|
|
|
|
|
|
|
"""
|
|
|
|
from django.db import models
|
2022-03-03 12:05:22 +01:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2021-11-15 17:19:06 +01:00
|
|
|
|
|
|
|
from codelist.models import KonovaCode
|
2022-03-03 12:05:22 +01:00
|
|
|
from codelist.settings import CODELIST_CONSERVATION_OFFICE_ID, CODELIST_REGISTRATION_OFFICE_ID, \
|
2022-03-03 12:09:09 +01:00
|
|
|
CODELIST_HANDLER_ID
|
2021-11-15 17:19:06 +01:00
|
|
|
from konova.models import UuidModel
|
2022-03-03 12:09:09 +01:00
|
|
|
from konova.utils.message_templates import UNKNOWN, NO_DETAILS
|
2021-11-15 17:19:06 +01:00
|
|
|
|
|
|
|
|
2022-03-03 12:05:22 +01:00
|
|
|
class Handler(UuidModel):
|
|
|
|
""" The handler of an entry
|
|
|
|
|
|
|
|
Refers to 'Eingriffsverursacher' or 'Maßnahmenträger'
|
|
|
|
|
|
|
|
"""
|
|
|
|
type = models.ForeignKey(
|
|
|
|
KonovaCode,
|
|
|
|
on_delete=models.SET_NULL,
|
|
|
|
null=True,
|
|
|
|
blank=True,
|
|
|
|
limit_choices_to={
|
2022-03-03 12:09:09 +01:00
|
|
|
"code_lists__in": [CODELIST_HANDLER_ID],
|
2022-03-03 12:05:22 +01:00
|
|
|
"is_selectable": True,
|
|
|
|
"is_archived": False,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
detail = models.CharField(
|
|
|
|
max_length=500,
|
|
|
|
null=True,
|
|
|
|
blank=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
def __str__(self):
|
2022-03-03 12:09:09 +01:00
|
|
|
detail = self.detail or NO_DETAILS
|
|
|
|
_type = self.type.long_name if self.type is not None else UNKNOWN
|
2022-03-03 12:05:22 +01:00
|
|
|
return f'{_type}, {detail}'
|
|
|
|
|
|
|
|
|
2021-11-15 17:19:06 +01:00
|
|
|
class Responsibility(UuidModel):
|
|
|
|
"""
|
|
|
|
Holds intervention data about responsible organizations and their file numbers for this case
|
|
|
|
|
|
|
|
"""
|
|
|
|
registration_office = models.ForeignKey(
|
|
|
|
KonovaCode,
|
|
|
|
on_delete=models.SET_NULL,
|
|
|
|
null=True,
|
|
|
|
related_name="+",
|
|
|
|
blank=True,
|
|
|
|
limit_choices_to={
|
|
|
|
"code_lists__in": [CODELIST_REGISTRATION_OFFICE_ID],
|
|
|
|
"is_selectable": True,
|
|
|
|
"is_archived": False,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
registration_file_number = models.CharField(max_length=1000, blank=True, null=True)
|
|
|
|
conservation_office = models.ForeignKey(
|
|
|
|
KonovaCode,
|
|
|
|
on_delete=models.SET_NULL,
|
|
|
|
null=True,
|
|
|
|
related_name="+",
|
|
|
|
blank=True,
|
|
|
|
limit_choices_to={
|
|
|
|
"code_lists__in": [CODELIST_CONSERVATION_OFFICE_ID],
|
|
|
|
"is_selectable": True,
|
|
|
|
"is_archived": False,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
conservation_file_number = models.CharField(max_length=1000, blank=True, null=True)
|
2022-03-03 12:05:22 +01:00
|
|
|
handler = models.ForeignKey(
|
|
|
|
Handler,
|
|
|
|
null=True,
|
|
|
|
blank=True,
|
|
|
|
help_text="Refers to 'Eingriffsverursacher' or 'Maßnahmenträger'",
|
|
|
|
on_delete=models.SET_NULL,
|
|
|
|
)
|
2021-11-15 17:19:06 +01:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return "ZB: {} | ETS: {} | Handler: {}".format(
|
|
|
|
self.registration_office,
|
|
|
|
self.conservation_office,
|
2022-03-03 12:05:22 +01:00
|
|
|
str(self.handler)
|
2021-11-15 17:19:06 +01:00
|
|
|
)
|