Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#159236202 Filter Exercise and Ingredient translations better #28

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion wger/exercises/views/exercises.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
TranslatedOriginalSelectMultiple
)
from wger.config.models import LanguageConfig
from wger.config.models import Language
from wger.weight.helpers import process_log_entries


Expand All @@ -77,7 +78,10 @@ def get_queryset(self):
'''
Filter to only active exercises in the configured languages
'''
languages = load_item_languages(LanguageConfig.SHOW_ITEM_EXERCISES)
url = self.request.META['PATH_INFO']
lang_name = url[1:3]
languages = Language.objects.filter(short_name=lang_name)

return Exercise.objects.accepted() \
.filter(language__in=languages) \
.order_by('category__id') \
Expand Down
6 changes: 4 additions & 2 deletions wger/nutrition/views/ingredient.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
from wger.utils.constants import PAGINATION_OBJECTS_PER_PAGE
from wger.utils.language import load_language, load_ingredient_languages
from wger.utils.cache import cache_mapper

from wger.config.models import Language

logger = logging.getLogger(__name__)

Expand All @@ -64,7 +64,9 @@ def get_queryset(self):
(the user can also want to see ingredients in English, in addition to his
native language, see load_ingredient_languages)
'''
languages = load_ingredient_languages(self.request)
url = self.request.META['PATH_INFO']
lang_name = url[1:3]
languages = Language.objects.filter(short_name=lang_name)
return (Ingredient.objects.filter(language__in=languages)
.filter(status__in=Ingredient.INGREDIENT_STATUS_OK)
.only('id', 'name'))
Expand Down