예제 #1
0
def embed_polycule(polycule_id):
    """ View just a polycule for embedding in an iframe. """
    polycule = Polycule.get(g.db, polycule_id,
                            request.form.get("view_pass", ""))
    if polycule is None:
        return render_template("error.jinja2", error="Polycule not found :(")
    return render_template("embed_polycule.jinja2", graph=polycule.graph)
예제 #2
0
def embed_polycule(polycule_id):
    """ View just a polycule for embedding in an iframe. """
    polycule = Polycule.get(g.db, polycule_id,
                            request.form.get('view_pass', b''))
    if polycule is None:
        return render_template('error.jinja2', error='Polycule not found :(')
    return render_template('embed_polycule.jinja2', graph=polycule.graph)
예제 #3
0
def embed_polycule(polycule_id):
    """ View just a polycule for embedding in an iframe. """
    polycule = Polycule.get(g.db, polycule_id,
                            request.form.get('view_pass', b''))
    if polycule is None:
        return render_template('error.jinja2', error='Polycule not found :(')
    return render_template('embed_polycule.jinja2', graph=polycule.graph)
예제 #4
0
def save_existing_polycule(polycule_id):
    polycule = Polycule.get(g.db, polycule_id, '', force=True)
    polycule.save(
        request.form.get('graph'),
        request.form.get('view_pass'),
        request.form.get('edit_pass'))
    return redirect('/{}'.format(polycule_id))
예제 #5
0
def delete_polycule(polycule_id):
    polycule = Polycule.get(g.db, polycule_id, None, force=True)
    if polycule is None:
        return render_template("error.jinja2", error="Polycule not found :(")
    try:
        polycule.delete(request.form.get("delete_pass", ""))
    except Polycule.PermissionDenied:
        return render_template("view_auth.jinja2", polycule_id=polycule_id)
    return redirect("/")
예제 #6
0
def delete_polycule(polycule_id):
    polycule = Polycule.get(g.db, polycule_id, None, force=True)
    if polycule is None:
        return render_template('error.jinja2', error='Polycule not found :(')
    try:
        polycule.delete(request.form.get('delete_pass', b''))
    except Polycule.PermissionDenied:
        return render_template('view_auth.jinja2', polycule_id=polycule_id)
    return redirect('/')
예제 #7
0
def choose_export(polycule_id):
    try:
        polycule = Polycule.get(g.db, polycule_id,
                                request.form.get('view_pass', b''))
    except Polycule.PermissionDenied:
        return render_template('view_auth.jinja2')
    if polycule is None:
        return render_template('error.jinja2', error='Polycule not found :(')
    return render_template('choose_export.jinja2', polycule=polycule)
예제 #8
0
def delete_polycule(polycule_id):
    polycule = Polycule.get(g.db, polycule_id, None, force=True)
    if polycule is None:
        return render_template('error.jinja2', error='Polycule not found :(')
    try:
        polycule.delete(request.form.get('delete_pass', b''))
    except Polycule.PermissionDenied:
        return render_template('view_auth.jinja2', polycule_id=polycule_id)
    return redirect('/')
예제 #9
0
def choose_export(polycule_id):
    try:
        polycule = Polycule.get(g.db, polycule_id,
                                request.form.get('view_pass', b''))
    except Polycule.PermissionDenied:
        return render_template('view_auth.jinja2')
    if polycule is None:
        return render_template('error.jinja2', error='Polycule not found :(')
    return render_template('choose_export.jinja2', polycule=polycule)
예제 #10
0
def export_text(polycule_id):
    try:
        polycule = Polycule.get(g.db, polycule_id,
                                request.form.get('view_pass', b''))
    except Polycule.PermissionDenied:
        return render_template('view_auth.jinja2')
    if polycule is None:
        return render_template('error.jinja2', error='Polycule not found :(')
    return Response(polycule.as_text(), mimetype='text/plain')
예제 #11
0
def choose_export(polycule_id):
    try:
        polycule = Polycule.get(g.db, polycule_id,
                                request.form.get("view_pass", ""))
    except Polycule.PermissionDenied:
        return render_template("view_auth.jinja2")
    if polycule is None:
        return render_template("error.jinja2", error="Polycule not found :(")
    return render_template("choose_export.jinja2", polycule=polycule)
