From f3714fe826eefda8371dd8420f2093dad6607df3 Mon Sep 17 00:00:00 2001 From: Tdxdxoz Date: Fri, 5 Nov 2021 23:34:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=BA=E5=8C=96=E6=8F=90=E7=A4=BA=20&=20?= =?UTF-8?q?=E8=90=BD=E9=80=89=E5=86=85=E5=AE=B9=E6=88=90=E4=B8=BA=E8=8D=89?= =?UTF-8?q?=E7=A8=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 10 ++++++++++ templates/story.html | 9 +++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index f54a6ed..ba145a3 100644 --- a/app.py +++ b/app.py @@ -213,6 +213,8 @@ def story(story_id): story = Story.query.get_or_404(story_id) is_tree = story.is_tree + draft = '' + if is_tree: tail = request.args.get('tail', story.tail, type=int) p_tail = Paragraph.query.get_or_404(tail) @@ -230,6 +232,14 @@ def story(story_id): story_id=story_id, is_chosen=True, is_hidden=False ).all() + if 'username' in session: + last_post = Paragraph.query.filter_by( + story_id=story_id, author=session['username'], is_chosen=False + ).order_by(Paragraph.id.desc()).first() + + if last_post and last_post.parent_id != tail: + draft = last_post.text + sort_by = request.args.get('sort_by', 'time') q = Paragraph.query.filter_by(story_id=story_id, parent_id=tail, is_hidden=False) diff --git a/templates/story.html b/templates/story.html index a997e1c..e5d3553 100644 --- a/templates/story.html +++ b/templates/story.html @@ -53,6 +53,10 @@