Skip to content

Commit

Permalink
Modification for places
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderWatzinger committed Oct 4, 2023
1 parent 3a9038b commit 688a97b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
3 changes: 2 additions & 1 deletion openatlas/forms/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 14 additions & 4 deletions openatlas/forms/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down

0 comments on commit 688a97b

Please sign in to comment.