Merge pull request '88_biotope_codes' (#96) from 88_biotope_codes into master

Reviewed-on: SGD-Nord/konova#96
This commit is contained in:
mpeltriaux 2022-01-31 14:07:33 +01:00
commit c09ed3bb09
26 changed files with 411 additions and 128 deletions

View File

@ -14,7 +14,8 @@ from django.db.models import QuerySet
from api.utils.serializer.serializer import AbstractModelAPISerializer
from codelist.models import KonovaCode
from codelist.settings import CODELIST_COMPENSATION_ACTION_ID, CODELIST_BIOTOPES_ID, CODELIST_PROCESS_TYPE_ID, \
CODELIST_LAW_ID, CODELIST_REGISTRATION_OFFICE_ID, CODELIST_CONSERVATION_OFFICE_ID
CODELIST_LAW_ID, CODELIST_REGISTRATION_OFFICE_ID, CODELIST_CONSERVATION_OFFICE_ID, \
CODELIST_COMPENSATION_ACTION_DETAIL_ID, CODELIST_BIOTOPES_EXTRA_CODES_ID
from compensation.models import CompensationAction, UnitChoices, CompensationState
from intervention.models import Responsibility, Legal
from konova.models import Deadline, DeadlineType
@ -323,6 +324,9 @@ class AbstractCompensationAPISerializerV1Mixin:
states = []
for entry in states_data:
biotope_type = entry["biotope"]
biotope_details = [
self._konova_code_from_json(e, CODELIST_BIOTOPES_EXTRA_CODES_ID) for e in entry["biotope_details"]
]
surface = float(entry["surface"])
# Check on validity
@ -331,22 +335,22 @@ class AbstractCompensationAPISerializerV1Mixin:
# If this exact data is already existing, we do not create it new. Instead put it's id in the list of
# entries, we will use to set the new actions
pre_existing_state = states_manager.filter(
state = states_manager.filter(
biotope_type__atom_id=biotope_type,
surface=surface,
).exclude(
id__in=states
).first()
if pre_existing_state is not None:
states.append(pre_existing_state.id)
if state is not None:
states.append(state.id)
else:
# Create and add id to list
new_state = CompensationState.objects.create(
state = CompensationState.objects.create(
biotope_type=self._konova_code_from_json(biotope_type, CODELIST_BIOTOPES_ID),
surface=surface
)
states.append(new_state.id)
states.append(state.id)
state.biotope_type_details.set(biotope_details)
states_manager.set(states)
return obj
@ -364,6 +368,9 @@ class AbstractCompensationAPISerializerV1Mixin:
actions = []
for entry in actions_data:
action = entry["action"]
action_details = [
self._konova_code_from_json(e, CODELIST_COMPENSATION_ACTION_DETAIL_ID) for e in entry["action_details"]
]
amount = float(entry["amount"])
unit = entry["unit"]
comment = entry["comment"]
@ -376,7 +383,7 @@ class AbstractCompensationAPISerializerV1Mixin:
# If this exact data is already existing, we do not create it new. Instead put it's id in the list of
# entries, we will use to set the new actions
pre_existing_action = obj.actions.filter(
action_entry = obj.actions.filter(
action_type__atom_id=action,
amount=amount,
unit=unit,
@ -384,17 +391,19 @@ class AbstractCompensationAPISerializerV1Mixin:
).exclude(
id__in=actions
).first()
if pre_existing_action is not None:
actions.append(pre_existing_action.id)
if action_entry is not None:
actions.append(action_entry.id)
else:
# Create and add id to list
new_action = CompensationAction.objects.create(
action_entry = CompensationAction.objects.create(
action_type=self._konova_code_from_json(action, CODELIST_COMPENSATION_ACTION_ID),
amount=amount,
unit=unit,
comment=comment,
)
actions.append(new_action.id)
actions.append(action_entry.id)
action_entry.action_type_details.set(action_details)
obj.actions.set(actions)
return obj
@ -410,6 +419,9 @@ class AbstractCompensationAPISerializerV1Mixin:
return [
{
"biotope": self._konova_code_to_json(entry.biotope_type),
"biotope_details": [
self._konova_code_to_json(detail) for detail in entry.biotope_type_details.all()
],
"surface": entry.surface,
}
for entry in qs
@ -427,6 +439,9 @@ class AbstractCompensationAPISerializerV1Mixin:
return [
{
"action": self._konova_code_to_json(entry.action_type),
"action_details": [
self._konova_code_to_json(detail) for detail in entry.action_type_details.all()
],
"amount": entry.amount,
"unit": entry.unit,
"comment": entry.comment,

View File

@ -13,7 +13,8 @@ from codelist.models import KonovaCode, KonovaCodeList
from codelist.settings import CODELIST_INTERVENTION_HANDLER_ID, CODELIST_CONSERVATION_OFFICE_ID, \
CODELIST_REGISTRATION_OFFICE_ID, CODELIST_BIOTOPES_ID, CODELIST_LAW_ID, CODELIST_COMPENSATION_HANDLER_ID, \
CODELIST_COMPENSATION_ACTION_ID, CODELIST_COMPENSATION_ACTION_CLASS_ID, CODELIST_COMPENSATION_ADDITIONAL_TYPE_ID, \
CODELIST_BASE_URL, CODELIST_PROCESS_TYPE_ID
CODELIST_BASE_URL, CODELIST_PROCESS_TYPE_ID, CODELIST_BIOTOPES_EXTRA_CODES_ID, \
CODELIST_COMPENSATION_ACTION_DETAIL_ID
from konova.management.commands.setup import BaseKonovaCommand
from konova.settings import PROXIES
@ -33,10 +34,12 @@ class Command(BaseKonovaCommand):
CODELIST_CONSERVATION_OFFICE_ID,
CODELIST_REGISTRATION_OFFICE_ID,
CODELIST_BIOTOPES_ID,
CODELIST_BIOTOPES_EXTRA_CODES_ID,
CODELIST_LAW_ID,
CODELIST_COMPENSATION_HANDLER_ID,
CODELIST_COMPENSATION_ACTION_ID,
CODELIST_COMPENSATION_ACTION_CLASS_ID,
CODELIST_COMPENSATION_ACTION_DETAIL_ID,
CODELIST_COMPENSATION_ADDITIONAL_TYPE_ID,
CODELIST_PROCESS_TYPE_ID,
]

View File

@ -14,11 +14,13 @@ CODELIST_INTERVENTION_HANDLER_ID = 903 # CLMassnahmeträger
CODELIST_CONSERVATION_OFFICE_ID = 907 # CLNaturschutzbehörden
CODELIST_REGISTRATION_OFFICE_ID = 1053 # CLZulassungsbehörden
CODELIST_BIOTOPES_ID = 974 # CL_EIV_Biotoptypen
CODELIST_BIOTOPES_EXTRA_CODES_ID = 975 # CLZusatzbezeichnung
CODELIST_LAW_ID = 1048 # CLVerfahrensrecht
CODELIST_PROCESS_TYPE_ID = 44382 # CLVerfahrenstyp
CODELIST_COMPENSATION_HANDLER_ID = 1052 # CLEingreifer
CODELIST_COMPENSATION_ACTION_ID = 1026 # CLMassnahmedetail
CODELIST_COMPENSATION_ACTION_DETAIL_ID = 1035 # CLZusatzmerkmal
CODELIST_COMPENSATION_ACTION_CLASS_ID = 1034 # CLMassnahmeklasse
CODELIST_COMPENSATION_ADDITIONAL_TYPE_ID = 1028 # CLMassnahmetyp, CEF and stuff
CODELIST_COMPENSATION_FUNDING_ID = 1049 # CLKombimassnahme

View File

@ -14,7 +14,8 @@ from django.shortcuts import render
from django.utils.translation import pgettext_lazy as _con, gettext_lazy as _
from codelist.models import KonovaCode
from codelist.settings import CODELIST_BIOTOPES_ID, CODELIST_COMPENSATION_ACTION_ID
from codelist.settings import CODELIST_BIOTOPES_ID, CODELIST_COMPENSATION_ACTION_ID, CODELIST_BIOTOPES_EXTRA_CODES_ID, \
CODELIST_COMPENSATION_ACTION_DETAIL_ID
from compensation.models import CompensationDocument, EcoAccountDocument
from konova.contexts import BaseContext
from konova.forms import BaseModalForm, NewDocumentForm
@ -127,6 +128,23 @@ class NewStateModalForm(BaseModalForm):
}
),
)
biotope_extra = forms.ModelMultipleChoiceField(
label=_("Biotope additional type"),
label_suffix="",
required=False,
help_text=_("Select an additional biotope type"),
queryset=KonovaCode.objects.filter(
is_archived=False,
is_leaf=True,
code_lists__in=[CODELIST_BIOTOPES_EXTRA_CODES_ID],
),
widget=autocomplete.ModelSelect2Multiple(
url="codes-biotope-extra-type-autocomplete",
attrs={
"data-placeholder": _("Biotope additional type"),
}
),
)
surface = forms.DecimalField(
min_value=0.00,
decimal_places=2,
@ -283,6 +301,23 @@ class NewActionModalForm(BaseModalForm):
}
),
)
action_type_details = forms.ModelMultipleChoiceField(
label=_("Action Type detail"),
label_suffix="",
required=False,
help_text=_("Select the action type detail"),
queryset=KonovaCode.objects.filter(
is_archived=False,
is_leaf=True,
code_lists__in=[CODELIST_COMPENSATION_ACTION_DETAIL_ID],
),
widget=autocomplete.ModelSelect2Multiple(
url="codes-compensation-action-detail-autocomplete",
attrs={
"data-placeholder": _("Action Type detail"),
}
),
)
unit = forms.ChoiceField(
label=_("Unit"),
label_suffix="",

View File

@ -9,7 +9,7 @@ from django.db import models
from django.utils.translation import gettext_lazy as _
from codelist.models import KonovaCode
from codelist.settings import CODELIST_COMPENSATION_ACTION_ID
from codelist.settings import CODELIST_COMPENSATION_ACTION_ID, CODELIST_COMPENSATION_ACTION_DETAIL_ID
from compensation.managers import CompensationActionManager
from konova.models import BaseResource
@ -39,7 +39,18 @@ class CompensationAction(BaseResource):
"code_lists__in": [CODELIST_COMPENSATION_ACTION_ID],
"is_selectable": True,
"is_archived": False,
}
},
related_name='+',
)
action_type_details = models.ManyToManyField(
KonovaCode,
blank=True,
limit_choices_to={
"code_lists__in": [CODELIST_COMPENSATION_ACTION_DETAIL_ID],
"is_selectable": True,
"is_archived": False,
},
related_name='+',
)
amount = models.FloatField()
unit = models.CharField(max_length=100, null=True, blank=True, choices=UnitChoices.choices)

