From 688a97b223662ed76fb8f537ce291ac3a998c3ad Mon Sep 17 00:00:00 2001 From: Alexander Watzinger Date: Wed, 4 Oct 2023 17:13:20 +0200 Subject: [PATCH] Modification for places --- openatlas/forms/field.py | 3 ++- openatlas/forms/manager.py | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/openatlas/forms/field.py b/openatlas/forms/field.py index 138ed3051..68bfec08d 100644 --- a/openatlas/forms/field.py +++ b/openatlas/forms/field.py @@ -155,7 +155,8 @@ def __call__( **kwargs: Any) -> TableMultiSelect: data = field.data or [] data = ast.literal_eval(data) if isinstance(data, str) else data - class_ = field.id if field.id != 'given_place' else 'place' + class_ = field.id \ + if field.id not in ['given_place', 'modified_place'] else 'place' aliases = current_user.settings['table_show_aliases'] if class_ in ['group', 'person']: entities = Entity.get_by_class(class_, types=True, aliases=aliases) diff --git a/openatlas/forms/manager.py b/openatlas/forms/manager.py index ba87c0f8e..4de4b7bcc 100644 --- a/openatlas/forms/manager.py +++ b/openatlas/forms/manager.py @@ -389,19 +389,29 @@ class ModificationManager(EventBaseManager): def additional_fields(self) -> dict[str, Any]: return dict( super().additional_fields(), - **{'artifact': TableMultiField()}) + **{ + 'artifact': TableMultiField(), + 'modified_place': TableMultiField('place')}) def populate_update(self) -> None: super().populate_update() - self.form.artifact.data = \ - [item.id for item in self.entity.get_linked_entities('P31')] + artifact_data = [] + place_data = [] + for item in self.entity.get_linked_entities('P31'): + if item.class_.name == 'artifact': + artifact_data.append(item.id) + elif item.cidoc_class.code == 'E18': + place_data.append(item.id) + self.form.artifact.data = artifact_data + self.form.modified_place.data = place_data def process_form(self) -> None: super().process_form() self.data['links']['delete'].add('P31') if self.form.artifact.data: self.add_link('P31', self.form.artifact.data) - + if self.form.modified_place.data: + self.add_link('P31', self.form.modified_place.data) class MoveManager(EventBaseManager):