Konova Codelist enhancements

* adds proper boolean mapping to update_codelist
* differs between id and atom_id for KonovaCode since atomIds are not unique (could change in the future)
* adds is_selectable and is_archived to KonovaCode
* scales width of DAL form fields to 100% width
* adds table-responsive wrapping container for table forms to prevent unwanted rendering artifacts in case of table resizing due to long content
* adds autocomplete routes for law, registration offices and conservation offices
This commit is contained in:
mipel
2021-08-26 12:45:48 +02:00
parent d33cf5ad4e
commit 97571d4363
8 changed files with 107 additions and 73 deletions

View File

@@ -9,7 +9,8 @@ from dal_select2.views import Select2QuerySetView
from django.db.models import Q
from codelist.models import KonovaCode
from codelist.settings import CODELIST_COMPENSATION_ACTION_ID, CODELIST_BIOTOPES_ID
from codelist.settings import CODELIST_COMPENSATION_ACTION_ID, CODELIST_BIOTOPES_ID, CODELIST_LAW_ID, \
CODELIST_REGISTRATION_OFFICE_ID, CODELIST_CONSERVATION_OFFICE_ID
from compensation.models import EcoAccount
from intervention.models import Intervention
from organisation.models import Organisation
@@ -92,7 +93,8 @@ class KonovaCodeAutocomplete(Select2QuerySetView):
if self.request.user.is_anonymous:
return KonovaCode.objects.none()
qs = KonovaCode.objects.filter(
is_active=True,
is_archived=False,
is_selectable=True,
is_leaf=True,
).order_by(
"long_name"
@@ -125,3 +127,30 @@ class BiotopeCodeAutocomplete(KonovaCodeAutocomplete):
def __init__(self, *args, **kwargs):
self.c = CODELIST_BIOTOPES_ID
super().__init__(*args, **kwargs)
class LawCodeAutocomplete(KonovaCodeAutocomplete):
"""
Due to limitations of the django dal package, we need to subclass for each code list
"""
def __init__(self, *args, **kwargs):
self.c = CODELIST_LAW_ID
super().__init__(*args, **kwargs)
class RegistrationOfficeCodeAutocomplete(KonovaCodeAutocomplete):
"""
Due to limitations of the django dal package, we need to subclass for each code list
"""
def __init__(self, *args, **kwargs):
self.c = CODELIST_REGISTRATION_OFFICE_ID
super().__init__(*args, **kwargs)
class ConservationOfficeCodeAutocomplete(KonovaCodeAutocomplete):
"""
Due to limitations of the django dal package, we need to subclass for each code list
"""
def __init__(self, *args, **kwargs):
self.c = CODELIST_CONSERVATION_OFFICE_ID
super().__init__(*args, **kwargs)

View File

@@ -203,4 +203,12 @@ input:focus, textarea:focus, select:focus{
.scroll-300{
max-height: 300px;
overflow: auto;
}
/*
Extends css for django autocomplete light (dal)
No other approach worked to get the autocomplete fields to full width of parent containers
*/
.select2-container{
width: 100% !important;
}

View File

@@ -18,7 +18,8 @@ from django.contrib import admin
from django.urls import path, include
from konova.autocompletes import OrganisationAutocomplete, NonOfficialOrganisationAutocomplete, EcoAccountAutocomplete, \
InterventionAutocomplete, CompensationActionCodeAutocomplete, BiotopeCodeAutocomplete
InterventionAutocomplete, CompensationActionCodeAutocomplete, BiotopeCodeAutocomplete, LawCodeAutocomplete, \
RegistrationOfficeCodeAutocomplete, ConservationOfficeCodeAutocomplete
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, get_document_view, remove_document_view, remove_deadline_view
@@ -51,6 +52,9 @@ urlpatterns = [
path("atcmplt/interventions", InterventionAutocomplete.as_view(), name="interventions-autocomplete"),
path("atcmplt/codes/compensation-action", CompensationActionCodeAutocomplete.as_view(), name="codes-compensation-action-autocomplete"),
path("atcmplt/codes/biotope", BiotopeCodeAutocomplete.as_view(), name="codes-biotope-autocomplete"),
path("atcmplt/codes/law", LawCodeAutocomplete.as_view(), name="codes-law-autocomplete"),
path("atcmplt/codes/reg-off", RegistrationOfficeCodeAutocomplete.as_view(), name="codes-registration-office-autocomplete"),
path("atcmplt/codes/cons-off", ConservationOfficeCodeAutocomplete.as_view(), name="codes-conservation-office-autocomplete"),
]
if DEBUG: