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)
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)
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)
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))
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("/")
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('/')
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)
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('/')
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)
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')
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)
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")
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")))
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())
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')
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)
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())
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')
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")
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)
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)
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')
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')
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", )
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)
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)
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)
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')
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")
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')
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()
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()
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))