Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Allow ordering of endpoints

Roland Geider1f8022986f4d
diff --git a/wger/core/api/views.py b/wger/core/api/views.py
index 934da1e5b..65fad49f4 100644
--- a/wger/core/api/views.py
+++ b/wger/core/api/views.py
@@ -27,6 +27,7 @@ class UserProfileViewSet(viewsets.ModelViewSet):
'''
model = UserProfile
is_private = True
+ ordering_fields = '__all__'
def get_queryset(self):
'''
@@ -43,6 +44,7 @@ class LanguageViewSet(viewsets.ReadOnlyModelViewSet):
API endpoint for workout objects
'''
model = Language
+ ordering_fields = '__all__'
class DaysOfWeekViewSet(viewsets.ReadOnlyModelViewSet):
@@ -50,6 +52,7 @@ class DaysOfWeekViewSet(viewsets.ReadOnlyModelViewSet):
API endpoint for workout objects
'''
model = DaysOfWeek
+ ordering_fields = '__all__'
class LicenseViewSet(viewsets.ReadOnlyModelViewSet):
@@ -57,3 +60,4 @@ class LicenseViewSet(viewsets.ReadOnlyModelViewSet):
API endpoint for workout objects
'''
model = License
+ ordering_fields = '__all__'
diff --git a/wger/exercises/api/views.py b/wger/exercises/api/views.py
index b06bd2242..408c5d0e7 100644
--- a/wger/exercises/api/views.py
+++ b/wger/exercises/api/views.py
@@ -34,6 +34,7 @@ class ExerciseViewSet(viewsets.ModelViewSet):
API endpoint for exercise objects
'''
model = Exercise
+ ordering_fields = '__all__'
def pre_save(self, obj):
'''
@@ -48,6 +49,7 @@ class EquipmentViewSet(viewsets.ReadOnlyModelViewSet):
API endpoint for equipment objects
'''
model = Equipment
+ ordering_fields = '__all__'
class ExerciseCategoryViewSet(viewsets.ReadOnlyModelViewSet):
@@ -55,6 +57,7 @@ class ExerciseCategoryViewSet(viewsets.ReadOnlyModelViewSet):
API endpoint for exercise categories objects
'''
model = ExerciseCategory
+ ordering_fields = '__all__'
class ExerciseImageViewSet(viewsets.ModelViewSet):
@@ -62,6 +65,7 @@ class ExerciseImageViewSet(viewsets.ModelViewSet):
API endpoint for exercise image objects
'''
model = ExerciseImage
+ ordering_fields = '__all__'
@link()
def thumbnails(self, request, pk):
@@ -90,6 +94,7 @@ class ExerciseCommentViewSet(viewsets.ReadOnlyModelViewSet):
API endpoint for exercise comment objects
'''
model = ExerciseComment
+ ordering_fields = '__all__'
class MuscleViewSet(viewsets.ReadOnlyModelViewSet):
@@ -97,3 +102,4 @@ class MuscleViewSet(viewsets.ReadOnlyModelViewSet):
API endpoint for muscle objects
'''
model = Muscle
+ ordering_fields = '__all__'
diff --git a/wger/manager/api/views.py b/wger/manager/api/views.py
index 6216e3e3e..dc9a2ebc1 100644
--- a/wger/manager/api/views.py
+++ b/wger/manager/api/views.py
@@ -110,6 +110,7 @@ class ScheduleStepViewSet(WgerOwnerObjectModelViewSet):
'''
model = ScheduleStep
is_private = True
+ ordering_fields = '__all__'
def get_queryset(self):
'''
diff --git a/wger/nutrition/api/views.py b/wger/nutrition/api/views.py
index 4df5e72cc..67e9947b3 100644
--- a/wger/nutrition/api/views.py
+++ b/wger/nutrition/api/views.py
@@ -36,6 +36,7 @@ class IngredientViewSet(viewsets.ReadOnlyModelViewSet):
API endpoint for ingredient objects
'''
model = Ingredient
+ ordering_fields = '__all__'
class WeightUnitViewSet(viewsets.ReadOnlyModelViewSet):
@@ -43,6 +44,7 @@ class WeightUnitViewSet(viewsets.ReadOnlyModelViewSet):
API endpoint for weight unit objects
'''
model = WeightUnit
+ ordering_fields = '__all__'
class IngredientWeightUnitViewSet(viewsets.ReadOnlyModelViewSet):
@@ -50,6 +52,7 @@ class IngredientWeightUnitViewSet(viewsets.ReadOnlyModelViewSet):
API endpoint for many-to-many table ingredient-weight unit objects
'''
model = IngredientWeightUnit
+ ordering_fields = '__all__'
class NutritionPlanViewSet(viewsets.ModelViewSet):
@@ -59,6 +62,7 @@ class NutritionPlanViewSet(viewsets.ModelViewSet):
model = NutritionPlan
serializer_class = NutritionPlanSerializer
is_private = True
+ ordering_fields = '__all__'
def get_queryset(self):
'''
@@ -86,6 +90,7 @@ class MealViewSet(WgerOwnerObjectModelViewSet):
'''
model = Meal
is_private = True
+ ordering_fields = '__all__'
def get_queryset(self):
'''
@@ -119,6 +124,7 @@ class MealItemViewSet(WgerOwnerObjectModelViewSet):
'''
model = MealItem
is_private = True
+ ordering_fields = '__all__'
def get_queryset(self):
'''
diff --git a/wger/settings_global.py b/wger/settings_global.py
index 7cb2e27db..7a0b6a988 100644
--- a/wger/settings_global.py
+++ b/wger/settings_global.py
@@ -343,5 +343,6 @@ REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.TokenAuthentication',
- )
+ ),
+ 'DEFAULT_FILTER_BACKENDS': ('rest_framework.filters.OrderingFilter',)
}
diff --git a/wger/weight/api/views.py b/wger/weight/api/views.py
index cbead88f5..81dbf950f 100644
--- a/wger/weight/api/views.py
+++ b/wger/weight/api/views.py
@@ -28,6 +28,7 @@ class WeightEntryViewSet(viewsets.ModelViewSet):
model = WeightEntry
serializer_class = WeightEntrySerializer
is_private = True
+ ordering_fields = '__all__'
def get_queryset(self):
'''