Self hosted FLOSS fitness/workout, nutrition and weight tracker
Show the actual nr of users, ingredients, etc. in landing page
Roland Geider875f56f183be
diff --git a/wger/core/forms.py b/wger/core/forms.pyindex be370a5a0..c40a9fa9e 100644--- a/wger/core/forms.py+++ b/wger/core/forms.py@@ -148,7 +148,7 @@ class UserEmailForm(forms.ModelForm):class Meta:model = User- fields = ('email',)+ fields = ('email', )def clean_email(self):"""diff --git a/wger/core/views/user.py b/wger/core/views/user.pyindex 366a58d16..a3674b7f3 100644--- a/wger/core/views/user.py+++ b/wger/core/views/user.py@@ -104,6 +104,7 @@ from wger.utils.generic_views import ()from wger.weight.models import WeightEntry+logger = logging.getLogger(__name__)@@ -563,7 +564,7 @@ class UserListView(LoginRequiredMixin, PermissionRequiredMixin, ListView):Overview of all users in the instance"""model = User- permission_required = ('gym.manage_gyms',)+ permission_required = ('gym.manage_gyms', )template_name = 'user/list.html'def get_queryset(self):diff --git a/wger/mailer/urls.py b/wger/mailer/urls.pyindex 01907dd3a..0a8d75078 100644--- a/wger/mailer/urls.py+++ b/wger/mailer/urls.py@@ -22,6 +22,7 @@ from django.urls import pathfrom wger.mailer.forms import EmailListFormfrom wger.mailer.views import gym+# sub patterns for email listspatterns_email = [path(diff --git a/wger/manager/forms.py b/wger/manager/forms.pyindex 3be62a30e..c578afc18 100644--- a/wger/manager/forms.py+++ b/wger/manager/forms.py@@ -69,6 +69,7 @@ from wger.utils.widgets import (class WorkoutForm(ModelForm):+class Meta:model = Workoutfields = (@@ -78,6 +79,7 @@ class WorkoutForm(ModelForm):class WorkoutMakeTemplateForm(ModelForm):+class Meta:model = Workoutfields = (@@ -100,9 +102,10 @@ class WorkoutCopyForm(Form):class DayForm(ModelForm):+class Meta:model = Day- exclude = ('training',)+ exclude = ('training', )widgets = {'day': TranslatedSelectMultiple()}def __init__(self, *args, **kwargs):@@ -142,6 +145,7 @@ class SetForm(ModelForm):class SettingForm(ModelForm):+class Meta:model = Settingexclude = ('set', 'exercise', 'order', 'name')@@ -188,7 +192,7 @@ class WorkoutLogForm(ModelForm):class Meta:model = WorkoutLog- exclude = ('workout',)+ exclude = ('workout', )class WorkoutLogFormHelper(FormHelper):diff --git a/wger/nutrition/forms.py b/wger/nutrition/forms.pyindex 071a4b730..f463e5159 100644--- a/wger/nutrition/forms.py+++ b/wger/nutrition/forms.py@@ -48,6 +48,7 @@ from wger.nutrition.models import ()from wger.utils.widgets import Html5NumberInput+logger = logging.getLogger(__name__)@@ -105,7 +106,7 @@ class BmiForm(forms.ModelForm):class Meta:model = UserProfile- fields = ('height',)+ fields = ('height', )def __init__(self, *args, **kwargs):super(BmiForm, self).__init__(*args, **kwargs)@@ -212,7 +213,7 @@ class DailyCaloriesForm(forms.ModelForm):class Meta:model = UserProfile- fields = ('calories',)+ fields = ('calories', )def __init__(self, *args, **kwargs):super(DailyCaloriesForm, self).__init__(*args, **kwargs)@@ -301,6 +302,7 @@ class MealLogItemForm(MealItemForm):class IngredientForm(forms.ModelForm):+class Meta:model = Ingredientfields = [diff --git a/wger/settings_global.py b/wger/settings_global.pyindex 7084b085c..5b44b96e1 100644--- a/wger/settings_global.py+++ b/wger/settings_global.py@@ -20,6 +20,7 @@ import osimport refrom datetime import timedelta+"""This file contains the global settings that don't usually need to be changed.For a full list of options, visit:@@ -166,7 +167,7 @@ TEMPLATES = ['django.template.loaders.app_directories.Loader',],'debug':- False+ False},},]@@ -236,7 +237,7 @@ LANGUAGES = (LANGUAGE_CODE = 'en'# All translation files are in one place-LOCALE_PATHS = (os.path.join(SITE_ROOT, 'locale'),)+LOCALE_PATHS = (os.path.join(SITE_ROOT, 'locale'), )# Primary keys are AutoFieldsDEFAULT_AUTO_FIELD = 'django.db.models.AutoField'@@ -409,15 +410,15 @@ COMPRESS_ROOT = STATIC_ROOT# Django Rest Framework#REST_FRAMEWORK = {- 'DEFAULT_PERMISSION_CLASSES': ('wger.utils.permissions.WgerPermission',),+ 'DEFAULT_PERMISSION_CLASSES': ('wger.utils.permissions.WgerPermission', ),'DEFAULT_PAGINATION_CLASS':- 'rest_framework.pagination.LimitOffsetPagination',+ 'rest_framework.pagination.LimitOffsetPagination','PAGE_SIZE':- 20,+ 20,'PAGINATE_BY_PARAM':- 'limit', # Allow client to override, using `?limit=xxx`.+ 'limit', # Allow client to override, using `?limit=xxx`.'TEST_REQUEST_DEFAULT_FORMAT':- 'json',+ 'json','DEFAULT_AUTHENTICATION_CLASSES': ('rest_framework.authentication.SessionAuthentication','rest_framework.authentication.TokenAuthentication',@@ -453,7 +454,7 @@ CORS_URLS_REGEX = r'^/api/.*$'## Ignore these URLs if they cause 404#-IGNORABLE_404_URLS = (re.compile(r'^/favicon\.ico$'),)+IGNORABLE_404_URLS = (re.compile(r'^/favicon\.ico$'), )## Password rulesdiff --git a/wger/software/templates/features.html b/wger/software/templates/features.htmlindex 4215381b6..5016d7e23 100644--- a/wger/software/templates/features.html+++ b/wger/software/templates/features.html@@ -8,10 +8,8 @@{{ block.super }}<meta property="og:title" content="{% translate 'Features' %} - wger">- {% with username=owner_user.username %}- <meta property="og:description"- content="{% blocktranslate %}wger Workout Manager is a free, open source web application that manages your exercises and workouts. {% endblocktranslate %}">- {% endwith %}+ <meta property="og:description"+ content="{% blocktranslate %}wger Workout Manager is a free, open source web application that manages your exercises and workouts.{% endblocktranslate %}">{% endblock %}@@ -56,7 +54,9 @@<!-- buttons --><div class="d-flex gap-2"><button type="button" class="btn btn-transparent">Login</button>- <button type="button" class="btn btn-primary rounded-1 bg-dark-blue px-4">Sign Up</button>+ {% if allow_registration %}+ <button type="button" class="btn btn-primary rounded-1 bg-dark-blue px-4">Sign Up</button>+ {% endif %}</div></div></div>@@ -82,20 +82,20 @@<!-- board section --><section class="row row-cols-lg-4 row-cols-2 board-section"><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 text-center mb-0">XY+</h2>+ <h2 class="display-3 font-Bebas_Neue text-dark-blue text-center mb-0">{{ nr_users }}+</h2><p class="text-center">people <br> using wger</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">100+</h2>+ <h2 class="display-3 font-Bebas_Neue text-dark-blue mb-0">{{ nr_exercises }}+</h2><p class="text-center">exercises <br> for workout creation</p></div><div class="col-lg-3 col-sm-3 d-flex flex-column align-items-center justify-content-center">- <h2 class="display-3 font-Bebas_Neue text-dark-blue mb-0">2 000 000+</h2>+ <h2 class="display-3 font-Bebas_Neue text-dark-blue mb-0">{{ nr_ingredients }}+</h2><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">1 700+</h2>- <p class="text-center">starts <br> on github</p>+ <h2 class="display-3 font-Bebas_Neue text-dark-blue mb-0">2000+</h2>+ <p class="text-center">stars <br> on GitHub</p></div></section></header>diff --git a/wger/software/views.py b/wger/software/views.pyindex 2ef723046..deb6f09df 100644--- a/wger/software/views.py+++ b/wger/software/views.py@@ -19,12 +19,18 @@ import logging# Djangofrom django.conf import settings+from django.contrib.auth.models import Userfrom django.shortcuts import render+from django.views.decorators.cache import cache_page+# wger+from wger.exercises.models import ExerciseBase+from wger.nutrition.models import Ingredientlogger = logging.getLogger(__name__)+# @cache_page(60 * 60 * 24 * 10)def features(request):"""Render the features page@@ -32,6 +38,9 @@ def features(request):context = {'allow_registration': settings.WGER_SETTINGS['ALLOW_REGISTRATION'],- 'allow_guest_users': settings.WGER_SETTINGS['ALLOW_GUEST_USERS']+ 'allow_guest_users': settings.WGER_SETTINGS['ALLOW_GUEST_USERS'],+ 'nr_users': User.objects.count(),+ 'nr_exercises': ExerciseBase.objects.count(),+ 'nr_ingredients': Ingredient.objects.count()}return render(request, 'features.html', context)diff --git a/wger/urls.py b/wger/urls.pyindex 1d72892c0..a47ce09fb 100644--- a/wger/urls.py+++ b/wger/urls.py@@ -48,6 +48,7 @@ from wger.nutrition.sitemap import NutritionSitemapfrom wger.utils.generic_views import TextTemplateViewfrom wger.weight.api import views as weight_api_views+# admin.autodiscover()#