Self hosted FLOSS fitness/workout, nutrition and weight tracker
Load current number of stars from GitHub
Roland Geider6c7056c01cce
diff --git a/wger/software/templates/features.html b/wger/software/templates/features.htmlindex aeecb5b0c..2366313f7 100644--- a/wger/software/templates/features.html+++ b/wger/software/templates/features.html@@ -97,7 +97,7 @@<p class="text-center">foods <br> for meal planing</p></div><div class="col-lg-3 col-sm-3 d-flex flex-column align-items-center">- <h2 class="display-3 font-bebas-neue text-dark-blue mb-0">2000+</h2>+ <h2 class="display-3 font-bebas-neue text-dark-blue mb-0">{{ nr_stars }}+</h2><p class="text-center">stars <br> on GitHub</p></div></section>diff --git a/wger/software/views.py b/wger/software/views.pyindex deb6f09df..299da8a4f 100644--- a/wger/software/views.py+++ b/wger/software/views.py@@ -23,10 +23,14 @@ from django.contrib.auth.models import Userfrom django.shortcuts import renderfrom django.views.decorators.cache import cache_page+# Third Party+import requests+# wgerfrom wger.exercises.models import ExerciseBasefrom wger.nutrition.models import Ingredient+logger = logging.getLogger(__name__)@@ -36,11 +40,15 @@ def features(request):Render the features page"""+ # Fetch number of stars from GitHub. The page is cached, so doing this is OK+ result = requests.get('https://api.github.com/repos/wger-project/wger').json()+context = {'allow_registration': settings.WGER_SETTINGS['ALLOW_REGISTRATION'],'allow_guest_users': settings.WGER_SETTINGS['ALLOW_GUEST_USERS'],'nr_users': User.objects.count(),'nr_exercises': ExerciseBase.objects.count(),- 'nr_ingredients': Ingredient.objects.count()+ 'nr_ingredients': Ingredient.objects.count(),+ 'nr_stars': result.get('stargazers_count', '2000')}return render(request, 'features.html', context)