From aca77314d16a7cdcd9ac8a526fb7a3836d5c63ff Mon Sep 17 00:00:00 2001 From: Michael Manfre Date: Sat, 24 Dec 2022 00:16:26 -0500 Subject: [PATCH] Fixes #239 - Add option to hide Boost and Like counts (#247) --- core/models/config.py | 3 +++ takahe/urls.py | 5 +++++ templates/activities/_boost.html | 6 ++++-- templates/activities/_like.html | 6 ++++-- templates/base.html | 5 +++++ templates/settings/_menu.html | 3 +++ users/views/settings/__init__.py | 1 + users/views/settings/wellness.py | 15 +++++++++++++++ 8 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 users/views/settings/wellness.py diff --git a/core/models/config.py b/core/models/config.py index cb40e60..cf54b7a 100644 --- a/core/models/config.py +++ b/core/models/config.py @@ -243,3 +243,6 @@ class Config(models.Model): toot_mode: bool = False default_post_visibility: int = 0 # Post.Visibilities.public visible_follows: bool = True + + # wellness Options + visible_reaction_counts: bool = True diff --git a/takahe/urls.py b/takahe/urls.py index 75e5fb6..41a6d2c 100644 --- a/takahe/urls.py +++ b/takahe/urls.py @@ -46,6 +46,11 @@ urlpatterns = [ settings.InterfacePage.as_view(), name="settings_interface", ), + path( + "settings/user/", + settings.WellnessPage.as_view(), + name="settings_wellness", + ), path( "admin/", admin.AdminRoot.as_view(), diff --git a/templates/activities/_boost.html b/templates/activities/_boost.html index 945683e..fe78567 100644 --- a/templates/activities/_boost.html +++ b/templates/activities/_boost.html @@ -1,9 +1,11 @@ {% if post.pk in interactions.boost %} - {% if event.boost_count is not None %}{{ event.boost_count }}{% else %}{{ post.boost_count }}{% endif %} + + {% else %} - {% if event.boost_count is not None %}{{ event.boost_count }}{% else %}{{ post.boost_count }}{% endif %} + + {% endif %} diff --git a/templates/activities/_like.html b/templates/activities/_like.html index 5877fff..6934d86 100644 --- a/templates/activities/_like.html +++ b/templates/activities/_like.html @@ -1,9 +1,11 @@ {% if post.pk in interactions.like %} - {% if event.like_count is not None %}{{ event.like_count }}{% else %}{{ post.like_count }}{% endif %} + + {% else %} - {% if event.like_count is not None %}{{ event.like_count }}{% else %}{{ post.like_count }}{% endif %} + + {% endif %} diff --git a/templates/base.html b/templates/base.html index 8a6f6c7..33f7ec1 100644 --- a/templates/base.html +++ b/templates/base.html @@ -16,6 +16,11 @@ body { --color-highlight: {{ config.highlight_color }}; } + {% if not config_system.visible_reaction_counts %} + .like-count { + display: none; + } + {% endif %} {% block extra_head %}{% endblock %} diff --git a/templates/settings/_menu.html b/templates/settings/_menu.html index 478e5ae..da12c3e 100644 --- a/templates/settings/_menu.html +++ b/templates/settings/_menu.html @@ -6,6 +6,9 @@ Interface + + Wellness +

Account

Login & Security diff --git a/users/views/settings/__init__.py b/users/views/settings/__init__.py index f3332d3..808e881 100644 --- a/users/views/settings/__init__.py +++ b/users/views/settings/__init__.py @@ -6,6 +6,7 @@ from users.views.settings.interface import InterfacePage # noqa from users.views.settings.profile import ProfilePage # noqa from users.views.settings.security import SecurityPage # noqa from users.views.settings.settings_page import SettingsPage # noqa +from users.views.settings.wellness import WellnessPage # noqa @method_decorator(identity_required, name="dispatch") diff --git a/users/views/settings/wellness.py b/users/views/settings/wellness.py new file mode 100644 index 0000000..6ea9151 --- /dev/null +++ b/users/views/settings/wellness.py @@ -0,0 +1,15 @@ +from users.views.settings.settings_page import SettingsPage + + +class WellnessPage(SettingsPage): + + section = "wellness" + + options = { + "visible_reaction_counts": { + "title": "Show Boost and Like Counts", + "help_text": "Disable to hide the number of Likes and Boosts on a 'Post'", + }, + } + + layout = {"Wellness": ["visible_reaction_counts"]}