|
|
|
@ -1,43 +1,41 @@
|
|
|
|
|
from flask import (Blueprint, flash, g, redirect,
|
|
|
|
|
request, session, url_for)
|
|
|
|
|
from flask import (Blueprint)
|
|
|
|
|
from flask_mako import render_template
|
|
|
|
|
|
|
|
|
|
from exquisite_branch.db import get_db
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bp = Blueprint('display', __name__, url_prefix='/display')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@bp.route('/')
|
|
|
|
|
def display():
|
|
|
|
|
db = get_db()
|
|
|
|
|
# @bp.route('/')
|
|
|
|
|
# def display():
|
|
|
|
|
# db = get_db()
|
|
|
|
|
|
|
|
|
|
branches = db.execute(
|
|
|
|
|
"SELECT content, branch, parent, username FROM branches"
|
|
|
|
|
).fetchall()
|
|
|
|
|
# branches = db.execute(
|
|
|
|
|
# "SELECT content, branch, parent, username FROM branches"
|
|
|
|
|
# ).fetchall()
|
|
|
|
|
|
|
|
|
|
streams = []
|
|
|
|
|
for branch in branches[::-1]:
|
|
|
|
|
if branch not in flatten(streams):
|
|
|
|
|
stream = [branch]
|
|
|
|
|
parent = branch['parent']
|
|
|
|
|
while parent != 'NEW':
|
|
|
|
|
current = next(
|
|
|
|
|
(x for x in branches if x['branch'] == parent), None)
|
|
|
|
|
parent = current['parent']
|
|
|
|
|
stream.append(current)
|
|
|
|
|
# streams = []
|
|
|
|
|
# for branch in branches[::-1]:
|
|
|
|
|
# if branch not in flatten(streams):
|
|
|
|
|
# stream = [branch]
|
|
|
|
|
# parent = branch['parent']
|
|
|
|
|
# while parent != 'NEW':
|
|
|
|
|
# current = next(
|
|
|
|
|
# (x for x in branches if x['branch'] == parent), None)
|
|
|
|
|
# parent = current['parent']
|
|
|
|
|
# stream.append(current)
|
|
|
|
|
|
|
|
|
|
streams.append(stream[::-1])
|
|
|
|
|
# streams.append(stream[::-1])
|
|
|
|
|
|
|
|
|
|
return render_template('display_mako.html', branches=branches, streams=streams)
|
|
|
|
|
# return render_template('display_mako.html', branches=branches, streams=streams)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def flatten(t):
|
|
|
|
|
return [item for sublist in t for item in sublist]
|
|
|
|
|
# def flatten(t):
|
|
|
|
|
# return [item for sublist in t for item in sublist]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@bp.route('/linked')
|
|
|
|
|
def linked():
|
|
|
|
|
@bp.route('/')
|
|
|
|
|
def display():
|
|
|
|
|
db = get_db()
|
|
|
|
|
|
|
|
|
|
branches = db.execute(
|
|
|
|
|