|
|
@ -4,7 +4,20 @@ from flask import (Blueprint, flash, g, redirect,
|
|
|
|
from exquisite_branch.db import get_db
|
|
|
|
from exquisite_branch.db import get_db
|
|
|
|
from werkzeug.exceptions import abort
|
|
|
|
from werkzeug.exceptions import abort
|
|
|
|
|
|
|
|
|
|
|
|
from shortuuid import uuid
|
|
|
|
import shortuuid
|
|
|
|
|
|
|
|
import uuid
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_uuid(d=7):
|
|
|
|
|
|
|
|
'''return a short uuid (default 7 chars)'''
|
|
|
|
|
|
|
|
u = uuid.uuid4()
|
|
|
|
|
|
|
|
s = shortuuid.encode(u)
|
|
|
|
|
|
|
|
return s[:d]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bp = Blueprint('draw', __name__, url_prefix='/draw')
|
|
|
|
bp = Blueprint('draw', __name__, url_prefix='/draw')
|
|
|
|
|
|
|
|
|
|
|
@ -31,7 +44,8 @@ def draw(parent=None):
|
|
|
|
print(url_for('share.share', branch=f"{branch}"))
|
|
|
|
print(url_for('share.share', branch=f"{branch}"))
|
|
|
|
return redirect(url_for('share.share', branch=branch))
|
|
|
|
return redirect(url_for('share.share', branch=branch))
|
|
|
|
|
|
|
|
|
|
|
|
branch = uuid()
|
|
|
|
branch = get_uuid()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
previous = db.execute(
|
|
|
|
previous = db.execute(
|
|
|
|
"SELECT content, branch, parent FROM branches"
|
|
|
|
"SELECT content, branch, parent FROM branches"
|
|
|
@ -48,7 +62,7 @@ def draw(parent=None):
|
|
|
|
@bp.route('/last', methods=('GET', 'POST'))
|
|
|
|
@bp.route('/last', methods=('GET', 'POST'))
|
|
|
|
def last():
|
|
|
|
def last():
|
|
|
|
|
|
|
|
|
|
|
|
branch = uuid()
|
|
|
|
branch = get_uuid()
|
|
|
|
db = get_db()
|
|
|
|
db = get_db()
|
|
|
|
previous = db.execute(
|
|
|
|
previous = db.execute(
|
|
|
|
'SELECT * FROM branches ORDER BY id DESC LIMIT 1'
|
|
|
|
'SELECT * FROM branches ORDER BY id DESC LIMIT 1'
|
|
|
@ -74,7 +88,7 @@ def last():
|
|
|
|
@bp.route('/', methods=('GET', 'POST'))
|
|
|
|
@bp.route('/', methods=('GET', 'POST'))
|
|
|
|
def new():
|
|
|
|
def new():
|
|
|
|
db = get_db()
|
|
|
|
db = get_db()
|
|
|
|
branch = uuid()
|
|
|
|
branch = get_uuid()
|
|
|
|
parent = 'NEW'
|
|
|
|
parent = 'NEW'
|
|
|
|
|
|
|
|
|
|
|
|
if request.method == 'POST':
|
|
|
|
if request.method == 'POST':
|
|
|
|