From 2dbf8f0db3ccd0edb8f6bcd25c84023b76e99f99 Mon Sep 17 00:00:00 2001 From: Svn-Sp Date: Wed, 19 Aug 2020 18:23:58 +0200 Subject: [PATCH 001/105] Feature: Bmi on graph at weight overview Issue(#462) --- wger/weight/static/js/weight.js | 34 +++++++++++++++++++++++++++++ wger/weight/templates/overview.html | 4 +++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/wger/weight/static/js/weight.js b/wger/weight/static/js/weight.js index 742024d8a..1fbe75446 100644 --- a/wger/weight/static/js/weight.js +++ b/wger/weight/static/js/weight.js @@ -78,6 +78,40 @@ $(document).ready(function () { chartParams.data = data; MG.data_graphic(chartParams); } + }); + //show bmi lines + $(document.querySelector("#enable_bmi")).click(function(){ + var height = document.querySelector("#height").value / 100; + //kg = bmi * cm² + var max = height*height * 25; + var min = height*height * 20; + var yAxisChildren = document.querySelector("#weight_diagram").querySelector("svg").querySelector(".mg-y-axis").children; + //get index of first text element + for(let i = 0; i - +
+ +
From 93d2e1e9af4d13775dc8bd79172af912677cd439 Mon Sep 17 00:00:00 2001 From: Svn-Sp Date: Wed, 19 Aug 2020 18:31:29 +0200 Subject: [PATCH 002/105] Added Name on AUTHORS.rst --- AUTHORS.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AUTHORS.rst b/AUTHORS.rst index b9a3585af..6385ad846 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -25,7 +25,7 @@ Developers * Malcolm Jones: https://github.com/DevloperMal * Boniface Mwenda: https://github.com/andela-bmwenda * Scott Peshak: https://github.com/speshak - +* Sven - https://github.com/Svn-Sp Translators ----------- From 5e014d6e506020f483ac4f105734c0001fd16176 Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Sun, 30 Aug 2020 19:46:22 +0200 Subject: [PATCH 003/105] Remove vary on headers The templates do not depend on the user agent anymore --- wger/core/views/misc.py | 2 -- wger/manager/views/schedule.py | 2 -- wger/manager/views/workout.py | 2 -- 3 files changed, 6 deletions(-) diff --git a/wger/core/views/misc.py b/wger/core/views/misc.py index 8ba59c071..21ea31c86 100644 --- a/wger/core/views/misc.py +++ b/wger/core/views/misc.py @@ -32,7 +32,6 @@ from django.urls import ( reverse_lazy ) from django.utils.translation import ugettext as _ -from django.views.decorators.vary import vary_on_headers from django.views.generic import TemplateView from django.views.generic.edit import FormView @@ -94,7 +93,6 @@ def demo_entries(request): @login_required -@vary_on_headers('User-Agent') def dashboard(request): """ Show the index page, in our case, the last workout and nutritional plan diff --git a/wger/manager/views/schedule.py b/wger/manager/views/schedule.py index b1b462f8e..68946a14b 100644 --- a/wger/manager/views/schedule.py +++ b/wger/manager/views/schedule.py @@ -38,7 +38,6 @@ from django.utils.translation import ( ugettext as _, ugettext_lazy ) -from django.views.decorators.vary import vary_on_headers from django.views.generic import ( CreateView, DeleteView, @@ -88,7 +87,6 @@ def overview(request): return render(request, 'schedule/overview.html', template_data) -@vary_on_headers('User-Agent') def view(request, pk): """ Show the workout schedule diff --git a/wger/manager/views/workout.py b/wger/manager/views/workout.py index a2ca7255c..d9371bad0 100644 --- a/wger/manager/views/workout.py +++ b/wger/manager/views/workout.py @@ -39,7 +39,6 @@ from django.utils.translation import ( ugettext as _, ugettext_lazy ) -from django.views.decorators.vary import vary_on_headers from django.views.generic import ( DeleteView, UpdateView @@ -91,7 +90,6 @@ def overview(request): return render(request, 'workout/overview.html', template_data) -@vary_on_headers('User-Agent') def view(request, pk): """ Show the workout with the given ID From eaeffd2c71111bde40a7b226403c90270fe5a731 Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Sun, 30 Aug 2020 20:42:06 +0200 Subject: [PATCH 004/105] Fix typo --- wger/core/templates/500.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wger/core/templates/500.html b/wger/core/templates/500.html index e2e839e85..f7431e85e 100644 --- a/wger/core/templates/500.html +++ b/wger/core/templates/500.html @@ -1,7 +1,7 @@ {% extends "base.html" %} {% load i18n static %} -{% block title %}{% trans "An error occured" %}{% endblock %} +{% block title %}{% trans "An error occurred" %}{% endblock %} {% block content %}

{% trans "Something happened that caused an error." %}

From 7d3ec2d13b89a0edad55cb49b92b8aa40219c33a Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Sun, 30 Aug 2020 21:01:17 +0200 Subject: [PATCH 005/105] Add template with no context This can be used for error templates or other that just display a general error message and where the context might not be available. This also has the additional benefit, that there is no unending list of errors during testing when something happens while testing. --- wger/core/templates/403.html | 2 +- wger/core/templates/404.html | 2 +- wger/core/templates/500.html | 2 +- wger/core/templates/template_no_context.html | 98 ++++++++++++++++++++ 4 files changed, 101 insertions(+), 3 deletions(-) create mode 100644 wger/core/templates/template_no_context.html diff --git a/wger/core/templates/403.html b/wger/core/templates/403.html index e0b2ef552..49f6a69db 100644 --- a/wger/core/templates/403.html +++ b/wger/core/templates/403.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "template_no_context.html" %} {% load i18n static %} {% block title %}{% trans "Forbidden!" %}{% endblock %} diff --git a/wger/core/templates/404.html b/wger/core/templates/404.html index aaa39f1b9..064275198 100644 --- a/wger/core/templates/404.html +++ b/wger/core/templates/404.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "template_no_context.html" %} {% load i18n static %} {% block title %}{% trans "Page not found" %}{% endblock %} diff --git a/wger/core/templates/500.html b/wger/core/templates/500.html index f7431e85e..85e7f53a6 100644 --- a/wger/core/templates/500.html +++ b/wger/core/templates/500.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "template_no_context.html" %} {% load i18n static %} {% block title %}{% trans "An error occurred" %}{% endblock %} diff --git a/wger/core/templates/template_no_context.html b/wger/core/templates/template_no_context.html new file mode 100644 index 000000000..69807f876 --- /dev/null +++ b/wger/core/templates/template_no_context.html @@ -0,0 +1,98 @@ + + + +{% load i18n static wger_extras compress django_bootstrap_breadcrumbs %} + + + + + + + + + + + + + + + {% block header %}{% endblock %} + + {% trans "An error occurred" %} + + + +{# #} +{# Navigation #} +{# #} +
+ + + + + +{# #} +{# Main content #} +{# #} +
+
+
+
+ +
+
+
+
+
+
+
+ {% block content %}{% endblock %} +
+
+
+
+ + + + + + + + + + + From 6d2108f35b6458839ca5eaecf9674e9899496561 Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Sun, 30 Aug 2020 21:13:48 +0200 Subject: [PATCH 006/105] Re-add test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hoping this closes #468 🤞 --- wger/manager/tests/test_schedule.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/wger/manager/tests/test_schedule.py b/wger/manager/tests/test_schedule.py index e19bb8458..88aa6d9f7 100644 --- a/wger/manager/tests/test_schedule.py +++ b/wger/manager/tests/test_schedule.py @@ -178,15 +178,12 @@ class ScheduleTestCase(WgerTestCase): self.assertEqual(response.status_code, 200) self.assertNotContains(response, 'This schedule is a loop') - # Commented out since travis was seemingly randomly failing this. See #468 - # - # def test_schedule_detail_page_owner(self): - # """ - # Tests the schedule detail page as the owning user - # """ - # - # self.user_login() - # self.schedule_detail_page() + def test_schedule_detail_page_owner(self): + """ + Tests the schedule detail page as the owning user + """ + self.user_login() + self.schedule_detail_page() def test_schedule_overview(self): """ From 659ca86be0d954824efa5b291c64df6f8148ca2a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Aug 2020 05:01:05 +0000 Subject: [PATCH 007/105] Update django-storages requirement from ~=1.9 to ~=1.10 Updates the requirements on [django-storages](https://github.com/jschneier/django-storages) to permit the latest version. - [Release notes](https://github.com/jschneier/django-storages/releases) - [Changelog](https://github.com/jschneier/django-storages/blob/master/CHANGELOG.rst) - [Commits](https://github.com/jschneier/django-storages/compare/1.9...1.10) Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index d8e6055da..bf815098e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,7 +15,7 @@ django-crispy-forms~=1.9 django_compressor~=2.4 django_extensions~=3.0 django-sortedm2m~=3.0 -django-storages~=1.9 +django-storages~=1.10 easy-thumbnails~=2.7 icalendar==4.0.6 invoke~=1.4 From 2d0259bf14d9a27918867b94f74877f4f1a6291c Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Mon, 31 Aug 2020 23:10:51 +0200 Subject: [PATCH 008/105] Simplify options menu for workout days This is more discoverable on mobile and works on desktop as well. Also, comment the drag and drop handles, they are making a too much trouble and need to be rewritten anyway. --- wger/core/templates/tags/render_day.html | 31 +++++++++++++++--------- wger/manager/templates/workout/view.html | 7 +++--- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/wger/core/templates/tags/render_day.html b/wger/core/templates/tags/render_day.html index d8637b60a..f8ee03a30 100644 --- a/wger/core/templates/tags/render_day.html +++ b/wger/core/templates/tags/render_day.html @@ -34,6 +34,7 @@ $(document).ready(function() { {% trans 'Edit' %} + {% trans 'Delete' %} @@ -50,23 +51,31 @@ $(document).ready(function() { {% for set in day.set_list %} -

#{{ forloop.counter }}

+ #{{ forloop.counter }} {% if editable %} +
+ + {% if false and day.set_list|length > 1 %} - {% if day.set_list|length > 1 %}
- {% endif %} - - -
- -
+ {% endif %} {% endif %} diff --git a/wger/manager/templates/workout/view.html b/wger/manager/templates/workout/view.html index 0db8acce9..fe75ba13c 100644 --- a/wger/manager/templates/workout/view.html +++ b/wger/manager/templates/workout/view.html @@ -125,9 +125,9 @@ $(document).ready(function () { application for example google calendar, outlook or iCal. This will create an appointment for each training day with the appropriate exercises.{% endblocktrans %}

- - {% trans "Export calendar file" %} - + + {% trans "Export calendar file" %} +

-
+
diff --git a/wger/weight/tests/test_entry.py b/wger/weight/tests/test_entry.py index c622147d1..ec087f8a5 100644 --- a/wger/weight/tests/test_entry.py +++ b/wger/weight/tests/test_entry.py @@ -24,7 +24,8 @@ from wger.core.tests import api_base_test from wger.core.tests.base_testcase import ( WgerAddTestCase, WgerEditTestCase, - WgerTestCase + WgerTestCase, + WgerDeleteTestCase ) from wger.utils.constants import TWOPLACES from wger.weight.models import WeightEntry @@ -112,6 +113,18 @@ class EditWeightEntryTestCase(WgerEditTestCase): 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 resource diff --git a/wger/weight/urls.py b/wger/weight/urls.py index a6a288b92..2e9b99075 100644 --- a/wger/weight/urls.py +++ b/wger/weight/urls.py @@ -33,6 +33,10 @@ urlpatterns = [ login_required(views.WeightUpdateView.as_view()), name='edit'), + url(r'^(?P\d+)/delete/$', + views.WeightDeleteView.as_view(), + name='delete'), + url(r'^export-csv/$', views.export_csv, name='export-csv'), diff --git a/wger/weight/views.py b/wger/weight/views.py index c34ff56dd..39eb90a9e 100644 --- a/wger/weight/views.py +++ b/wger/weight/views.py @@ -38,7 +38,8 @@ from django.utils.translation import ( ) from django.views.generic import ( CreateView, - UpdateView + UpdateView, + DeleteView ) # Third Party @@ -47,7 +48,10 @@ from rest_framework.decorators import api_view from rest_framework.response import Response # wger -from wger.utils.generic_views import WgerFormMixin +from wger.utils.generic_views import ( + WgerFormMixin, + WgerDeleteMixin +) from wger.utils.helpers import check_access from wger.weight import helpers from wger.weight.forms import WeightForm @@ -109,6 +113,28 @@ class WeightUpdateView(WgerFormMixin, LoginRequiredMixin, UpdateView): return reverse('weight:overview', kwargs={'username': self.object.user.username}) +class WeightDeleteView(WgerDeleteMixin, LoginRequiredMixin, DeleteView): + """ + Generic view to delete a weight entry + """ + + model = WeightEntry + fields = ('weight',) + + messages = ugettext_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', kwargs={'username': self.object.user.username}) + + @login_required def export_csv(request): """ From 2912fca63e4d8cb747a2464e2a013586cb4bfd08 Mon Sep 17 00:00:00 2001 From: beingbiplov Date: Fri, 16 Oct 2020 14:40:44 +0545 Subject: [PATCH 102/105] remove whitespace --- wger/weight/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wger/weight/views.py b/wger/weight/views.py index 39eb90a9e..94d095ef6 100644 --- a/wger/weight/views.py +++ b/wger/weight/views.py @@ -120,7 +120,7 @@ class WeightDeleteView(WgerDeleteMixin, LoginRequiredMixin, DeleteView): model = WeightEntry fields = ('weight',) - + messages = ugettext_lazy('Successfully deleted.') def get_context_data(self, **kwargs): From 5c04646d5954fc7bc3a0c72ba8e7ec7bcdc1ba65 Mon Sep 17 00:00:00 2001 From: beingbiplov Date: Fri, 16 Oct 2020 14:43:49 +0545 Subject: [PATCH 103/105] add to AUTHORS.rst --- AUTHORS.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.rst b/AUTHORS.rst index a7fc3f50e..1146adc9e 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -29,6 +29,7 @@ Developers * Kevin Antonio Rateni Iatauro: https://github.com/WalkingPizza * Sven - https://github.com/Svn-Sp * Christopher OConnell - https://github.com/oconnelc +* Biplov - https://github.com/beingbiplov Translators ----------- From 9f2cd270a7885eae6716a8126c726f2537c88aee Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Sat, 17 Oct 2020 14:33:03 +0200 Subject: [PATCH 104/105] Update changelog --- docs/changelog.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 8b46aa49c..fc70625f2 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -21,6 +21,7 @@ Upgrade steps from 1.9: `#506`_ (thanks `@oconnelc`_) * Improved user experience, on desktop and mobile `#337`_ * Show BMI on weight graph `#462`_ (thanks `@Svn-Sp`_) +* Allow user to edit and delete body weight entries `#478`_ (thanks `@beingbiplov`_) 🐛 Bug Fixes: @@ -40,12 +41,14 @@ Upgrade steps from 1.9: .. _@louiCoder: https://github.com/louiCoder .. _@WalkingPizza: https://github.com/WalkingPizza .. _@oconnelc: https://github.com/oconnelc +.. _@beingbiplov: https://github.com/beingbiplov .. _#246: https://github.com/wger-project/wger/issues/246 .. _#284: https://github.com/wger-project/wger/issues/284 .. _#337: https://github.com/wger-project/wger/issues/337 .. _#340: https://github.com/wger-project/wger/issues/340 .. _#462: https://github.com/wger-project/wger/issues/462 +.. _#478: https://github.com/wger-project/wger/issues/478 .. _#494: https://github.com/wger-project/wger/issues/494 .. _#499: https://github.com/wger-project/wger/issues/499 .. _#501: https://github.com/wger-project/wger/issues/501 From aefad2bc5bb44d1693ff9c76c3db0b2555ddb6ba Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Sat, 17 Oct 2020 14:33:31 +0200 Subject: [PATCH 105/105] Remove icon from dropdown, has too much weight --- wger/weight/templates/overview.html | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/wger/weight/templates/overview.html b/wger/weight/templates/overview.html index 56202f8c9..b18781338 100644 --- a/wger/weight/templates/overview.html +++ b/wger/weight/templates/overview.html @@ -75,11 +75,9 @@
- -