Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

The image license for open food facts is cc by sa 3

Roland Geideref84753481ed
diff --git a/wger/nutrition/models/image.py b/wger/nutrition/models/image.py
index c76b31dce..b83e68c6e 100644
--- a/wger/nutrition/models/image.py
+++ b/wger/nutrition/models/image.py
@@ -83,7 +83,7 @@ class Image(AbstractLicenseModel, models.Model, BaseImage):
image: cls = super().from_json(connect_to, retrieved_image, json_data, generate_uuid)
image.ingredient = connect_to
- image.license = License.objects.get(pk=1)
+ image.license_id = json_data['license']
image.license_author = json_data['license_author']
image.size = json_data['size']
diff --git a/wger/nutrition/sync.py b/wger/nutrition/sync.py
index 25a916c38..9a0111c3b 100644
--- a/wger/nutrition/sync.py
+++ b/wger/nutrition/sync.py
@@ -32,13 +32,13 @@ from wger.nutrition.models import (
Source,
)
from wger.utils.constants import (
+ CC_BY_SA_3_LICENSE_ID,
DOWNLOAD_INGREDIENT_OFF,
DOWNLOAD_INGREDIENT_WGER,
)
from wger.utils.requests import wger_headers
from wger.utils.url import make_uri
-
logger = logging.getLogger(__name__)
@@ -119,6 +119,7 @@ def fetch_image_from_off(ingredient):
# Save to DB
image_data = {
'image': os.path.basename(image_url),
+ 'license': CC_BY_SA_3_LICENSE_ID,
'license_author': uploader_name,
'size': len(response.content)
}
diff --git a/wger/utils/constants.py b/wger/utils/constants.py
index 1ac1e4fdb..637b7099e 100644
--- a/wger/utils/constants.py
+++ b/wger/utils/constants.py
@@ -17,7 +17,6 @@
# Standard Library
from decimal import Decimal
-
# Navigation
WORKOUT_TAB = 'workout'
EXERCISE_TAB = 'exercises'
@@ -43,7 +42,7 @@ DATE_FORMATS = [
# editor. Everything not in these whitelists is stripped.
HTML_TAG_WHITELIST = {'b', 'i', 'strong', 'em', 'ul', 'ol', 'li', 'p'}
HTML_ATTRIBUTES_WHITELIST = {'*': 'style'}
-HTML_STYLES_WHITELIST = ('text-decoration', )
+HTML_STYLES_WHITELIST = ('text-decoration',)
# Pagination
PAGINATION_OBJECTS_PER_PAGE = 25
@@ -56,6 +55,7 @@ MIN_EDIT_DISTANCE_THRESHOLD = 2
# CC-BY-SA-4
DEFAULT_LICENSE_ID = 2
+CC_BY_SA_3_LICENSE_ID = 1
# Default language
ENGLISH_SHORT_NAME = 'en'