Self hosted FLOSS fitness/workout, nutrition and weight tracker
Remove unused code
Roland Geiderbab088abec93
diff --git a/wger/core/templates/navigation.html b/wger/core/templates/navigation.htmlindex 00f0d28df..5dc75e71b 100644--- a/wger/core/templates/navigation.html+++ b/wger/core/templates/navigation.html@@ -212,10 +212,6 @@{% translate "Weight overview" %}</a></li>- <li>- {% translate 'Add weight entry' as text %}- {% modal_link url='weight:add' text=text css_class='dropdown-item' %}- </li></ul></li>{% endif %}@@ -281,7 +277,8 @@<li class="dropdown nav-item"><a href="#" class="dropdown-toggle nav-link text-white"data-bs-toggle="dropdown">- {% translate "Login" %}{% if allow_registration %} / {% translate "Register" %}{% endif %}+ {% translate "Login" %}{% if allow_registration %} /+ {% translate "Register" %}{% endif %}<span class="caret"></span></a><ul class="dropdown-menu">@@ -291,12 +288,12 @@</a></li>{% if allow_registration %}- <li>- <a class="dropdown-item"- href="{% url 'core:user:registration' %}">- {% translate "Register" %}- </a>- </li>+ <li>+ <a class="dropdown-item"+ href="{% url 'core:user:registration' %}">+ {% translate "Register" %}+ </a>+ </li>{% endif %}<li><a class="dropdown-item"diff --git a/wger/manager/templates/workout/email_weight_reminder.tpl b/wger/manager/templates/workout/email_weight_reminder.tplindex dad2e0a44..dfebb2fa3 100644--- a/wger/manager/templates/workout/email_weight_reminder.tpl+++ b/wger/manager/templates/workout/email_weight_reminder.tpl@@ -13,5 +13,4 @@ option in your settings.{% endblocktranslate %}* https://{{site}}{% url 'weight:overview' %}-* https://{{site}}{% url 'weight:add' %}* https://{{site}}{% url 'core:user:preferences' %}diff --git a/wger/weight/forms.py b/wger/weight/forms.pyindex 7a3809b3f..bb47506a9 100644--- a/wger/weight/forms.py+++ b/wger/weight/forms.py@@ -14,27 +14,20 @@## You should have received a copy of the GNU Affero General Public License+# Third Party+from crispy_forms.helper import FormHelper+from crispy_forms.layout import Layout+# Djangofrom django import formsfrom django.forms import (CharField,- DateField,Form,- ModelForm,Textarea,- widgets,)from django.utils.translation import gettext as _-# Third Party-from crispy_forms.helper import FormHelper-from crispy_forms.layout import Layout-# wger-from wger.utils.constants import DATE_FORMATS-from wger.utils.widgets import Html5DateInput-from wger.weight.models import WeightEntry-CSV_DATE_FORMAT = (('%d.%m.%Y', 'DD.MM.YYYY (30.01.2012)'),@@ -63,14 +56,3 @@ class WeightCsvImportForm(Form):'date_format',)self.helper.form_tag = False---class WeightForm(ModelForm):- date = DateField(input_formats=DATE_FORMATS, widget=Html5DateInput())-- class Meta:- model = WeightEntry- exclude = []- widgets = {- 'user': widgets.HiddenInput(),- }diff --git a/wger/weight/tests/test_entry.py b/wger/weight/tests/test_entry.pyindex 8af3955d0..853d2e281 100644--- a/wger/weight/tests/test_entry.py+++ b/wger/weight/tests/test_entry.py@@ -14,20 +14,10 @@# Standard Libraryimport datetime-import decimal--# Django-from django.urls import reverse# wgerfrom wger.core.tests import api_base_test-from wger.core.tests.base_testcase import (- WgerAddTestCase,- WgerDeleteTestCase,- WgerEditTestCase,- WgerTestCase,-)-from wger.utils.constants import TWOPLACES+from wger.core.tests.base_testcase import WgerTestCasefrom wger.weight.models import WeightEntry@@ -43,50 +33,6 @@ class MealRepresentationTestCase(WgerTestCase):self.assertEqual(str(WeightEntry.objects.get(pk=1)), '2012-10-01: 77.00 kg')-class AddWeightEntryTestCase(WgerAddTestCase):- """- Tests adding a weight entry- """-- object_class = WeightEntry- url = 'weight:add'- user_fail = False- data = {- 'weight': decimal.Decimal(81.1).quantize(TWOPLACES),- 'date': datetime.date(2013, 2, 1),- 'user': 1,- }---class EditWeightEntryTestCase(WgerEditTestCase):- """- Tests editing a weight entry- """-- object_class = WeightEntry- url = 'weight:edit'- pk = 1- data = {- 'weight': 100,- 'date': datetime.date(2013, 2, 1),- 'user': 1,- }- user_success = 'test'- user_fail = 'admin'---class DeleteWeightEntryTestCase(WgerDeleteTestCase):- """- Tests deleting a weight entry- """-- object_class = WeightEntry- url = 'weight:delete'- pk = 1- user_success = 'test'- user_fail = 'admin'--class WeightEntryTestCase(api_base_test.ApiBaseResourceTestCase):"""Tests the weight entry overview resourcediff --git a/wger/weight/urls.py b/wger/weight/urls.pyindex 1c2435da0..673ef42fe 100644--- a/wger/weight/urls.py+++ b/wger/weight/urls.py@@ -29,21 +29,6 @@ from wger.weight.forms import WeightCsvImportFormurlpatterns = [- path(- 'add/',- login_required(views.WeightAddView.as_view()),- name='add',- ),- path(- '<int:pk>/edit/',- login_required(views.WeightUpdateView.as_view()),- name='edit',- ),- path(- '<int:pk>/delete/',- views.WeightDeleteView.as_view(),- name='delete',- ),path('export-csv/',views.export_csv,diff --git a/wger/weight/views.py b/wger/weight/views.pyindex 25d764896..c58b35f7e 100644--- a/wger/weight/views.py+++ b/wger/weight/views.py@@ -16,118 +16,28 @@# Standard Libraryimport csv-import datetimeimport logging# Djangofrom django.contrib.auth.decorators import login_required-from django.contrib.auth.mixins import LoginRequiredMixinfrom django.http import (HttpResponse,HttpResponseRedirect,)-from django.shortcuts import renderfrom django.urls import reverse-from django.utils.translation import (- gettext as _,- gettext_lazy,-)-from django.views.generic import (- CreateView,- DeleteView,- UpdateView,-)+from django.utils.translation import gettext as _# Third Partyfrom formtools.preview import FormPreview# wger-from wger.utils.generic_views import (- WgerDeleteMixin,- WgerFormMixin,-)-from wger.utils.helpers import check_accessfrom wger.weight import helpers-from wger.weight.forms import WeightFormfrom wger.weight.models import WeightEntrylogger = logging.getLogger(__name__)-class WeightAddView(WgerFormMixin, CreateView):- """- Generic view to add a new weight entry- """-- model = WeightEntry- form_class = WeightForm- title = gettext_lazy('Add weight entry')-- def get_initial(self):- """- Set the initial data for the form.-- Read the comment on weight/models.py WeightEntry about why we need- to pass the user here.- """- return {'user': self.request.user, 'date': datetime.date.today()}-- def form_valid(self, form):- """- Set the owner of the entry here- """- form.instance.user = self.request.user- return super(WeightAddView, self).form_valid(form)-- def get_success_url(self):- """- Return to overview with username- """- return reverse('weight:overview')---class WeightUpdateView(WgerFormMixin, LoginRequiredMixin, UpdateView):- """- Generic view to edit an existing weight entry- """-- model = WeightEntry- form_class = WeightForm-- def get_context_data(self, **kwargs):- context = super(WeightUpdateView, self).get_context_data(**kwargs)- context['title'] = _('Edit weight entry for the %s') % self.object.date-- return context-- def get_success_url(self):- """- Return to overview with username- """- return reverse('weight:overview')---class WeightDeleteView(WgerDeleteMixin, LoginRequiredMixin, DeleteView):- """- Generic view to delete a weight entry- """-- model = WeightEntry- messages = gettext_lazy('Successfully deleted.')-- def get_context_data(self, **kwargs):- context = super(WeightDeleteView, self).get_context_data(**kwargs)- context['title'] = _('Delete weight entry for the %s') % self.object.date- return context-- def get_success_url(self):- """- Return to overview with username- """- return reverse('weight:overview')--@login_requireddef export_csv(request):"""