예제 #12
0
def export_text(polycule_id):
    try:
        polycule = Polycule.get(g.db, polycule_id,
                                request.form.get("view_pass", ""))
    except Polycule.PermissionDenied:
        return render_template("view_auth.jinja2")
    if polycule is None:
        return render_template("error.jinja2", error="Polycule not found :(")
    return Response(polycule.as_text(), mimetype="text/plain")
예제 #13
0
def save_existing_polycule():
    polycule = Polycule.get(g.db, session["currently_editing"], "", force=True)
    polycule.save(
        request.form.get("graph"),
        request.form.get("view_pass"),
        request.form.get("edit_pass"),
        remove_view_pass=request.form.get("remove_view_pass"),
        remove_edit_pass=request.form.get("remove_edit_pass"),
    )
    return redirect("/{}".format(session.pop("currently_editing")))
예제 #14
0
def view_text_only(polycule_id):
    """ View a polycule. """
    try:
        polycule = Polycule.get(g.db, polycule_id,
                                request.form.get("view_pass", ""))
    except Polycule.PermissionDenied:
        return render_template("view_auth.jinja2")
    if polycule is None:
        return render_template("error.jinja2", error="Polycule not found :(")
    return render_template("text_only.jinja2", content=polycule.as_html())
예제 #15
0
def export_dot(polycule_id):
    try:
        polycule = Polycule.get(g.db, polycule_id,
                                request.form.get('view_pass', b''))
    except Polycule.PermissionDenied:
        return render_template('view_auth.jinja2')
    if polycule is None:
        return render_template('error.jinja2', error='Polycule not found :(')
    labels = request.args.get('link-labels', '') != ''
    return Response(polycule.as_dot(edge_labels=labels), mimetype='text/plain')
예제 #16
0
def edit_polycule(polycule_id):
    # Force, as we're relying on edit pass instead of view pass
    polycule = Polycule.get(g.db, polycule_id, '', force=True)
    try:
        polycule.can_save(request.form.get('edit_pass', b''))
    except Polycule.PermissionDenied:
        return render_template('edit_auth.jinja2')
    return render_template('edit_polycule.jinja2',
                           polycule_id=polycule_id,
                           graph=polycule.graph)
예제 #17
0
def view_text_only(polycule_id):
    """ View a polycule. """
    try:
        polycule = Polycule.get(g.db, polycule_id,
                                request.form.get('view_pass', b''))
    except Polycule.PermissionDenied:
        return render_template('view_auth.jinja2')
    if polycule is None:
        return render_template('error.jinja2', error='Polycule not found :(')
    return render_template('text_only.jinja2', content=polycule.as_html())
예제 #18
0
def export_dot(polycule_id):
    try:
        polycule = Polycule.get(g.db, polycule_id,
                                request.form.get('view_pass', b''))
    except Polycule.PermissionDenied:
        return render_template('view_auth.jinja2')
    if polycule is None:
        return render_template('error.jinja2', error='Polycule not found :(')
    labels = request.args.get('link-labels', '') != ''
    return Response(polycule.as_dot(edge_labels=labels), mimetype='text/plain')
예제 #19
0
def export_dot(polycule_id):
    try:
        polycule = Polycule.get(g.db, polycule_id,
                                request.form.get("view_pass", ""))
    except Polycule.PermissionDenied:
        return render_template("view_auth.jinja2")
    if polycule is None:
        return render_template("error.jinja2", error="Polycule not found :(")
    labels = request.args.get("link-labels", "") != ""
    return Response(polycule.as_dot(edge_labels=labels), mimetype="text/plain")
예제 #20
0
def inherit_polycule(polycule_id):
    """
    Take a given polycule and enter create mode, with that polycule's contents
    already in place
    """
    try:
        polycule = Polycule.get(g.db, polycule_id,
                                request.form.get('view_pass', b''))
    except Polycule.PermissionDenied:
        return render_template('view_auth.jinja2')
    if polycule is None:
        return render_template('error.jinja2', error='Polycule not found :(')
    return render_template('create_polycule.jinja2', inherited=polycule.graph)
