Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Pass user agent to OFF api

Roland Geider63f66f9fa29f
diff --git a/wger/nutrition/models/ingredient.py b/wger/nutrition/models/ingredient.py
index ac12126ef..8ca63b981 100644
--- a/wger/nutrition/models/ingredient.py
+++ b/wger/nutrition/models/ingredient.py
@@ -56,6 +56,7 @@ from wger.utils.constants import (
TWOPLACES,
)
from wger.utils.language import load_language
+from wger.utils.requests import wger_user_agent
from wger.utils.managers import SubmissionManager
from wger.utils.models import (
AbstractLicenseModel,
@@ -65,7 +66,6 @@ from wger.utils.models import (
# Local
from .ingredient_category import IngredientCategory
-
logger = logging.getLogger(__name__)
@@ -465,7 +465,7 @@ class Ingredient(AbstractSubmissionModel, AbstractLicenseModel, models.Model):
logger.info(f'Searching for ingredient {code} in OFF')
try:
- api = API()
+ api = API(user_agent=wger_user_agent())
result = api.product.get(code)
except JSONDecodeError as e:
logger.info(f'Got JSONDecodeError from OFF: {e}')