mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-22 22:12:24 +01:00
Add all user replies page
This commit is contained in:
parent
8f4e214c52
commit
933d8ebfe7
@ -28,6 +28,7 @@ from wtforms import *
|
|||||||
from wtforms.validators import *
|
from wtforms.validators import *
|
||||||
from app.utils import get_int_or_abort
|
from app.utils import get_int_or_abort
|
||||||
|
|
||||||
|
|
||||||
@menu.register_menu(bp, ".threads", "Threads", order=20)
|
@menu.register_menu(bp, ".threads", "Threads", order=20)
|
||||||
@bp.route("/threads/")
|
@bp.route("/threads/")
|
||||||
def list_all():
|
def list_all():
|
||||||
@ -344,7 +345,7 @@ def new():
|
|||||||
|
|
||||||
if is_review_thread:
|
if is_review_thread:
|
||||||
post_discord_webhook.delay(current_user.username,
|
post_discord_webhook.delay(current_user.username,
|
||||||
"Opened approval thread: {}".format(thread.getViewURL(absolute=True)), True)
|
"Opened approval thread: {}".format(thread.gcletViewURL(absolute=True)), True)
|
||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
@ -352,3 +353,12 @@ def new():
|
|||||||
|
|
||||||
|
|
||||||
return render_template("threads/new.html", form=form, allow_private_change=allow_change, package=package)
|
return render_template("threads/new.html", form=form, allow_private_change=allow_change, package=package)
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/users/<username>/replies/")
|
||||||
|
def user_replies(username):
|
||||||
|
user = User.query.filter_by(username=username).first()
|
||||||
|
if user is None:
|
||||||
|
abort(404)
|
||||||
|
|
||||||
|
return render_template("threads/user_replies.html", user=user, replies=user.replies)
|
@ -177,7 +177,7 @@ class User(db.Model, UserMixin):
|
|||||||
review_votes = db.relationship("PackageReviewVote", back_populates="user", cascade="all, delete, delete-orphan")
|
review_votes = db.relationship("PackageReviewVote", back_populates="user", cascade="all, delete, delete-orphan")
|
||||||
tokens = db.relationship("APIToken", back_populates="owner", lazy="dynamic", cascade="all, delete, delete-orphan")
|
tokens = db.relationship("APIToken", back_populates="owner", lazy="dynamic", cascade="all, delete, delete-orphan")
|
||||||
threads = db.relationship("Thread", back_populates="author", lazy="dynamic", cascade="all, delete, delete-orphan")
|
threads = db.relationship("Thread", back_populates="author", lazy="dynamic", cascade="all, delete, delete-orphan")
|
||||||
replies = db.relationship("ThreadReply", back_populates="author", lazy="dynamic", cascade="all, delete, delete-orphan")
|
replies = db.relationship("ThreadReply", back_populates="author", lazy="dynamic", cascade="all, delete, delete-orphan", order_by=db.desc("created_at"))
|
||||||
forum_topics = db.relationship("ForumTopic", back_populates="author", lazy="dynamic", cascade="all, delete, delete-orphan")
|
forum_topics = db.relationship("ForumTopic", back_populates="author", lazy="dynamic", cascade="all, delete, delete-orphan")
|
||||||
|
|
||||||
def __init__(self, username=None, active=False, email=None, password=None):
|
def __init__(self, username=None, active=False, email=None, password=None):
|
||||||
|
65
app/templates/threads/user_replies.html
Normal file
65
app/templates/threads/user_replies.html
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
|
||||||
|
{% block link %}
|
||||||
|
<a href="{{ url_for('users.profile', username=user.username) }}">{{ user.display_name }}</a>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
{{ _("Replies by %(user)s", user=user.display_name) }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>{{ _("Replies by %(user)s", user=self.link()) }}</h1>
|
||||||
|
|
||||||
|
|
||||||
|
<ul class="comments mt-5 mb-0">
|
||||||
|
{% for r in replies %}
|
||||||
|
<li class="row my-2 mx-0">
|
||||||
|
<div class="col-md-1 p-1">
|
||||||
|
<a href="{{ url_for('users.profile', username=r.author.username) }}">
|
||||||
|
<img class="img-fluid user-photo img-thumbnail img-thumbnail-1" src="{{ r.author.getProfilePicURL() }}">
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="col pr-0">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
|
||||||
|
<a class="author {{ r.author.rank.name }} mr-3"
|
||||||
|
href="{{ url_for('users.profile', username=r.author.username) }}">
|
||||||
|
{{ r.author.display_name }}
|
||||||
|
</a>
|
||||||
|
|
||||||
|
{% if r.author.username != r.author.display_name %}
|
||||||
|
<span class="text-muted small mr-2">
|
||||||
|
({{ r.author.username }})
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if r == r.thread.replies[0] %}
|
||||||
|
<a class="badge badge-primary" href="{{ r.thread.getViewURL() }}">
|
||||||
|
{{ r.thread.title }}
|
||||||
|
</a>
|
||||||
|
{% else %}
|
||||||
|
<i class="fas fa-reply mr-2"></i>
|
||||||
|
<a class="badge badge-dark" href="{{ r.thread.getViewURL() }}">
|
||||||
|
Reply to <b>{{ r.thread.title }}</b>
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<a name="reply-{{ r.id }}" class="text-muted float-right"
|
||||||
|
href="{{ url_for('threads.view', id=r.thread.id) }}#reply-{{ r.id }}">
|
||||||
|
{{ r.created_at | datetime }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card-body markdown">
|
||||||
|
{{ r.comment | markdown }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{% endblock %}
|
@ -101,13 +101,13 @@
|
|||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<span>
|
<a class="btn" href="{{ url_for('threads.user_replies', username=user.username) }}">
|
||||||
<i class="fas fa-comment"></i>
|
<i class="fas fa-comment"></i>
|
||||||
<span class="count">
|
<span class="count">
|
||||||
<strong>{{ user.replies.count() }}</strong>
|
<strong>{{ user.replies.count() }}</strong>
|
||||||
{{ _("comments") }}
|
{{ _("comments") }}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user