def link_insert(id_: int, view: str) -> Union[str, Response]: entity = Entity.get_by_id(id_) property_code = 'P67' inverse = False if entity.class_.view == 'actor' and view == 'artifact': property_code = 'P52' inverse = True if request.method == 'POST': if request.form['checkbox_values']: entity.link_string(property_code, request.form['checkbox_values'], inverse=inverse) return redirect(f"{url_for('view', id_=entity.id)}#tab-{view}") if entity.class_.view == 'actor' and view == 'artifact': excluded = Entity.get_by_link_property(property_code, 'artifact') else: excluded = entity.get_linked_entities(property_code, inverse=inverse) return render_template('form.html', form=build_table_form(view, excluded), title=_(entity.class_.view), crumbs=[[ _(entity.class_.view), url_for('index', view=entity.class_.view) ], entity, _('link')])
def source_add(id_: int, view: str) -> Union[str, Response]: source = Entity.get_by_id(id_) if request.method == 'POST': if request.form['checkbox_values']: source.link_string('P67', request.form['checkbox_values']) return redirect(f"{url_for('entity_view', id_=source.id)}#tab-{view}") return render_template( 'form.html', form=build_table_form(view, source.get_linked_entities('P67')), title=_('source'), crumbs=[[_('source'), url_for('index', view='source')], source, _('link')])
def file_add(id_: int, view: str) -> Union[str, Response]: entity = Entity.get_by_id(id_) if request.method == 'POST': if request.form['checkbox_values']: entity.link_string('P67', request.form['checkbox_values']) return redirect(f"{url_for('entity_view', id_=entity.id)}#tab-{view}") return render_template( 'form.html', form=build_table_form(view, entity.get_linked_entities('P67')), title=entity.name, crumbs=[ [_(entity.class_.view), url_for('index', view=entity.class_.view)], entity, f"{_('link')} {_(view)}"])
def entity_add_source(id_: int) -> Union[str, Response]: entity = Entity.get_by_id(id_) if request.method == 'POST': if request.form['checkbox_values']: entity.link_string('P67', request.form['checkbox_values'], inverse=True) return redirect(f"{url_for('entity_view', id_=id_)}#tab-source") form = build_table_form('source', entity.get_linked_entities('P67', inverse=True)) return render_template('form.html', form=form, title=entity.name, crumbs=[[ _(entity.class_.view), url_for('index', view=entity.class_.view) ], entity, f"{_('link')} {_('source')}"])