Self hosted FLOSS fitness/workout, nutrition and weight tracker
Use submission manager for ingredients
Roland Geider10fd2e5017b1
diff --git a/wger/nutrition/api/views.py b/wger/nutrition/api/views.pyindex 4210b343c..7a4a95d37 100644--- a/wger/nutrition/api/views.py+++ b/wger/nutrition/api/views.py@@ -58,7 +58,7 @@ class IngredientViewSet(viewsets.ReadOnlyModelViewSet):"""API endpoint for ingredient objects"""- queryset = Ingredient.objects.all()+ queryset = Ingredient.objects.accepted()serializer_class = IngredientSerializerordering_fields = '__all__'filterset_fields = ('carbohydrates',diff --git a/wger/nutrition/models.py b/wger/nutrition/models.pyindex 9432358a3..918ce5b5b 100644--- a/wger/nutrition/models.py+++ b/wger/nutrition/models.py@@ -46,6 +46,7 @@ from wger.core.models import Languagefrom wger.utils.cache import cache_mapperfrom wger.utils.constants import TWOPLACESfrom wger.utils.fields import Html5TimeField+from wger.utils.managers import SubmissionManagerfrom wger.utils.models import (AbstractLicenseModel,AbstractSubmissionModel@@ -263,6 +264,9 @@ class Ingredient(AbstractSubmissionModel, AbstractLicenseModel, models.Model):"""An ingredient, with some approximate nutrition values"""+ objects = SubmissionManager()+ """Custom manager"""+ENERGY_APPROXIMATION = 15"""diff --git a/wger/nutrition/views/ingredient.py b/wger/nutrition/views/ingredient.pyindex c4441bf4b..c1f266447 100644--- a/wger/nutrition/views/ingredient.py+++ b/wger/nutrition/views/ingredient.py@@ -83,8 +83,8 @@ class IngredientListView(ListView):native language, see load_ingredient_languages)"""languages = load_ingredient_languages(self.request)- return (Ingredient.objects.filter(language__in=languages)- .filter(status=Ingredient.STATUS_ACCEPTED)+ return (Ingredient.objects.accepted()+ .filter(language__in=languages).only('id', 'name'))def get_context_data(self, **kwargs):