Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Add a setting to hide the app store links

Roland Geider2fef4c74b1f5
diff --git a/settings/main.py b/settings/main.py
index c27204242..b7319c0c7 100644
--- a/settings/main.py
+++ b/settings/main.py
@@ -197,6 +197,7 @@ WGER_SETTINGS['CACHE_API_EXERCISES_CELERY'] = env.bool('CACHE_API_EXERCISES_CELE
WGER_SETTINGS['CACHE_API_EXERCISES_CELERY_FORCE_UPDATE'] = env.bool(
'CACHE_API_EXERCISES_CELERY_FORCE_UPDATE', False
)
+WGER_SHOW_APP_STORE_LINKS = env.bool('WGER_SHOW_APP_STORE_LINKS', True)
#
# Auth Proxy Authentication
diff --git a/settings/settings_global.py b/settings/settings_global.py
index b5ca8ec95..c5cc9ffc4 100644
--- a/settings/settings_global.py
+++ b/settings/settings_global.py
@@ -643,6 +643,9 @@ WGER_SETTINGS = {
# List of allauth provider IDs to load, e.g. ['google', 'github', 'gitlab'].
WGER_SOCIAL_PROVIDERS = []
+# Whether to link to the mobile app in the app stores in the footer and on the landing page.
+WGER_SHOW_APP_STORE_LINKS = True
+
#
# Auth Proxy Authentication
diff --git a/wger/core/templates/template.html b/wger/core/templates/template.html
index 153aa96bd..919a85908 100644
--- a/wger/core/templates/template.html
+++ b/wger/core/templates/template.html
@@ -127,23 +127,25 @@
<div class="container bg-wger-light">
<div class="row">
<div class="col-xl-4 col-md-7 mt-2">
- <a href="https://play.google.com/store/apps/details?id=de.wger.flutter">
- <img
- src="{% static 'images/logos/play-store/badge.svg' %}"
- alt="google play logo"
- height="40"
- /></a>
- <a href="https://apps.apple.com/us/app/wger-workout-manager/id6502226792">
- <img
- src="{% static 'images/logos/app-store/black.svg' %}"
- alt="app store logo"
- height="40"/></a>
- <a href="https://flathub.org/apps/de.wger.flutter">
- <img
- src="{% static 'images/logos/flathub/black.svg' %}"
- alt="flathub logo"
- height="40"
- /></a>
+ {% if show_app_store_links %}
+ <a href="https://play.google.com/store/apps/details?id=de.wger.flutter">
+ <img
+ src="{% static 'images/logos/play-store/badge.svg' %}"
+ alt="google play logo"
+ height="40"
+ /></a>
+ <a href="https://apps.apple.com/us/app/wger-workout-manager/id6502226792">
+ <img
+ src="{% static 'images/logos/app-store/black.svg' %}"
+ alt="app store logo"
+ height="40"/></a>
+ <a href="https://flathub.org/apps/de.wger.flutter">
+ <img
+ src="{% static 'images/logos/flathub/black.svg' %}"
+ alt="flathub logo"
+ height="40"
+ /></a>
+ {% endif %}
</div>
<div class="col-xl-6 col-md-3">
<ul class="list-unstyled mb-0 pt-2">
diff --git a/wger/core/tests/test_app_store_links.py b/wger/core/tests/test_app_store_links.py
new file mode 100644
index 000000000..5dda91232
--- /dev/null
+++ b/wger/core/tests/test_app_store_links.py
@@ -0,0 +1,65 @@
+# This file is part of wger Workout Manager.
+#
+# wger Workout Manager is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# wger Workout Manager is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+
+# Standard Library
+from unittest import mock
+
+# Django
+from django.test import override_settings
+from django.urls import reverse
+
+# wger
+from wger.core.tests.base_testcase import WgerTestCase
+
+
+class AppStoreLinksTestCase(WgerTestCase):
+ """
+ Test that WGER_SHOW_APP_STORE_LINKS controls the app store badges
+ """
+
+ stores = (
+ 'play.google.com',
+ 'apps.apple.com',
+ 'flathub.org',
+ )
+
+ def test_footer_shows_the_badges_by_default(self):
+ response = self.client.get(reverse('core:user:login'))
+
+ for store in self.stores:
+ self.assertContains(response, store)
+
+ @override_settings(WGER_SHOW_APP_STORE_LINKS=False)
+ def test_footer_badges_can_be_hidden(self):
+ response = self.client.get(reverse('core:user:login'))
+
+ for store in self.stores:
+ self.assertNotContains(response, store)
+
+ @mock.patch('wger.software.views.requests.get')
+ def test_landing_page_shows_the_badges_by_default(self, mock_request):
+ mock_request.return_value.json.return_value = {'stargazers_count': 42}
+ response = self.client.get(reverse('software:features'))
+
+ for store in self.stores + ('f-droid.org',):
+ self.assertContains(response, store)
+
+ @override_settings(WGER_SHOW_APP_STORE_LINKS=False)
+ @mock.patch('wger.software.views.requests.get')
+ def test_landing_page_badges_can_be_hidden(self, mock_request):
+ mock_request.return_value.json.return_value = {'stargazers_count': 42}
+ response = self.client.get(reverse('software:features'))
+
+ for store in self.stores + ('f-droid.org',):
+ self.assertNotContains(response, store)
diff --git a/wger/software/templates/features.html b/wger/software/templates/features.html
index 4f5ca708d..0c39d21d2 100644
--- a/wger/software/templates/features.html
+++ b/wger/software/templates/features.html
@@ -51,12 +51,14 @@
{% translate "Exercises" %}
</a>
</li>
- <li class="nav-item mx-2 my-1">
- <a class="nav-link fw-semibold"
- href="https://play.google.com/store/apps/details?id=de.wger.flutter">
- {% translate "Mobile app" %}
- </a>
- </li>
+ {% if show_app_store_links %}
+ <li class="nav-item mx-2 my-1">
+ <a class="nav-link fw-semibold"
+ href="https://play.google.com/store/apps/details?id=de.wger.flutter">
+ {% translate "Mobile app" %}
+ </a>
+ </li>
+ {% endif %}
<li class="nav-item mx-2 my-1">
<a class="nav-link fw-semibold"
href="https://www.buymeacoffee.com/wger">
@@ -618,34 +620,36 @@
</ul>
</div>
- <a href="https://play.google.com/store/apps/details?id=de.wger.flutter">
- <img
- src="{% static 'images/logos/play-store/badge.svg' %}"
- alt="google play logo"
- height="55"
- />
- </a>
- <a href="https://apps.apple.com/us/app/wger-workout-manager/id6502226792">
- <img
- src="{% static 'images/logos/app-store/black.svg' %}"
- alt="app store logo"
- height="55"
- />
- </a>
- <a href="https://flathub.org/apps/de.wger.flutter">
- <img
- src="{% static 'images/logos/flathub/black.svg' %}"
- alt="flathub logo"
- height="55"
- />
- </a>
- <a href="https://f-droid.org/de/packages/de.wger.flutter/">
- <img
- src="{% static 'images/logos/fdroid/get-it-on.svg' %}"
- alt="fdroid logo"
- height="55"
- />
- </a>
+ {% if show_app_store_links %}
+ <a href="https://play.google.com/store/apps/details?id=de.wger.flutter">
+ <img
+ src="{% static 'images/logos/play-store/badge.svg' %}"
+ alt="google play logo"
+ height="55"
+ />
+ </a>
+ <a href="https://apps.apple.com/us/app/wger-workout-manager/id6502226792">
+ <img
+ src="{% static 'images/logos/app-store/black.svg' %}"
+ alt="app store logo"
+ height="55"
+ />
+ </a>
+ <a href="https://flathub.org/apps/de.wger.flutter">
+ <img
+ src="{% static 'images/logos/flathub/black.svg' %}"
+ alt="flathub logo"
+ height="55"
+ />
+ </a>
+ <a href="https://f-droid.org/de/packages/de.wger.flutter/">
+ <img
+ src="{% static 'images/logos/fdroid/get-it-on.svg' %}"
+ alt="fdroid logo"
+ height="55"
+ />
+ </a>
+ {% endif %}
</div>
</div>
</footer>
diff --git a/wger/utils/context_processor.py b/wger/utils/context_processor.py
index 550fb5426..63c86750d 100644
--- a/wger/utils/context_processor.py
+++ b/wger/utils/context_processor.py
@@ -34,6 +34,7 @@ def processor(request):
context = {
'mastodon': settings.WGER_SETTINGS.get('MASTODON', ''),
'allow_registration': settings.WGER_SETTINGS.get('ALLOW_REGISTRATION', False),
+ 'show_app_store_links': settings.WGER_SHOW_APP_STORE_LINKS,
# Languages
'i18n_language': get_language_data(