Esempio n. 1
0
def overlay_update(id_: int) -> Union[str, Response]:
    overlay = Overlay.get_by_id(id_)
    form = OverlayForm()
    if form.validate_on_submit():
        Overlay.update(form=form,
                       image_id=overlay.image_id,
                       place_id=overlay.place_id)
        flash(_('info update'), 'info')
        return redirect(
            f"{url_for('entity_view', id_=overlay.place_id)}#tab-file")
    bounding = ast.literal_eval(overlay.bounding_box)
    if len(bounding) == 2:  # pragma no cover
        bounding = [[0, 0], [0, 0], [0, 0]]  # For data entered before 6.4.0
    form.top_left_easting.data = bounding[0][1]
    form.top_left_northing.data = bounding[0][0]
    form.top_right_easting.data = bounding[1][1]
    form.top_right_northing.data = bounding[1][0]
    form.bottom_left_easting.data = bounding[2][1]
    form.bottom_left_northing.data = bounding[2][0]
    entity = Entity.get_by_id(overlay.place_id)
    return render_template(
        'overlay.html',
        form=form,
        overlay=overlay,
        entity=entity,
        buttons=[
            button(_('remove'),
                   url_for('overlay_remove',
                           id_=overlay.id,
                           place_id=entity.id),
                   onclick=f"return confirm('{uc_first(_('remove'))}?');")
        ],
        crumbs=[[_('place'), url_for('index', view='place')], entity,
                Entity.get_by_id(overlay.image_id),
                _('update overlay')])
Esempio n. 2
0
def overlay_update(id_: int) -> Union[str, Response]:
    overlay = Overlay.get_by_id(id_)
    form = OverlayForm()
    if form.validate_on_submit():
        Overlay.update(form=form,
                       image_id=overlay.image_id,
                       place_id=overlay.place_id)
        flash(_('info update'), 'info')
        return redirect(
            url_for('entity_view', id_=overlay.place_id) + '#tab-file')
    bounding = ast.literal_eval(overlay.bounding_box)
    form.top_left_easting.data = bounding[0][1]
    form.top_left_northing.data = bounding[0][0]
    form.bottom_right_easting.data = bounding[1][1]
    form.bottom_right_northing.data = bounding[1][0]
    entity = Entity.get_by_id(overlay.place_id)
    return render_template(
        'overlay/update.html',
        form=form,
        overlay=overlay,
        entity=entity,
        crumbs=[[_('place'), url_for('index', view='place')], entity,
                Entity.get_by_id(overlay.image_id),
                _('update overlay')])