[Compensation] Conservation office #5
* keeps responsible data in compensation model for potential future purposes * refactors registration_office and conservation_office to map onto KonovaCodes instead of own Organization model * adds str_as_office property-method to KonovaCode to provide an easy way of rendering template data * adds missing highlighting in case of missing information about registration office and conservation office
This commit is contained in:
		
							parent
							
								
									c1aea16fba
								
							
						
					
					
						commit
						6b70ee8ba9
					
				@ -57,6 +57,13 @@ class KonovaCode(models.Model):
 | 
			
		||||
            ret_val += " ({})".format(self.short_name)
 | 
			
		||||
        return ret_val
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def str_as_office(self):
 | 
			
		||||
        ret_val = self.long_name
 | 
			
		||||
        if self.parent:
 | 
			
		||||
            ret_val += ", " + self.parent.long_name
 | 
			
		||||
        return ret_val
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class KonovaCodeList(models.Model):
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
@ -52,9 +52,9 @@
 | 
			
		||||
                            {% endif %}
 | 
			
		||||
                        </td>
 | 
			
		||||
                    </tr>
 | 
			
		||||
                    <tr>
 | 
			
		||||
                    <tr {% if not obj.responsible.conservation_office %}class="alert alert-danger" title="{% trans 'Missing' %}" {% endif %}>
 | 
			
		||||
                        <th scope="row">{% trans 'Conservation office' %}</th>
 | 
			
		||||
                        <td class="align-middle">{{obj.responsible.conservation_office|default_if_none:""}}</td>
 | 
			
		||||
                        <td class="align-middle">{{obj.responsible.conservation_office.str_as_office|default_if_none:""}}</td>
 | 
			
		||||
                    </tr>
 | 
			
		||||
                    <tr {% if not obj.responsible.conservation_file_number %}class="alert alert-danger" title="{% trans 'Missing' %}" {% endif %}>
 | 
			
		||||
                        <th scope="row">{% trans 'Conversation office file number' %}</th>
 | 
			
		||||
 | 
			
		||||
@ -38,9 +38,9 @@
 | 
			
		||||
                            {% endif %}
 | 
			
		||||
                        </td>
 | 
			
		||||
                    </tr>
 | 
			
		||||
                    <tr>
 | 
			
		||||
                    <tr {% if not obj.responsible.conservation_office %}class="alert alert-danger" title="{% trans 'Missing' %}" {% endif %}>
 | 
			
		||||
                        <th scope="row">{% trans 'Conservation office' %}</th>
 | 
			
		||||
                        <td class="align-middle">{{obj.responsible.conservation_office|default_if_none:""}}</td>
 | 
			
		||||
                        <td class="align-middle">{{obj.responsible.conservation_office.str_as_office|default_if_none:""}}</td>
 | 
			
		||||
                    </tr>
 | 
			
		||||
                    <tr {% if not obj.responsible.conservation_file_number %}class="alert alert-danger" title="{% trans 'Missing' %}" {% endif %}>
 | 
			
		||||
                        <th scope="row">{% trans 'Conversation office file number' %}</th>
 | 
			
		||||
 | 
			
		||||
@ -10,6 +10,8 @@ from django.contrib.gis.db import models
 | 
			
		||||
from django.utils.timezone import localtime
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
 | 
			
		||||
from codelist.models import KonovaCode
 | 
			
		||||
from codelist.settings import CODELIST_REGISTRATION_OFFICE_ID, CODELIST_CONSERVATION_OFFICE_ID
 | 
			
		||||
from konova.models import BaseObject, Geometry, UuidModel, BaseResource
 | 
			
		||||
from konova.settings import DEFAULT_SRID_RLP, LANIS_LINK_TEMPLATE
 | 
			
		||||
from konova.sub_settings.django_settings import DEFAULT_DATE_TIME_FORMAT
 | 
			
		||||
@ -23,11 +25,33 @@ 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="+", blank=True)
 | 
			
		||||
    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(Organisation, on_delete=models.SET_NULL, null=True, related_name="+", blank=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.CharField(max_length=500, null=True, blank=True, help_text="Refers to 'Eingriffsverursacher'")
 | 
			
		||||
    handler = models.CharField(max_length=500, null=True, blank=True, help_text="Refers to 'Eingriffsverursacher' or 'Maßnahmenträger'")
 | 
			
		||||
 | 
			
		||||
    def __str__(self):
 | 
			
		||||
        return "ZB: {} | ETS: {} | Handler: {}".format(
 | 
			
		||||
 | 
			
		||||
@ -38,17 +38,17 @@
 | 
			
		||||
                        <th scope="row">{% trans 'Law' %}</th>
 | 
			
		||||
                        <td class="align-middle">{{intervention.legal.law|default_if_none:""}}</td>
 | 
			
		||||
                    </tr>
 | 
			
		||||
                    <tr>
 | 
			
		||||
                    <tr {% if not intervention.responsible.registration_office %}class="alert alert-danger" title="{% trans 'Missing' %}" {% endif %}>
 | 
			
		||||
                        <th scope="row">{% trans 'Registration office' %}</th>
 | 
			
		||||
                        <td class="align-middle">{{intervention.responsible.registration_office|default_if_none:""}}</td>
 | 
			
		||||
                        <td class="align-middle">{{intervention.responsible.registration_office.str_as_office|default_if_none:""}}</td>
 | 
			
		||||
                    </tr>
 | 
			
		||||
                    <tr {% if not intervention.responsible.registration_file_number %}class="alert alert-danger" title="{% trans 'Missing' %}" {% endif %}>
 | 
			
		||||
                        <th scope="row">{% trans 'Registration office file number' %}</th>
 | 
			
		||||
                        <td class="align-middle">{{intervention.responsible.registration_file_number|default_if_none:""}}</td>
 | 
			
		||||
                    </tr>
 | 
			
		||||
                    <tr>
 | 
			
		||||
                    <tr {% if not intervention.responsible.conservation_office %}class="alert alert-danger" title="{% trans 'Missing' %}" {% endif %}>
 | 
			
		||||
                        <th scope="row">{% trans 'Conservation office' %}</th>
 | 
			
		||||
                        <td class="align-middle">{{intervention.responsible.conservation_office|default_if_none:""}}</td>
 | 
			
		||||
                        <td class="align-middle">{{intervention.responsible.conservation_office.str_as_office|default_if_none:""}}</td>
 | 
			
		||||
                    </tr>
 | 
			
		||||
                    <tr {% if not intervention.responsible.conservation_file_number %}class="alert alert-danger" title="{% trans 'Missing' %}" {% endif %}>
 | 
			
		||||
                        <th scope="row">{% trans 'Conversation office file number' %}</th>
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user