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 @@