예제 #21
0
def inherit_polycule(polycule_id):
    """
    Take a given polycule and enter create mode, with that polycule's contents
    already in place
    """
    try:
        polycule = Polycule.get(g.db, polycule_id,
                                request.form.get('view_pass', b''))
    except Polycule.PermissionDenied:
        return render_template('view_auth.jinja2')
    if polycule is None:
        return render_template('error.jinja2', error='Polycule not found :(')
    return render_template('create_polycule.jinja2', inherited=polycule.graph)
예제 #22
0
def export_svg(polycule_id):
    try:
        polycule = Polycule.get(g.db, polycule_id,
                                request.form.get('view_pass', b''))
    except Polycule.PermissionDenied:
        return render_template('view_auth.jinja2')
    if polycule is None:
        return render_template('error.jinja2', error='Polycule not found :(')
    labels = request.args.get('link-labels', '') != ''
    style = request.args.get('style', '') != ''
    embed = request.args.get('embed', '') != ''
    return Response(polycule.as_svg(edge_labels=labels,
                                    include_style=style,
                                    embed=embed),
                    mimetype='image/svg+xml')
예제 #23
0
def export_svg(polycule_id):
    try:
        polycule = Polycule.get(g.db, polycule_id,
                                request.form.get('view_pass', b''))
    except Polycule.PermissionDenied:
        return render_template('view_auth.jinja2')
    if polycule is None:
        return render_template('error.jinja2', error='Polycule not found :(')
    labels = request.args.get('link-labels', '') != ''
    style = request.args.get('style', '') != ''
    embed = request.args.get('embed', '') != ''
    return Response(polycule.as_svg(
        edge_labels=labels,
        include_style=style,
        embed=embed), mimetype='image/svg+xml')
예제 #24
0
def export_svg(polycule_id):
    try:
        polycule = Polycule.get(g.db, polycule_id,
                                request.form.get("view_pass", ""))
    except Polycule.PermissionDenied:
        return render_template("view_auth.jinja2")
    if polycule is None:
        return render_template("error.jinja2", error="Polycule not found :(")
    labels = request.args.get("link-labels", "") != ""
    style = request.args.get("style", "") != ""
    embed = request.args.get("embed", "") != ""
    return Response(
        polycule.as_svg(edge_labels=labels, include_style=style, embed=embed),
        mimetype="image/svg+xml",
    )
예제 #25
0
def edit_polycule(polycule_id):
    # Force, as we're relying on edit pass instead of view pass
    polycule = Polycule.get(g.db, polycule_id, '', force=True)
    if request.method == 'GET':
        return render_template('edit_auth.jinja2')
    try:
        polycule.can_save(request.form.get('edit_pass', b''))
    except Polycule.PermissionDenied:
        return render_template('edit_auth.jinja2')
    except Polycule.NoPassword:
        return render_template(
            'error.jinja2',
            error='This polycule has no password and thus cannot be edited :(')
    return render_template('edit_polycule.jinja2',
                           polycule_id=polycule_id,
                           graph=polycule.graph)
예제 #26
0
def edit_polycule(polycule_id):
    # Force, as we're relying on edit pass instead of view pass
    polycule = Polycule.get(g.db, polycule_id, '', force=True)
    if request.method == 'GET':
        return render_template('edit_auth.jinja2')
    try:
        polycule.can_save(request.form.get('edit_pass', b''))
    except Polycule.PermissionDenied:
        return render_template('edit_auth.jinja2')
    except Polycule.NoPassword:
        return render_template(
            'error.jinja2',
            error='This polycule has no password and thus cannot be edited :(')
    return render_template('edit_polycule.jinja2',
                           polycule_id=polycule_id,
                           graph=polycule.graph)
예제 #27
0
def edit_polycule(polycule_id):
    # Force, as we're relying on edit pass instead of view pass
    polycule = Polycule.get(g.db, polycule_id, "", force=True)
    if request.method == "GET":
        return render_template("edit_auth.jinja2")
    try:
        polycule.can_save(request.form.get("edit_pass", ""))
    except Polycule.PermissionDenied:
        return render_template("edit_auth.jinja2")
    except Polycule.NoPassword:
        return render_template(
            "error.jinja2",
            error="This polycule has no password and thus cannot be edited :(",
        )
    session["currently_editing"] = polycule_id
    return render_template("edit_polycule.jinja2",
                           polycule_id=polycule_id,
                           graph=polycule.graph)
