You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
konova/intervention/models/responsibility.py

91 lines
2.5 KiB
Python

"""
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
from django.utils.translation import gettext_lazy as _
from codelist.models import KonovaCode
from codelist.settings import CODELIST_CONSERVATION_OFFICE_ID, CODELIST_REGISTRATION_OFFICE_ID, \
CODELIST_COMPENSATION_HANDLER_ID
from konova.models import UuidModel
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={
"code_lists__in": [CODELIST_COMPENSATION_HANDLER_ID],
"is_selectable": True,
"is_archived": False,
}
)
detail = models.CharField(
max_length=500,
null=True,
blank=True,
)
def __str__(self):
detail = self.detail or _("no further details")
_type = self.type.long_name if self.type is not None else None
return f'{_type}, {detail}'
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)
handler = models.ForeignKey(
Handler,
null=True,
blank=True,
help_text="Refers to 'Eingriffsverursacher' or 'Maßnahmenträger'",
on_delete=models.SET_NULL,
)
def __str__(self):
return "ZB: {} | ETS: {} | Handler: {}".format(
self.registration_office,
self.conservation_office,
str(self.handler)
)