Self hosted FLOSS fitness/workout, nutrition and weight tracker
Allow more flexible filtering of weight entries
Roland Geider540f210a15c4
diff --git a/wger/weight/api/filtersets.py b/wger/weight/api/filtersets.pynew file mode 100644index 000000000..831b9808f--- /dev/null+++ b/wger/weight/api/filtersets.py@@ -0,0 +1,30 @@+# 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+# along with Workout Manager. If not, see <http://www.gnu.org/licenses/>.++# Third Party+from django_filters import rest_framework as filters++# wger+from wger.weight.models import WeightEntry+++class WeightEntryFilterSet(filters.FilterSet):+ class Meta:+ model = WeightEntry+ fields = {+ 'id': ['exact', 'in'],+ 'weight': ['exact', 'gt', 'gte', 'lt', 'lte'],+ 'date': ['exact', 'gt', 'gte', 'lt', 'lte'],+ }diff --git a/wger/weight/api/views.py b/wger/weight/api/views.pyindex 850ad9efb..70c0f05d9 100644--- a/wger/weight/api/views.py+++ b/wger/weight/api/views.py@@ -19,6 +19,7 @@from rest_framework import viewsets# wger+from wger.weight.api.filtersets import WeightEntryFilterSetfrom wger.weight.api.serializers import WeightEntrySerializerfrom wger.weight.models import WeightEntry@@ -32,7 +33,7 @@ class WeightEntryViewSet(viewsets.ModelViewSet):is_private = Trueordering_fields = '__all__'- filterset_fields = ('date', 'weight')+ filterset_class = WeightEntryFilterSetdef get_queryset(self):"""