Skip to content

Commit

Permalink
Link artifact from tab at source (#2433)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderWatzinger committed Dec 18, 2024
1 parent db4ba22 commit f12a7f1
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions openatlas/display/tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def set_table_headers(
def set_buttons(self, name: str, entity: Optional[Entity] = None) -> None:
view = entity.class_.view if entity else None
id_ = entity.id if entity else None
class_ = entity.class_ if entity else None
class_name = entity.class_.name if entity else None
match name:
case 'actor':
match view:
Expand Down Expand Up @@ -137,7 +137,12 @@ def set_buttons(self, name: str, entity: Optional[Entity] = None) -> None:
g.classes[item].label,
url_for('insert', class_=item, origin_id=id_)))
case 'artifact':
if entity and entity.class_.name in [
if class_name == 'source':
self.buttons.append(
button(
'link',
url_for('link_insert', id_=id_, view='artifact')))
if class_name in [
'place',
'artifact',
'human_remains',
Expand All @@ -147,15 +152,15 @@ def set_buttons(self, name: str, entity: Optional[Entity] = None) -> None:
button(
_('add subunit'),
url_for('add_subunit', super_id=id_)))
if entity and entity.class_.name != 'human_remains':
if class_name != 'human_remains':
self.buttons.append(
button(
g.classes['artifact'].label,
url_for(
'insert',
class_='artifact',
origin_id=id_)))
if entity and entity.class_.name != 'artifact':
if class_name != 'artifact':
self.buttons.append(
button(
g.classes['human_remains'].label,
Expand Down Expand Up @@ -217,7 +222,7 @@ def set_buttons(self, name: str, entity: Optional[Entity] = None) -> None:
origin_id=id_),
tooltip_text=g.classes[item]
.get_tooltip()))
case 'feature' if class_ and class_.name == 'place':
case 'feature' if class_name == 'place':
self.buttons.append(
button(
g.classes[name].label,
Expand Down Expand Up @@ -264,7 +269,7 @@ def set_buttons(self, name: str, entity: Optional[Entity] = None) -> None:
self.buttons.append(
button(_('note'), url_for('note_insert', entity_id=id_)))
case 'place':
if class_ and class_.name == 'file':
if class_name == 'file':
self.buttons.append(
button(
'link',
Expand Down Expand Up @@ -305,7 +310,7 @@ def set_buttons(self, name: str, entity: Optional[Entity] = None) -> None:
g.classes[item].label,
url_for('insert', class_=item, origin_id=id_)))
case 'source':
if class_ and class_.name == 'file':
if class_name == 'file':
self.buttons.append(
button(
_('link'),
Expand All @@ -322,12 +327,11 @@ def set_buttons(self, name: str, entity: Optional[Entity] = None) -> None:
button(
g.classes['source'].label,
url_for('insert', class_=name, origin_id=id_)))
case 'stratigraphic_unit':
if class_ and class_.name == 'feature':
self.buttons.append(
button(
g.classes['stratigraphic_unit'].label,
url_for('insert', class_=name, origin_id=id_)))
case 'stratigraphic_unit' if class_name == 'feature':
self.buttons.append(
button(
g.classes['stratigraphic_unit'].label,
url_for('insert', class_=name, origin_id=id_)))
case 'text':
self.buttons.append(button(
_('text'),
Expand Down

0 comments on commit f12a7f1

Please sign in to comment.