diff --git a/app/admin/routes.py b/app/admin/routes.py index 32f2e7d4..b09292e9 100644 --- a/app/admin/routes.py +++ b/app/admin/routes.py @@ -15,7 +15,7 @@ from app.admin.forms import FederationForm, SiteMiscForm, SiteProfileForm, EditC from app.admin.util import unsubscribe_from_everything_then_delete, unsubscribe_from_community, send_newsletter from app.community.util import save_icon_file, save_banner_file from app.models import AllowedInstances, BannedInstances, ActivityPubLog, utcnow, Site, Community, CommunityMember, \ - User, Instance, File, Report, Topic, UserRegistration, Role + User, Instance, File, Report, Topic, UserRegistration, Role, Post from app.utils import render_template, permission_required, set_setting, get_setting, gibberish, markdown_to_html, \ moderating_communities, joined_communities, finalize_user_setup, theme_list from app.admin import bp @@ -475,6 +475,26 @@ def admin_users_trash(): ) +@bp.route('/content/trash', methods=['GET']) +@login_required +@permission_required('administer all users') +def admin_content_trash(): + + page = request.args.get('page', 1, type=int) + + posts = Post.query.filter(Post.posted_at > utcnow() - timedelta(days=3)).order_by(Post.score) + posts = posts.paginate(page=page, per_page=100, error_out=False) + + next_url = url_for('admin.admin_content_trash', page=posts.next_num) if posts.has_next else None + prev_url = url_for('admin.admin_content_trash', page=posts.prev_num) if posts.has_prev and page != 1 else None + + return render_template('admin/posts.html', title=_('Bad posts'), next_url=next_url, prev_url=prev_url, posts=posts, + moderating_communities=moderating_communities(current_user.get_id()), + joined_communities=joined_communities(current_user.get_id()), + site=g.site + ) + + @bp.route('/approve_registrations', methods=['GET']) @login_required @permission_required('approve registrations') diff --git a/app/templates/admin/posts.html b/app/templates/admin/posts.html new file mode 100644 index 00000000..2c3da127 --- /dev/null +++ b/app/templates/admin/posts.html @@ -0,0 +1,37 @@ +{% 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 %} +
+
+ {% include 'admin/_nav.html' %} +
+
+ +
+
+

{{ _('Most downvoted in the last 3 days') }}

+
+ {% for post in posts.items %} + {% include 'post/_post_teaser.html' %} + {% endfor %} +
+ +
+
+{% endblock %} \ No newline at end of file