View File

@ -95,6 +95,8 @@ class AbstractCompensation(BaseObject, GeoReferencedMixin):
comment=form_data["comment"],
created=user_action,
)
comp_action_details = form_data["action_type_details"]
comp_action.action_type_details.set(comp_action_details)
self.actions.add(comp_action)
return comp_action
@ -114,6 +116,8 @@ class AbstractCompensation(BaseObject, GeoReferencedMixin):
biotope_type=form_data["biotope_type"],
surface=form_data["surface"],
)
state_additional_types = form_data["biotope_extra"]
state.biotope_type_details.set(state_additional_types)
if is_before_state:
self.before_states.add(state)
else:

View File

@ -8,7 +8,7 @@ Created on: 16.11.21
from django.db import models
from codelist.models import KonovaCode
from codelist.settings import CODELIST_BIOTOPES_ID
from codelist.settings import CODELIST_BIOTOPES_ID, CODELIST_BIOTOPES_EXTRA_CODES_ID
from compensation.managers import CompensationStateManager
from konova.models import UuidModel
@ -26,7 +26,18 @@ class CompensationState(UuidModel):
"code_lists__in": [CODELIST_BIOTOPES_ID],
"is_selectable": True,
"is_archived": False,
}
},
related_name='+',
)
biotope_type_details = models.ManyToManyField(
KonovaCode,
blank=True,
limit_choices_to={
"code_lists__in": [CODELIST_BIOTOPES_EXTRA_CODES_ID],
"is_selectable": True,
"is_archived": False,
},
related_name='+',
)
surface = models.FloatField()

