diff options
author | Matt Arnold | 2025-04-15 21:55:22 -0400 |
---|---|---|
committer | Matt Arnold | 2025-04-15 21:55:22 -0400 |
commit | 1f6e041e49754ae41db005f98df2685031ccaff0 (patch) | |
tree | f74fa30cde99976942fc5719e7c350451a09da0b | |
parent | e8880e73a23571acf47845b1e38292239c5d71b2 (diff) |
threaded view basically works now
-rw-r--r-- | app.py | 8 | ||||
-rw-r--r-- | models.py | 2 | ||||
-rw-r--r-- | templates/view_thread.html | 28 |
3 files changed, 37 insertions, 1 deletions
diff --git a/app.py b/app.py index d5b0c8c..2653dde 100644 --- a/app.py +++ b/app.py @@ -144,5 +144,13 @@ def faccets(): return render_template("faccet_list.html", faccet=faccet_list) +@app.route("/thread/<int:post_id>") +@login_required +def thread(post_id): + thread = Post.get(Post.id == post_id) + pdx = get_replies(post_id) + return render_template("view_thread.html", thread=thread, pdx=pdx) + + if __name__ == "__main__": app.run(debug=True, port=5052) diff --git a/models.py b/models.py index 6e5a5b0..b435a40 100644 --- a/models.py +++ b/models.py @@ -61,7 +61,7 @@ def get_previous(post_id): def get_attribed_posts(uid): - return Post.select().where(Post.authour == uid).order_by(Post.created_at.desc()) + return Post.select().where(Post.authour == uid).order_by(Post.created_at.asc()) db.create_tables([User, Post, Faccet]) diff --git a/templates/view_thread.html b/templates/view_thread.html new file mode 100644 index 0000000..877feb8 --- /dev/null +++ b/templates/view_thread.html @@ -0,0 +1,28 @@ +{% extends 'base.html' %} + +{% block content %} + +<h2>{{ thread.title }}</h2> +<p>{{ thread.created_at.strftime('%Y-%m-%d %H:%M') }}</p> +{% for post in pdx %} +<div class="container"> + <div class="userbox"> + <p> Poster: <a href="{{url_for('details', light=post.authour.name)}}"> {{post.authour.name}} </a> + </p> + <p> Date: {{post.created_at.strftime('%Y-%m-%d %H:%M')}} </p> + </div> + <div class="post-content"> + <p> + <h4> {{post.title}} </h4> + </p> + {{ post.content|markdown|safe }} + </div> + <br> <br> +</div> +{% endfor %} +<div class="post-actions"> + <a href="{{ url_for('create', reply=thread.id)}}"> Reply</a> ~ + <a href="{{ url_for('index') }}">Back to posts</a> +</div> + +{% endblock %} \ No newline at end of file |