예제 #28
0
def export_png(polycule_id):
    try:
        polycule = Polycule.get(g.db, polycule_id,
                                request.form.get('view_pass', b''))
    except Polycule.PermissionDenied:
        return render_template('view_auth.jinja2')
    if polycule is None:
        return render_template('error.jinja2', error='Polycule not found :(')
    labels = request.args.get('link-labels', '') != ''
    source = request.args.get('from', 'dot')
    if source == 'dot':
        png = polycule.as_png_from_dot(edge_labels=labels)
    elif source == 'svg':
        style = request.args.get('style', '') != ''
        embed = request.args.get('embed', '') != ''
        png = polycule.as_png_from_svg(edge_labels=labels,
                                       include_style=style,
                                       embed=embed)
    return Response(png, mimetype='image/png')
예제 #29
0
def export_png(polycule_id):
    try:
        polycule = Polycule.get(g.db, polycule_id,
                                request.form.get("view_pass", ""))
    except Polycule.PermissionDenied:
        return render_template("view_auth.jinja2")
    if polycule is None:
        return render_template("error.jinja2", error="Polycule not found :(")
    labels = request.args.get("link-labels", "") != ""
    source = request.args.get("from", "dot")
    if source == "dot":
        png = polycule.as_png_from_dot(edge_labels=labels)
    elif source == "svg":
        style = request.args.get("style", "") != ""
        embed = request.args.get("embed", "") != ""
        png = polycule.as_png_from_svg(edge_labels=labels,
                                       include_style=style,
                                       embed=embed)
    return Response(png, mimetype="image/png")
예제 #30
0
def export_png(polycule_id):
    try:
        polycule = Polycule.get(g.db, polycule_id,
                                request.form.get('view_pass', b''))
    except Polycule.PermissionDenied:
        return render_template('view_auth.jinja2')
    if polycule is None:
        return render_template('error.jinja2', error='Polycule not found :(')
    labels = request.args.get('link-labels', '') != ''
    source = request.args.get('from', 'dot')
    if source == 'dot':
        png = polycule.as_png_from_dot(edge_labels=labels)
    elif source == 'svg':
        style = request.args.get('style', '') != ''
        embed = request.args.get('embed', '') != ''
        png = polycule.as_png_from_svg(
            edge_labels=labels,
            include_style=style,
            embed=embed)
    return Response(png, mimetype='image/png')
예제 #31
0
from six.moves import input
import sys

from model import Polycule
import polycules

db = polycules.connect_db()

id = input('Enter the ID of the polycule to delete > ')
polycule = Polycule.get(db, int(id), None, force=True)
if polycule is None:
    print('\nNo polycule with that ID found.')
    db.close()
    sys.exit(1)

if polycule.delete_pass is not None:
    confirm = input('\nPolycule has a delete password, are you sure? [y/n] > ')
    if confirm[0].lower() != 'y':
        print('\nOkay, exiting without deleting.')
        db.close()
        sys.exit(1)

confirm = input('\nAre you sure you want to delete {}? [y/n] > '.format(id))
if confirm[0].lower() == 'y':
    print('\nDeleting {}...'.format(id))
    polycule.delete(None, force=True)
    print('Polycule deleted.')
db.close()
예제 #32
0
from six.moves import input
import sys

from model import Polycule
import polycules


db = polycules.connect_db()

id = input('Enter the ID of the polycule to delete > ')
polycule = Polycule.get(db, int(id), None, force=True)
if polycule is None:
    print('\nNo polycule with that ID found.')
    db.close()
    sys.exit(1)

if polycule.delete_pass is not None:
    confirm = input(
        '\nPolycule has a delete password, are you sure? [y/n] > ')
    if confirm[0].lower() != 'y':
        print('\nOkay, exiting without deleting.')
        db.close()
        sys.exit(1)

confirm = input(
    '\nAre you sure you want to delete {}? [y/n] > '.format(id))
if confirm[0].lower() == 'y':
    print('\nDeleting {}...'.format(id))
    polycule.delete(None, force=True)
    print('Polycule deleted.')
db.close()
예제 #33
0
def save_existing_polycule(polycule_id):
    polycule = Polycule.get(g.db, polycule_id, '', force=True)
    polycule.save(request.form.get('graph'), request.form.get('view_pass'),
                  request.form.get('edit_pass'))
    return redirect('/{}'.format(polycule_id))