You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.5 KiB
Python

5 months ago
from flask import Blueprint
from flask_mako import render_template
5 months ago
from exquisite_branch.db import get_db, dict_factory
from exquisite_branch.tree import make_tree
3 years ago
5 months ago
bp = Blueprint("display", __name__, url_prefix="/display")
3 years ago
# @bp.route('/')
# def display():
# db = get_db()
3 years ago
# branches = db.execute(
# "SELECT content, branch, parent, username FROM branches"
# ).fetchall()
3 years ago
# 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)
3 years ago
# streams.append(stream[::-1])
3 years ago
# return render_template('display_mako.html', branches=branches, streams=streams)
3 years ago
# def flatten(t):
# return [item for sublist in t for item in sublist]
5 months ago
# @bp.route("/")
# def display():
# db = get_db()
# branches = db.execute(
# "SELECT content, branch, parent, username FROM branches"
# ).fetchall()
# return render_template("display_mako_bis.html", branches=branches)
@bp.route("/")
def display():
db = get_db()
branches = db.execute(
"SELECT content, branch, parent, username FROM branches"
).fetchall()
5 months ago
root = make_tree(branches)
return render_template("display_mako_bis.html", root=root)
# return render_template("display_linked_mako.html", branches=branches)