From 8e093a2c0c705fa7f593ad63b33dffde573137ec Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Tue, 24 Dec 2024 12:47:34 +1300 Subject: [PATCH] community - show stats in side pane --- app/community/routes.py | 2 ++ app/templates/_side_pane.html | 4 ++++ app/templates/community/community.html | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/community/routes.py b/app/community/routes.py index 9a6cfa87..da920891 100644 --- a/app/community/routes.py +++ b/app/community/routes.py @@ -439,6 +439,7 @@ def do_subscribe(actor, user_id, admin_preload=False): # for local communities, joining is instant member = CommunityMember(user_id=user.id, community_id=community.id) db.session.add(member) + community.subscriptions_count += 1 db.session.commit() if remote: # send ActivityPub message to remote community, asking to follow. Accept message will be sent to our shared inbox @@ -533,6 +534,7 @@ def unsubscribe(actor): if proceed: db.session.query(CommunityMember).filter_by(user_id=current_user.id, community_id=community.id).delete() db.session.query(CommunityJoinRequest).filter_by(user_id=current_user.id, community_id=community.id).delete() + community.subscriptions_count -= 1 db.session.commit() flash('You have left ' + community.title) diff --git a/app/templates/_side_pane.html b/app/templates/_side_pane.html index 8c0d424e..a24b0f6b 100644 --- a/app/templates/_side_pane.html +++ b/app/templates/_side_pane.html @@ -34,6 +34,10 @@

{{ community.description_html|community_links|safe if community.description_html else '' }}

{{ community.rules_html|safe if community.rules_html else '' }}

+

{{ _('Subscribers') }}: {{ community.subscriptions_count }}
+ {{ _('Posts') }}: {{ community.post_count }}
+ {{ _('Comments') }}: {{ community.post_reply_count }} +

{% if len(mods) > 0 and not community.private_mods -%}

Moderators