Пример #1
0
def get_entity_data(
        entity: Entity,
        event_links: Optional[list[Link]] = None) -> dict[str, Any]:
    data: dict[str, Any] = {_('alias'): list(entity.aliases.values())}

    # Dates
    from_link = ''
    to_link = ''
    if entity.class_.name == 'move':  # Add places to the dates if it's a move
        if place_from := entity.get_linked_entity('P27'):
            from_link = \
                link(place_from.get_linked_entity_safe('P53', True)) + ' '
        if place_to := entity.get_linked_entity('P26'):
            to_link = link(place_to.get_linked_entity_safe('P53', True)) + ' '
Пример #2
0
    def get_by_object(object_: Entity) -> dict[int, Overlay]:
        if not app.config['IS_UNIT_TEST'] \
                and not current_user.settings['module_map_overlay']:
            return {}  # pragma: no cover - tests can't access user settings

        ids = [object_.id]
        # Get overlays of parents
        if object_.class_.name == 'artifact' \
                and object_.get_linked_entity('P46', True):
            stratigraphic_unit = object_.get_linked_entity_safe('P46', True)
            ids.append(stratigraphic_unit.id)
            feature = stratigraphic_unit.get_linked_entity_safe('P46', True)
            ids.append(feature.id)
            ids.append(feature.get_linked_entity_safe('P46', True).id)
        elif object_.class_.name == 'stratigraphic_unit':
            feature = object_.get_linked_entity_safe('P46', True)
            ids.append(feature.id)
            ids.append(feature.get_linked_entity_safe('P46', True).id)
        elif object_.class_.name == 'feature':
            ids.append(object_.get_linked_entity_safe('P46', True).id)
        return {row['image_id']: Overlay(row) for row in Db.get_by_object(ids)}