From 9df02c649ed35cb25fd375cab6dd272ec797a9f7 Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Sun, 18 Aug 2024 13:44:19 +1200 Subject: [PATCH] flag un-moderated communities --- app/community/routes.py | 13 +++++++++++-- app/templates/_side_pane.html | 3 +++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/community/routes.py b/app/community/routes.py index 2a838815..b0d73684 100644 --- a/app/community/routes.py +++ b/app/community/routes.py @@ -193,11 +193,20 @@ def show_community(community: Community): is_owner = False is_admin = False + # Build list of moderators and set un-moderated flag + mod_user_ids = [mod.user_id for mod in mods] + un_moderated = False if community.private_mods: mod_list = [] + inactive_mods = User.query.filter(User.id.in_(mod_user_ids), User.last_seen < utcnow() - timedelta(days=60)).all() else: - mod_user_ids = [mod.user_id for mod in mods] mod_list = User.query.filter(User.id.in_(mod_user_ids)).all() + inactive_mods = [] + for mod in mod_list: + if mod.last_seen < utcnow() - timedelta(days=60): + inactive_mods.append(mod) + if current_user.is_authenticated and (current_user.is_admin() or current_user.is_staff()): + un_moderated = len(mod_user_ids) == len(inactive_mods) posts = community.posts @@ -305,7 +314,7 @@ def show_community(community: Community): POST_TYPE_VIDEO=POST_TYPE_VIDEO, POST_TYPE_POLL=POST_TYPE_POLL, SUBSCRIPTION_PENDING=SUBSCRIPTION_PENDING, SUBSCRIPTION_MEMBER=SUBSCRIPTION_MEMBER, SUBSCRIPTION_OWNER=SUBSCRIPTION_OWNER, SUBSCRIPTION_MODERATOR=SUBSCRIPTION_MODERATOR, etag=f"{community.id}{sort}{post_layout}_{hash(community.last_active)}", related_communities=related_communities, - next_url=next_url, prev_url=prev_url, low_bandwidth=low_bandwidth, + next_url=next_url, prev_url=prev_url, low_bandwidth=low_bandwidth, un_moderated=un_moderated, recently_upvoted=recently_upvoted, recently_downvoted=recently_downvoted, rss_feed=f"https://{current_app.config['SERVER_NAME']}/community/{community.link()}/feed", rss_feed_name=f"{community.title} on {g.site.name}", content_filters=content_filters, moderating_communities=moderating_communities(current_user.get_id()), diff --git a/app/templates/_side_pane.html b/app/templates/_side_pane.html index 4c1e2089..43fa6f1d 100644 --- a/app/templates/_side_pane.html +++ b/app/templates/_side_pane.html @@ -41,6 +41,9 @@
  • {{ render_username(mod) }}
  • {% endfor -%} + {% if un_moderated -%} +

    {{ _('Moderators have not been active recently.') }}

    + {% endif -%} {% endif -%} {% if not community.is_local() -%}