View File

@ -24,9 +24,12 @@
<table class="table table-hover">
<thead>
<tr>
<th scope="col">
<th class="w-25" scope="col">
{% trans 'Action type' %}
</th>
<th class="w-25" scope="col">
{% trans 'Action type details' %}
</th>
<th scope="col">
{% trans 'Amount' context 'Compensation' %}
</th>
@ -46,9 +49,14 @@
<td class="align-middle">
{{ action.action_type }}
</td>
<td class="align-middle">
{% for detail in action.action_type_details.all %}
<div class="mb-2" title="{{detail}}">{{detail.long_name}}</div>
{% endfor %}
</td>
<td class="align-middle">{{ action.amount|floatformat:2|intcomma }} {{ action.unit_humanize }}</td>
<td class="align-middle">{{ action.comment|default_if_none:"" }}</td>
<td>
<td class="align-middle">
{% if is_default_member and has_access %}
<button data-form-url="{% url 'compensation:action-remove' obj.id action.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove action' %}">
{% fa5_icon 'trash' %}

View File

@ -29,9 +29,12 @@
<table class="table table-hover">
<thead>
<tr>
<th scope="col">
<th class="w-25" scope="col">
{% trans 'Biotope type' %}
</th>
<th class="w-25" scope="col">
{% trans 'Biotope additional type' %}
</th>
<th scope="col">
{% trans 'Surface' %}
</th>
@ -48,8 +51,15 @@
<td class="align-middle">
{{ state.biotope_type }}
</td>
<td class="align-middle">
{% for biotope_extra in state.biotope_type_details.all %}
<div class="mb-2" title="{{ biotope_extra }}">
{{ biotope_extra.long_name }}
</div>
{% endfor %}
</td>
<td class="align-middle">{{ state.surface|floatformat:2 }} m²</td>
<td>
<td class="align-middle">
{% if is_default_member and has_access %}
<button data-form-url="{% url 'compensation:state-remove' obj.id state.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove state' %}">
{% fa5_icon 'trash' %}

View File

@ -29,9 +29,12 @@
<table class="table table-hover">
<thead>
<tr>
<th scope="col">
<th class="w-25" scope="col">
{% trans 'Biotope type' %}
</th>
<th class="w-25" scope="col">
{% trans 'Biotope additional type' %}
</th>
<th scope="col">
{% trans 'Surface' %}
</th>
@ -48,8 +51,15 @@
<td class="align-middle">
{{ state.biotope_type }}
</td>
<td class="align-middle">
{% for biotope_extra in state.biotope_type_details.all %}
<div class="mb-2" title="{{ biotope_extra }}">
{{ biotope_extra.long_name }}
</div>
{% endfor %}
</td>
<td class="align-middle">{{ state.surface|floatformat:2 }} m²</td>
<td>
<td class="align-middle">
{% if is_default_member and has_access %}
<button data-form-url="{% url 'compensation:state-remove' obj.id state.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove state' %}">
{% fa5_icon 'trash' %}

View File

@ -24,9 +24,12 @@
<table class="table table-hover">
<thead>
<tr>
<th scope="col">
<th class="w-25" scope="col">
{% trans 'Action type' %}
</th>
<th class="w-25" scope="col">
{% trans 'Action type details' %}
</th>
<th scope="col">
{% trans 'Amount' context 'Compensation' %}
</th>
@ -46,9 +49,14 @@
<td class="align-middle">
{{ action.action_type }}
</td>
<td class="align-middle">
{% for detail in action.action_type_details.all %}
<div class="mb-2" title="{{detail}}">{{detail.long_name}}</div>
{% endfor %}
</td>
<td class="align-middle">{{ action.amount|floatformat:2|intcomma }} {{ action.unit_humanize }}</td>
<td class="align-middle">{{ action.comment|default_if_none:"" }}</td>
<td>
<td class="align-middle">
{% if is_default_member and has_access %}
<button data-form-url="{% url 'compensation:acc-action-remove' obj.id action.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove action' %}">
{% fa5_icon 'trash' %}

View File

@ -29,9 +29,12 @@
<table class="table table-hover">
<thead>
<tr>
<th scope="col">
<th class="w-25" scope="col">
{% trans 'Biotope type' %}
</th>
<th class="w-25" scope="col">
{% trans 'Biotope additional type' %}
</th>
<th scope="col">
{% trans 'Surface' %}
</th>
@ -48,8 +51,15 @@
<td class="align-middle">
{{ state.biotope_type }}
</td>
<td class="align-middle">
{% for biotope_extra in state.biotope_type_details.all %}
<div class="mb-2" title="{{ biotope_extra }}">
{{ biotope_extra.long_name }}
</div>
{% endfor %}
</td>
<td class="align-middle">{{ state.surface|floatformat:2 }} m²</td>
<td>
<td class="align-middle">
{% if is_default_member and has_access %}
<button data-form-url="{% url 'compensation:acc-state-remove' obj.id state.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove state' %}">
{% fa5_icon 'trash' %}

View File

@ -29,9 +29,12 @@
<table class="table table-hover">
<thead>
<tr>
<th scope="col">
<th class="w-25" scope="col">
{% trans 'Biotope type' %}
</th>
<th class="w-25" scope="col">
{% trans 'Biotope additional type' %}
</th>
<th scope="col">
{% trans 'Surface' %}
</th>
@ -48,8 +51,15 @@
<td class="align-middle">
{{ state.biotope_type }}
</td>
<td class="align-middle">
{% for biotope_extra in state.biotope_type_details.all %}
<div class="mb-2" title="{{ biotope_extra }}">
{{ biotope_extra.long_name }}
</div>
{% endfor %}
</td>
<td class="align-middle">{{ state.surface|floatformat:2 }} m²</td>
<td>
<td class="align-middle">
{% if is_default_member and has_access %}
<button data-form-url="{% url 'compensation:acc-state-remove' obj.id state.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove state' %}">
{% fa5_icon 'trash' %}

