mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-02-02 16:21:32 -08:00
Add pages for admins and community mods to see voting activity
This commit is contained in:
parent
6413490cc3
commit
e6f3bd6fb4
5 changed files with 106 additions and 2 deletions
|
@ -1787,3 +1787,45 @@ def post_cross_posts(post_id: int):
|
|||
post = Post.query.get_or_404(post_id)
|
||||
cross_posts = Post.query.filter(Post.id.in_(post.cross_posts)).all()
|
||||
return render_template('post/post_cross_posts.html', post=post, cross_posts=cross_posts)
|
||||
|
||||
|
||||
@bp.route('/post/<int:post_id>/voting_activity', methods=['GET'])
|
||||
@login_required
|
||||
def post_view_voting_activity(post_id: int):
|
||||
post = Post.query.get_or_404(post_id)
|
||||
if not current_user.is_admin() and not post.community.is_moderator() and not post.community.is_owner():
|
||||
abort(404)
|
||||
|
||||
post_title=post.title
|
||||
upvoters = User.query.join(PostVote, PostVote.user_id == User.id).filter_by(post_id=post_id, effect=1.0).order_by(User.ap_domain, User.user_name)
|
||||
downvoters = User.query.join(PostVote, PostVote.user_id == User.id).filter_by(post_id=post_id, effect=-1.0).order_by(User.ap_domain, User.user_name)
|
||||
|
||||
# local users will be at the bottom of each list as ap_domain is empty for those.
|
||||
|
||||
return render_template('post/post_voting_activity.html', title=_('Voting Activity'),
|
||||
post_title=post_title, upvoters=upvoters, downvoters=downvoters,
|
||||
moderating_communities=moderating_communities(current_user.get_id()),
|
||||
joined_communities=joined_communities(current_user.get_id()),
|
||||
menu_topics=menu_topics(), site=g.site
|
||||
)
|
||||
|
||||
|
||||
@bp.route('/comment/<int:comment_id>/voting_activity', methods=['GET'])
|
||||
@login_required
|
||||
def post_reply_view_voting_activity(comment_id: int):
|
||||
post_reply = PostReply.query.get_or_404(comment_id)
|
||||
if not current_user.is_admin() and not post_reply.community.is_moderator() and not post_reply.community.is_owner():
|
||||
abort(404)
|
||||
|
||||
reply_text=post_reply.body
|
||||
upvoters = User.query.join(PostReplyVote, PostReplyVote.user_id == User.id).filter_by(post_reply_id=comment_id, effect=1.0).order_by(User.ap_domain, User.user_name)
|
||||
downvoters = User.query.join(PostReplyVote, PostReplyVote.user_id == User.id).filter_by(post_reply_id=comment_id, effect=-1.0).order_by(User.ap_domain, User.user_name)
|
||||
|
||||
# local users will be at the bottom of each list as ap_domain is empty for those.
|
||||
|
||||
return render_template('post/post_reply_voting_activity.html', title=_('Voting Activity'),
|
||||
reply_text=reply_text, upvoters=upvoters, downvoters=downvoters,
|
||||
moderating_communities=moderating_communities(current_user.get_id()),
|
||||
joined_communities=joined_communities(current_user.get_id()),
|
||||
menu_topics=menu_topics(), site=g.site
|
||||
)
|
||||
|
|
|
@ -62,10 +62,14 @@
|
|||
{% endif -%}
|
||||
<li><a href="{{ url_for('post.post_report', post_id=post.id) }}" class="no-underline" rel="nofollow"><span class="fe fe-report"></span>
|
||||
{{ _('Report to moderators') }}</a></li>
|
||||
{% if post.community.is_moderator() or post.community.is_owner() or current_user.is_admin() -%}
|
||||
<li><a href="{{ url_for('post.post_view_voting_activity', post_id=post.id) }}" class="no-underline" rel="nofollow"><span class="fe fe-sticky-left"></span>
|
||||
{{ _('View Voting Activity') }}</a></li>
|
||||
{% endif -%}
|
||||
</ul>
|
||||
<p>{{ _('If you want to perform more than one of these (e.g. block and report), hold down Ctrl and click, then complete the operation in the new tabs that open.') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock -%}
|
||||
{% endblock -%}
|
||||
|
|
|
@ -41,6 +41,10 @@
|
|||
{{ _("Hide every post from author's instance: %(name)s", name=post_reply.instance.domain) }}</a></li>
|
||||
{% endif -%}
|
||||
{% endif -%}
|
||||
{% if post_reply.community.is_moderator() or post_reply.community.is_owner() or current_user.is_admin() -%}
|
||||
<li><a href="{{ url_for('post.post_reply_view_voting_activity', comment_id=post_reply.id) }}" class="no-underline" rel="nofollow"><span class="fe fe-sticky-left"></span>
|
||||
{{ _('View Voting Activity') }}</a></li>
|
||||
{% endif -%}
|
||||
{% endif -%}
|
||||
<li><a href="{{ url_for('post.post_reply_report', post_id=post.id, comment_id=post_reply.id) }}" rel="nofollow" class="no-underline"><span class="fe fe-report"></span>
|
||||
{{ _('Report to moderators') }}</a></li>
|
||||
|
@ -50,4 +54,4 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock -%}
|
||||
{% endblock -%}
|
||||
|
|
27
app/templates/post/post_reply_voting_activity.html
Normal file
27
app/templates/post/post_reply_voting_activity.html
Normal file
|
@ -0,0 +1,27 @@
|
|||
{% if theme() and file_exists('app/templates/themes/' + theme() + '/base.html') -%}
|
||||
{% extends 'themes/' + theme() + '/base.html' -%}
|
||||
{% else -%}
|
||||
{% extends "base.html" -%}
|
||||
{% endif -%} -%}
|
||||
{% from 'bootstrap/form.html' import render_form -%}
|
||||
|
||||
{% block app_content -%}
|
||||
<div class="row">
|
||||
<h3>{{ _('Voting Activity for "%(reply_text)s"', reply_text=reply_text) }}</h3>
|
||||
<p><details open>
|
||||
<summary>Upvoters</summary>
|
||||
{% for upvoter in upvoters -%}
|
||||
<a href="{{ upvoter.ap_profile_id }}" rel="nofollow" class="no-underline"><span class="fe fe-external"></span>
|
||||
{{ upvoter.ap_profile_id }}</a><br />
|
||||
{% endfor -%}
|
||||
</details>
|
||||
</p><p><hr></p>
|
||||
<details open>
|
||||
<summary>Downvoters</summary>
|
||||
{% for downvoter in downvoters -%}
|
||||
<a href="{{ downvoter.ap_profile_id }}" rel="nofollow" class="no-underline"><span class="fe fe-external"></span>
|
||||
{{ downvoter.ap_profile_id }}</a><br />
|
||||
{% endfor -%}
|
||||
</details>
|
||||
</div>
|
||||
{% endblock -%}
|
27
app/templates/post/post_voting_activity.html
Normal file
27
app/templates/post/post_voting_activity.html
Normal file
|
@ -0,0 +1,27 @@
|
|||
{% if theme() and file_exists('app/templates/themes/' + theme() + '/base.html') -%}
|
||||
{% extends 'themes/' + theme() + '/base.html' -%}
|
||||
{% else -%}
|
||||
{% extends "base.html" -%}
|
||||
{% endif -%} -%}
|
||||
{% from 'bootstrap/form.html' import render_form -%}
|
||||
|
||||
{% block app_content -%}
|
||||
<div class="row">
|
||||
<h3>{{ _('Voting Activity for "%(post_title)s"', post_title=post_title) }}</h3>
|
||||
<p><details open>
|
||||
<summary>Upvoters</summary>
|
||||
{% for upvoter in upvoters -%}
|
||||
<a href="{{ upvoter.ap_profile_id }}" rel="nofollow" class="no-underline"><span class="fe fe-external"></span>
|
||||
{{ upvoter.ap_profile_id }}</a><br />
|
||||
{% endfor -%}
|
||||
</details>
|
||||
</p><p><hr></p>
|
||||
<details open>
|
||||
<summary>Downvoters</summary>
|
||||
{% for downvoter in downvoters -%}
|
||||
<a href="{{ downvoter.ap_profile_id }}" rel="nofollow" class="no-underline"><span class="fe fe-external"></span>
|
||||
{{ downvoter.ap_profile_id }}</a><br />
|
||||
{% endfor -%}
|
||||
</details>
|
||||
</div>
|
||||
{% endblock -%}
|
Loading…
Add table
Reference in a new issue