Ejemplo n.º 1
0
def views(sketch_id):
    """Generates the sketch views template.

    Returns:
        Template with context.
    """
    sketch = Sketch.query.get_with_acl(sketch_id)
    trash_form = TrashViewForm()
    graphs_enabled = current_app.config['GRAPH_BACKEND_ENABLED']

    # Trash form POST
    if trash_form.validate_on_submit():
        if not sketch.has_permission(current_user, 'write'):
            abort(HTTP_STATUS_CODE_FORBIDDEN)
        view_id = trash_form.view_id.data
        view = View.query.get(view_id)
        # Check that this view belongs to the sketch
        if view.sketch_id != sketch.id:
            abort(HTTP_STATUS_CODE_NOT_FOUND)
        view.set_status(status='deleted')
        return redirect('/sketch/{0:d}/views/'.format(sketch.id))

    return render_template('sketch/views.html',
                           sketch=sketch,
                           trash_form=trash_form,
                           graphs_enabled=graphs_enabled)
Ejemplo n.º 2
0
def views(sketch_id):
    """Generates the sketch views template.

    Returns:
        Template with context.
    """
    sketch = Sketch.query.get_with_acl(sketch_id)
    trash_form = TrashViewForm()
    graphs_enabled = current_app.config['GRAPH_BACKEND_ENABLED']

    # Trash form POST
    if trash_form.validate_on_submit():
        if not sketch.has_permission(current_user, 'write'):
            abort(HTTP_STATUS_CODE_FORBIDDEN)
        view_id = trash_form.view_id.data
        view = View.query.get(view_id)
        # Check that this view belongs to the sketch
        if view.sketch_id != sketch.id:
            abort(HTTP_STATUS_CODE_NOT_FOUND)
        view.set_status(status='deleted')
        return redirect('/sketch/{0:d}/views/'.format(sketch.id))

    return render_template(
        'sketch/views.html',
        sketch=sketch,
        trash_form=trash_form,
        graphs_enabled=graphs_enabled)