View File

@ -24,9 +24,12 @@
<table class="table table-hover">
<thead>
<tr>
<th scope="col">
<th class="w-25" scope="col">
{% trans 'Action type' %}
</th>
<th class="w-25" scope="col">
{% trans 'Action type details' %}
</th>
<th scope="col">
{% trans 'Amount' context 'Compensation' %}
</th>
@ -44,9 +47,14 @@
<td class="align-middle">
{{ action.action_type }}
</td>
<td class="align-middle">
{% for detail in action.action_type_details.all %}
<div class="mb-2" title="{{detail}}">{{detail.long_name}}</div>
{% endfor %}
</td>
<td class="align-middle">{{ action.amount|floatformat:2|intcomma }} {{ action.unit_humanize }}</td>
<td class="align-middle">{{ action.comment|default_if_none:"" }}</td>
<td>
<td class="align-middle">
{% if is_default_member and has_access %}
<button data-form-url="{% url 'ema:action-remove' obj.id action.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove action' %}">
{% fa5_icon 'trash' %}

View File

@ -29,9 +29,12 @@
<table class="table table-hover">
<thead>
<tr>
<th scope="col">
<th class="w-25" scope="col">
{% trans 'Biotope type' %}
</th>
<th class="w-25" scope="col">
{% trans 'Biotope additional type' %}
</th>
<th scope="col">
{% trans 'Surface' %}
</th>
@ -46,8 +49,15 @@
<td class="align-middle">
{{ state.biotope_type }}
</td>
<td class="align-middle">
{% for biotope_extra in state.biotope_type_details.all %}
<div class="mb-2" title="{{ biotope_extra }}">
{{ biotope_extra.long_name }}
</div>
{% endfor %}
</td>
<td class="align-middle">{{ state.surface|floatformat:2 }} m²</td>
<td>
<td class="align-middle">
{% if is_default_member and has_access %}
<button data-form-url="{% url 'ema:state-remove' obj.id state.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove state' %}">
{% fa5_icon 'trash' %}

View File

@ -29,9 +29,12 @@
<table class="table table-hover">
<thead>
<tr>
<th scope="col">
<th class="w-25" scope="col">
{% trans 'Biotope type' %}
</th>
<th class="w-25" scope="col">
{% trans 'Biotope additional type' %}
</th>
<th scope="col">
{% trans 'Surface' %}
</th>
@ -46,8 +49,15 @@
<td class="align-middle">
{{ state.biotope_type }}
</td>
<td class="align-middle">
{% for biotope_extra in state.biotope_type_details.all %}
<div class="mb-2" title="{{ biotope_extra }}">
{{ biotope_extra.long_name }}
</div>
{% endfor %}
</td>
<td class="align-middle">{{ state.surface|floatformat:2 }} m²</td>
<td>
<td class="align-middle">
{% if is_default_member and has_access %}
<button data-form-url="{% url 'ema:state-remove' obj.id state.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove state' %}">
{% fa5_icon 'trash' %}

View File

@ -11,7 +11,8 @@ from django.db.models import Q
from codelist.models import KonovaCode
from codelist.settings import CODELIST_COMPENSATION_ACTION_ID, CODELIST_BIOTOPES_ID, CODELIST_LAW_ID, \
CODELIST_REGISTRATION_OFFICE_ID, CODELIST_CONSERVATION_OFFICE_ID, CODELIST_PROCESS_TYPE_ID
CODELIST_REGISTRATION_OFFICE_ID, CODELIST_CONSERVATION_OFFICE_ID, CODELIST_PROCESS_TYPE_ID, \
CODELIST_BIOTOPES_EXTRA_CODES_ID, CODELIST_COMPENSATION_ACTION_DETAIL_ID
from compensation.models import EcoAccount
from intervention.models import Intervention
@ -94,6 +95,7 @@ class KonovaCodeAutocomplete(Select2GroupQuerySetView):
* c: Search inside a special codelist
"""
paginate_by = 50
def order_by(self, qs):
""" Orders by a predefined value
@ -162,6 +164,24 @@ class CompensationActionCodeAutocomplete(KonovaCodeAutocomplete):
)
class CompensationActionDetailCodeAutocomplete(KonovaCodeAutocomplete):
"""
Due to limitations of the django dal package, we need to subclass for each code list
"""
group_by_related = "parent"
related_field_name = "long_name"
paginate_by = 200
def __init__(self, *args, **kwargs):
self.c = CODELIST_COMPENSATION_ACTION_DETAIL_ID
super().__init__(*args, **kwargs)
def order_by(self, qs):
return qs.order_by(
"parent__long_name"
)
class BiotopeCodeAutocomplete(KonovaCodeAutocomplete):
"""
Due to limitations of the django dal package, we need to subclass for each code list
@ -192,6 +212,37 @@ class BiotopeCodeAutocomplete(KonovaCodeAutocomplete):
return f"{result.long_name} ({result.short_name})"
class BiotopeExtraCodeAutocomplete(KonovaCodeAutocomplete):
"""
Due to limitations of the django dal package, we need to subclass for each code list
"""
group_by_related = "parent"
related_field_name = "long_name"
paginate_by = 200
def __init__(self, *args, **kwargs):
self.c = CODELIST_BIOTOPES_EXTRA_CODES_ID
super().__init__(*args, **kwargs)
def order_by(self, qs):
""" Orders by a predefined value
Wrapped in a function to provide inheritance-based different orders
Args:
qs (QuerySet): The queryset to be ordered
Returns:
qs (QuerySet): The ordered queryset
"""
return qs.order_by(
"parent__long_name",
)
def get_result_label(self, result):
return f"{result.long_name} ({result.short_name})"
class LawCodeAutocomplete(KonovaCodeAutocomplete):
"""
Due to limitations of the django dal package, we need to subclass for each code list

