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 dac334ed14
commit 77b290216b
8 changed files with 107 additions and 73 deletions

View File

@@ -15,6 +15,10 @@ from codelist.settings import CODELIST_INTERVENTION_HANDLER_ID, CODELIST_CONSERV
CODELIST_COMPENSATION_ACTION_ID, CODELIST_COMPENSATION_ACTION_CLASS_ID, CODELIST_COMPENSATION_ADDITIONAL_TYPE_ID, \
CODELIST_COMPENSATION_COMBINATION_ID, CODELIST_BASE_URL
bool_map = {
"true": True,
"false": False,
}
class Command(BaseCommand):
help = "Performs test on collisions using the identifier generation"
@@ -56,41 +60,6 @@ class Command(BaseCommand):
code_list=code_list,
parent=None,
)
"""
for element in items:
atom_id = element.find("atomid").text
parent = element.find("vaterid").text
short_name = element.find("shortname").text
long_name = element.find("longname").text
is_archived = bool(element.find("archive").text)
# If a parent has been set, we need to fetch/create this entry. Otherwise ("0") we ignore it.
if parent == "0":
parent = None
else:
parent = KonovaCode.objects.get_or_create(
id=parent,
)[0]
code = KonovaCode.objects.get_or_create(
id=atom_id,
)
created = code[1]
if created:
num_created += 1
else:
num_updated += 1
code = code[0]
code.short_name = short_name
code.long_name = long_name
code.parent = parent
code.is_active = is_archived
code.save()
if code not in code_list.codes.all():
code_list.codes.add(code)
"""
except KeyboardInterrupt:
self._break_line()
@@ -102,19 +71,24 @@ class Command(BaseCommand):
else:
for element in items:
children = element.find("items")
_id = element.find("id").text
atom_id = element.find("atomid").text
selectable = element.find("selectable").text.lower()
selectable = bool_map.get(selectable, False)
short_name = element.find("shortname").text
long_name = element.find("longname").text
is_archived = bool(element.find("archive").text)
is_archived = bool_map.get((element.find("archive").text.lower()), False)
code = KonovaCode.objects.get_or_create(
id=atom_id,
id=_id,
)
code = code[0]
code.atom_id = atom_id
code.short_name = short_name
code.long_name = long_name
code.parent = parent
code.is_active = is_archived
code.is_selectable = selectable
code.is_archived = is_archived
code.is_leaf = children is None
code.save()