View File

@ -121,18 +121,12 @@ a {
.card{
margin: 0 0.5rem 0.5rem 0;
font-size: 12px;
font-size: 0.9rem;
}
.card:hover{
box-shadow: 1px 1px 3px var(--rlp-gray-light);
}
.card .card-text{
font-size: 12px;
max-height: 150px;
overflow: auto;
}
.qs-box{
background-color: var(--rlp-red);
color: white;
@ -215,6 +209,11 @@ Overwrites bootstrap .btn:focus box shadow color
color: var(--rlp-red);
}
.scroll-150{
max-height: 150px;
overflow: auto;
}
.scroll-300{
max-height: 300px;
overflow: auto;
@ -229,4 +228,7 @@ No other approach worked to get the autocomplete fields to full width of parent
}
.select2-results__option--highlighted{
background-color: var(--rlp-red) !important;
}
.select2-container--default .select2-results > .select2-results__options{
max-height: 500px !important;
}

View File

@ -19,7 +19,7 @@
</div>
</div>
<div class="card-body">
<div class="card-text font-italic">
<div class="scroll-150 font-italic">
{{obj.comment}}
</div>
</div>

View File

@ -57,3 +57,33 @@ class AutocompleteTestCase(BaseTestCase):
)
content = json.loads(response.content)
self.assertEqual([], content["results"])
def test_all_autocompletes(self):
tests = [
"accounts-autocomplete",
"interventions-autocomplete",
"codes-compensation-action-autocomplete",
"codes-compensation-action-detail-autocomplete",
"codes-biotope-autocomplete",
"codes-biotope-extra-type-autocomplete",
"codes-law-autocomplete",
"codes-process-type-autocomplete",
"codes-registration-office-autocomplete",
"codes-conservation-office-autocomplete",
"share-user-autocomplete",
]
for test in tests:
self.client.login(username=self.superuser.username, password=self.superuser_pw)
user_autocomplete_url = reverse(test)
data = {
"q": ""
}
response = self.client.get(
user_autocomplete_url,
data,
)
content = json.loads(response.content)
try:
content["results"]
except KeyError:
self.fail(f"No results returned for autocomplete {test}")

View File

@ -20,7 +20,7 @@ from django.urls import path, include
from konova.autocompletes import EcoAccountAutocomplete, \
InterventionAutocomplete, CompensationActionCodeAutocomplete, BiotopeCodeAutocomplete, LawCodeAutocomplete, \
RegistrationOfficeCodeAutocomplete, ConservationOfficeCodeAutocomplete, ProcessTypeCodeAutocomplete, \
ShareUserAutocomplete
ShareUserAutocomplete, BiotopeExtraCodeAutocomplete, CompensationActionDetailCodeAutocomplete
from konova.settings import SSO_SERVER, SSO_PUBLIC_KEY, SSO_PRIVATE_KEY, DEBUG
from konova.sso.sso import KonovaSSOClient
from konova.views import logout_view, home_view, remove_deadline_view
@ -47,7 +47,9 @@ urlpatterns = [
path("atcmplt/eco-accounts", EcoAccountAutocomplete.as_view(), name="accounts-autocomplete"),
path("atcmplt/interventions", InterventionAutocomplete.as_view(), name="interventions-autocomplete"),
path("atcmplt/codes/comp/action", CompensationActionCodeAutocomplete.as_view(), name="codes-compensation-action-autocomplete"),
path("atcmplt/codes/comp/action/detail", CompensationActionDetailCodeAutocomplete.as_view(), name="codes-compensation-action-detail-autocomplete"),
path("atcmplt/codes/biotope", BiotopeCodeAutocomplete.as_view(), name="codes-biotope-autocomplete"),
path("atcmplt/codes/biotope/extra", BiotopeExtraCodeAutocomplete.as_view(), name="codes-biotope-extra-type-autocomplete"),
path("atcmplt/codes/law", LawCodeAutocomplete.as_view(), name="codes-law-autocomplete"),
path("atcmplt/codes/prc-type", ProcessTypeCodeAutocomplete.as_view(), name="codes-process-type-autocomplete"),
path("atcmplt/codes/reg-off", RegistrationOfficeCodeAutocomplete.as_view(), name="codes-registration-office-autocomplete"),

View File

@ -60,7 +60,7 @@ def home_view(request: HttpRequest):
unpublish_on__gte=now,
).order_by(
"-publish_on"
)[:4]
)[:3]
# First fetch all valid objects (undeleted, only newest versions)
interventions = Intervention.objects.filter(

Binary file not shown.

View File

@ -3,9 +3,9 @@
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#: compensation/filters.py:122 compensation/forms/modalForms.py:34
#: compensation/forms/modalForms.py:45 compensation/forms/modalForms.py:61
#: compensation/forms/modalForms.py:238 compensation/forms/modalForms.py:316
#: compensation/filters.py:122 compensation/forms/modalForms.py:35
#: compensation/forms/modalForms.py:46 compensation/forms/modalForms.py:62
#: compensation/forms/modalForms.py:256 compensation/forms/modalForms.py:351
#: intervention/forms/forms.py:52 intervention/forms/forms.py:154
#: intervention/forms/forms.py:166 intervention/forms/modalForms.py:125
#: intervention/forms/modalForms.py:138 intervention/forms/modalForms.py:151
@ -26,7 +26,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-01-28 16:27+0100\n"
"POT-Creation-Date: 2022-01-31 12:41+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -95,7 +95,7 @@ msgstr ""
#: analysis/templates/analysis/reports/includes/eco_account/amount.html:3
#: analysis/templates/analysis/reports/includes/intervention/amount.html:3
#: analysis/templates/analysis/reports/includes/old_data/amount.html:3
#: compensation/forms/modalForms.py:299
#: compensation/forms/modalForms.py:334
#: compensation/templates/compensation/detail/eco_account/includes/deductions.html:34
#: intervention/templates/intervention/detail/includes/deductions.html:31
msgid "Amount"
@ -177,8 +177,9 @@ msgstr "Einzelflächen"
#: analysis/templates/analysis/reports/includes/intervention/laws.html:23
#: analysis/templates/analysis/reports/includes/intervention/laws.html:43
#: analysis/templates/analysis/reports/includes/old_data/amount.html:19
#: konova/templates/konova/home.html:23 konova/templates/konova/home.html:61
#: konova/templates/konova/home.html:100
#: konova/templates/konova/includes/quickstart/compensations.html:16
#: konova/templates/konova/includes/quickstart/ecoaccounts.html:16
#: konova/templates/konova/includes/quickstart/interventions.html:16
msgid "Total"
msgstr "Insgesamt"
@ -212,13 +213,13 @@ msgstr "Abbuchungen"
#: analysis/templates/analysis/reports/includes/eco_account/deductions.html:9
#: analysis/templates/analysis/reports/includes/eco_account/deductions.html:11
#: compensation/forms/modalForms.py:133
#: compensation/templates/compensation/detail/compensation/includes/states-after.html:36
#: compensation/templates/compensation/detail/compensation/includes/states-before.html:36
#: compensation/templates/compensation/detail/eco_account/includes/states-after.html:36
#: compensation/templates/compensation/detail/eco_account/includes/states-before.html:36
#: ema/templates/ema/detail/includes/states-after.html:36
#: ema/templates/ema/detail/includes/states-before.html:36
#: compensation/forms/modalForms.py:151
#: compensation/templates/compensation/detail/compensation/includes/states-after.html:39
#: compensation/templates/compensation/detail/compensation/includes/states-before.html:39
#: compensation/templates/compensation/detail/eco_account/includes/states-after.html:39
#: compensation/templates/compensation/detail/eco_account/includes/states-before.html:39
#: ema/templates/ema/detail/includes/states-after.html:39
#: ema/templates/ema/detail/includes/states-before.html:39
#: intervention/forms/modalForms.py:295
msgid "Surface"
msgstr "Fläche"
@ -240,12 +241,13 @@ msgstr "Kompensationsart"
#: analysis/templates/analysis/reports/includes/old_data/amount.html:29
#: compensation/tables.py:85
#: compensation/templates/compensation/detail/compensation/view.html:19
#: konova/templates/konova/home.html:49 templates/navbars/navbar.html:28
#: konova/templates/konova/includes/quickstart/compensations.html:4
#: templates/navbars/navbar.html:28
msgid "Compensation"
msgstr "Kompensation"
#: analysis/templates/analysis/reports/includes/intervention/compensated_by.html:21
#: compensation/forms/modalForms.py:74
#: compensation/forms/modalForms.py:75
msgid "Payment"
msgstr "Zahlung"
@ -285,7 +287,8 @@ msgstr "Typ"
#: intervention/forms/modalForms.py:306 intervention/forms/modalForms.py:313
#: intervention/tables.py:89
#: intervention/templates/intervention/detail/view.html:19
#: konova/templates/konova/home.html:11 templates/navbars/navbar.html:22
#: konova/templates/konova/includes/quickstart/interventions.html:4
#: templates/navbars/navbar.html:22
msgid "Intervention"
msgstr "Eingriff"
@ -293,7 +296,8 @@ msgstr "Eingriff"
#: compensation/tables.py:226
#: compensation/templates/compensation/detail/eco_account/view.html:19
#: intervention/forms/modalForms.py:279 intervention/forms/modalForms.py:286
#: konova/templates/konova/home.html:88 templates/navbars/navbar.html:34
#: konova/templates/konova/includes/quickstart/ecoaccounts.html:4
#: templates/navbars/navbar.html:34
msgid "Eco-account"
msgstr "Ökokonto"
@ -349,9 +353,9 @@ msgstr "Aussagekräftiger Titel"
msgid "Compensation XY; Location ABC"
msgstr "Kompensation XY; Flur ABC"
#: compensation/forms/forms.py:57 compensation/forms/modalForms.py:60
#: compensation/forms/modalForms.py:237 compensation/forms/modalForms.py:315
#: compensation/templates/compensation/detail/compensation/includes/actions.html:34
#: compensation/forms/forms.py:57 compensation/forms/modalForms.py:61
#: compensation/forms/modalForms.py:255 compensation/forms/modalForms.py:350
#: compensation/templates/compensation/detail/compensation/includes/actions.html:37
#: compensation/templates/compensation/detail/compensation/includes/deadlines.html:34
#: compensation/templates/compensation/detail/compensation/includes/documents.html:31
#: compensation/templates/compensation/detail/eco_account/includes/actions.html:34
@ -465,66 +469,80 @@ msgstr "Ökokonto XY; Flur ABC"
msgid "Edit Eco-Account"
msgstr "Ökokonto bearbeiten"
#: compensation/forms/modalForms.py:35
#: compensation/forms/modalForms.py:36
msgid "in Euro"
msgstr "in Euro"
#: compensation/forms/modalForms.py:44
#: compensation/forms/modalForms.py:45
#: intervention/templates/intervention/detail/includes/payments.html:31
msgid "Due on"
msgstr "Fällig am"
#: compensation/forms/modalForms.py:47
#: compensation/forms/modalForms.py:48
msgid "Due on which date"
msgstr "Zahlung wird an diesem Datum erwartet"
#: compensation/forms/modalForms.py:62 compensation/forms/modalForms.py:239
#: compensation/forms/modalForms.py:317 intervention/forms/modalForms.py:152
#: compensation/forms/modalForms.py:63 compensation/forms/modalForms.py:257
#: compensation/forms/modalForms.py:352 intervention/forms/modalForms.py:152
#: konova/forms.py:375
msgid "Additional comment, maximum {} letters"
msgstr "Zusätzlicher Kommentar, maximal {} Zeichen"
#: compensation/forms/modalForms.py:75
#: compensation/forms/modalForms.py:76
msgid "Add a payment for intervention '{}'"
msgstr "Neue Ersatzzahlung zu Eingriff '{}' hinzufügen"
#: compensation/forms/modalForms.py:95
#: compensation/forms/modalForms.py:96
msgid "If there is no date you can enter, please explain why."
msgstr "Falls Sie kein Datum angeben können, erklären Sie bitte weshalb."
#: compensation/forms/modalForms.py:114 compensation/forms/modalForms.py:126
#: compensation/forms/modalForms.py:115 compensation/forms/modalForms.py:127
msgid "Biotope Type"
msgstr "Biotoptyp"
#: compensation/forms/modalForms.py:117
#: compensation/forms/modalForms.py:118
msgid "Select the biotope type"
msgstr "Biotoptyp wählen"
#: compensation/forms/modalForms.py:136 intervention/forms/modalForms.py:297
#: compensation/forms/modalForms.py:132 compensation/forms/modalForms.py:144
#: compensation/templates/compensation/detail/compensation/includes/states-after.html:36
#: compensation/templates/compensation/detail/compensation/includes/states-before.html:36
#: compensation/templates/compensation/detail/eco_account/includes/states-after.html:36
#: compensation/templates/compensation/detail/eco_account/includes/states-before.html:36
#: ema/templates/ema/detail/includes/states-after.html:36
#: ema/templates/ema/detail/includes/states-before.html:36
msgid "Biotope additional type"
msgstr "Zusatzbezeichnung"
#: compensation/forms/modalForms.py:135
msgid "Select an additional biotope type"
msgstr "Zusatzbezeichnung wählen"
#: compensation/forms/modalForms.py:154 intervention/forms/modalForms.py:297
msgid "in m²"
msgstr ""
#: compensation/forms/modalForms.py:147
#: compensation/forms/modalForms.py:165
msgid "New state"
msgstr "Neuer Zustand"
#: compensation/forms/modalForms.py:148
#: compensation/forms/modalForms.py:166
msgid "Insert data for the new state"
msgstr "Geben Sie die Daten des neuen Zustandes ein"
#: compensation/forms/modalForms.py:155 konova/forms.py:190
#: compensation/forms/modalForms.py:173 konova/forms.py:190
msgid "Object removed"
msgstr "Objekt entfernt"
#: compensation/forms/modalForms.py:209
#: compensation/forms/modalForms.py:227
msgid "Deadline Type"
msgstr "Fristart"
#: compensation/forms/modalForms.py:212
#: compensation/forms/modalForms.py:230
msgid "Select the deadline type"
msgstr "Fristart wählen"
#: compensation/forms/modalForms.py:221
#: compensation/forms/modalForms.py:239
#: compensation/templates/compensation/detail/compensation/includes/deadlines.html:31
#: compensation/templates/compensation/detail/eco_account/includes/deadlines.html:31
#: ema/templates/ema/detail/includes/deadlines.html:31
@ -532,43 +550,43 @@ msgstr "Fristart wählen"
msgid "Date"
msgstr "Datum"
#: compensation/forms/modalForms.py:224
#: compensation/forms/modalForms.py:242
msgid "Select date"
msgstr "Datum wählen"
#: compensation/forms/modalForms.py:251
#: compensation/forms/modalForms.py:269
msgid "New deadline"
msgstr "Neue Frist"
#: compensation/forms/modalForms.py:252
#: compensation/forms/modalForms.py:270
msgid "Insert data for the new deadline"
msgstr "Geben Sie die Daten der neuen Frist ein"
#: compensation/forms/modalForms.py:270
#: compensation/forms/modalForms.py:288
msgid "Action Type"
msgstr "Maßnahmentyp"
#: compensation/forms/modalForms.py:273
#: compensation/forms/modalForms.py:291
msgid "Select the action type"
msgstr "Maßnahmentyp wählen"
#: compensation/forms/modalForms.py:282
#: compensation/templates/compensation/detail/compensation/includes/actions.html:38
#: compensation/forms/modalForms.py:300
#: compensation/templates/compensation/detail/compensation/includes/actions.html:41
#: compensation/templates/compensation/detail/compensation/includes/deadlines.html:38
#: compensation/templates/compensation/detail/compensation/includes/documents.html:35
#: compensation/templates/compensation/detail/compensation/includes/states-after.html:40
#: compensation/templates/compensation/detail/compensation/includes/states-before.html:40
#: compensation/templates/compensation/detail/compensation/includes/states-after.html:43
#: compensation/templates/compensation/detail/compensation/includes/states-before.html:43
#: compensation/templates/compensation/detail/eco_account/includes/actions.html:38
#: compensation/templates/compensation/detail/eco_account/includes/deadlines.html:37
#: compensation/templates/compensation/detail/eco_account/includes/deductions.html:40
#: compensation/templates/compensation/detail/eco_account/includes/documents.html:34
#: compensation/templates/compensation/detail/eco_account/includes/states-after.html:40
#: compensation/templates/compensation/detail/eco_account/includes/states-before.html:40
#: compensation/templates/compensation/detail/eco_account/includes/states-after.html:43
#: compensation/templates/compensation/detail/eco_account/includes/states-before.html:43
#: ema/templates/ema/detail/includes/actions.html:37
#: ema/templates/ema/detail/includes/deadlines.html:37
#: ema/templates/ema/detail/includes/documents.html:34
#: ema/templates/ema/detail/includes/states-after.html:39
#: ema/templates/ema/detail/includes/states-before.html:39
#: ema/templates/ema/detail/includes/states-after.html:42
#: ema/templates/ema/detail/includes/states-before.html:42
#: intervention/templates/intervention/detail/includes/compensations.html:37
#: intervention/templates/intervention/detail/includes/deductions.html:38
#: intervention/templates/intervention/detail/includes/documents.html:35
@ -578,23 +596,31 @@ msgstr "Maßnahmentyp wählen"
msgid "Action"
msgstr "Aktionen"
#: compensation/forms/modalForms.py:287
#: compensation/forms/modalForms.py:305 compensation/forms/modalForms.py:317
msgid "Action Type detail"
msgstr "Zusatzmerkmal"
#: compensation/forms/modalForms.py:308
msgid "Select the action type detail"
msgstr "Zusatzmerkmal wählen"
#: compensation/forms/modalForms.py:322
msgid "Unit"
msgstr "Einheit"
#: compensation/forms/modalForms.py:290
#: compensation/forms/modalForms.py:325
msgid "Select the unit"
msgstr "Einheit wählen"
#: compensation/forms/modalForms.py:302
#: compensation/forms/modalForms.py:337
msgid "Insert the amount"
msgstr "Menge eingeben"
#: compensation/forms/modalForms.py:328
#: compensation/forms/modalForms.py:363
msgid "New action"
msgstr "Neue Maßnahme"
#: compensation/forms/modalForms.py:329
#: compensation/forms/modalForms.py:364
msgid "Insert data for the new action"
msgstr "Geben Sie die Daten der neuen Maßnahme ein"
@ -724,13 +750,17 @@ msgid "Action type"
msgstr "Maßnahmentyp"
#: compensation/templates/compensation/detail/compensation/includes/actions.html:31
msgid "Action type details"
msgstr "Zusatzmerkmale"
#: compensation/templates/compensation/detail/compensation/includes/actions.html:34
#: compensation/templates/compensation/detail/eco_account/includes/actions.html:31
#: ema/templates/ema/detail/includes/actions.html:31
msgctxt "Compensation"
msgid "Amount"
msgstr "Menge"
#: compensation/templates/compensation/detail/compensation/includes/actions.html:53
#: compensation/templates/compensation/detail/compensation/includes/actions.html:61
#: compensation/templates/compensation/detail/eco_account/includes/actions.html:53
#: ema/templates/ema/detail/includes/actions.html:51
msgid "Remove action"
@ -840,12 +870,12 @@ msgstr "Fehlende Flächenmengen laut Ausgangszustand: "
msgid "Biotope type"
msgstr "Biotoptyp"
#: compensation/templates/compensation/detail/compensation/includes/states-after.html:54
#: compensation/templates/compensation/detail/compensation/includes/states-before.html:54
#: compensation/templates/compensation/detail/eco_account/includes/states-after.html:54
#: compensation/templates/compensation/detail/eco_account/includes/states-before.html:54
#: ema/templates/ema/detail/includes/states-after.html:52
#: ema/templates/ema/detail/includes/states-before.html:52
#: compensation/templates/compensation/detail/compensation/includes/states-after.html:64
#: compensation/templates/compensation/detail/compensation/includes/states-before.html:64
#: compensation/templates/compensation/detail/eco_account/includes/states-after.html:64
#: compensation/templates/compensation/detail/eco_account/includes/states-before.html:64
#: ema/templates/ema/detail/includes/states-after.html:62
#: ema/templates/ema/detail/includes/states-before.html:62
msgid "Remove state"
msgstr "Zustand entfernen"
@ -876,13 +906,13 @@ msgstr "Ist CEF Maßnahme"
#: compensation/templates/compensation/detail/compensation/view.html:56
#: venv/lib/python3.7/site-packages/django/forms/widgets.py:710
msgid "Yes"
msgstr ""
msgstr "Ja"
#: compensation/templates/compensation/detail/compensation/view.html:48
#: compensation/templates/compensation/detail/compensation/view.html:58
#: venv/lib/python3.7/site-packages/django/forms/widgets.py:711
msgid "No"
msgstr ""
msgstr "Nein"
#: compensation/templates/compensation/detail/compensation/view.html:53
msgid "Is Coherence keeping compensation"
@ -1725,21 +1755,6 @@ msgstr ""
msgid "English"
msgstr ""
#: konova/templates/konova/home.html:27 konova/templates/konova/home.html:65
#: konova/templates/konova/home.html:104
msgid "Shared with you"
msgstr "Für Sie freigegeben"
#: konova/templates/konova/home.html:35 konova/templates/konova/home.html:73
#: konova/templates/konova/home.html:114
msgid "Create"
msgstr "Neu"
#: konova/templates/konova/home.html:40 konova/templates/konova/home.html:78
#: konova/templates/konova/home.html:119
msgid "Show"
msgstr "Anzeigen"
#: konova/templates/konova/includes/parcels.html:3
msgid "Spatial reference"
msgstr "Raumreferenz"
@ -1764,6 +1779,24 @@ msgstr "Kreis"
msgid "Gemarkung"
msgstr "Gemarkung"
#: konova/templates/konova/includes/quickstart/compensations.html:20
#: konova/templates/konova/includes/quickstart/ecoaccounts.html:20
#: konova/templates/konova/includes/quickstart/interventions.html:20
msgid "Shared with you"
msgstr "Für Sie freigegeben"
#: konova/templates/konova/includes/quickstart/compensations.html:28
#: konova/templates/konova/includes/quickstart/ecoaccounts.html:30
#: konova/templates/konova/includes/quickstart/interventions.html:28
msgid "Create"
msgstr "Neu"
#: konova/templates/konova/includes/quickstart/compensations.html:33
#: konova/templates/konova/includes/quickstart/ecoaccounts.html:35
#: konova/templates/konova/includes/quickstart/interventions.html:33
msgid "Show"
msgstr "Anzeigen"
#: konova/templates/konova/widgets/generate-content-input.html:6
msgid "Generate new"
msgstr "Neu generieren"

View File

@ -10,7 +10,7 @@
{{msg.subject}}
</h6>
<small>{% trans 'Published on' %} {{msg.publish_on}}</small>
<article class="card-text">{{msg.body|safe}}</article>
<article class="scroll-150">{{msg.body|safe}}</article>
</div>
</div>
</div>

View File

@ -19,7 +19,7 @@
<small> {% trans 'Published on' %} {{msg.publish_on}}</small>
</h5>
<small></small>
<article class="card-text">{{msg.body|safe}}</article>
<article class="scroll-150">{{msg.body|safe}}</article>
</div>
</div>
{% endfor %}