Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Rename constant

Roland Geider86e7ef8f5925
diff --git a/wger/exercises/management/commands/read-exercise-cleanup.py b/wger/exercises/management/commands/read-exercise-cleanup.py
index 3ed64499b..15b834b41 100644
--- a/wger/exercises/management/commands/read-exercise-cleanup.py
+++ b/wger/exercises/management/commands/read-exercise-cleanup.py
@@ -35,8 +35,7 @@ from wger.exercises.models import (
ExerciseVideo,
Variation,
)
-from wger.utils.constants import DEFAULT_LICENSE_ID
-
+from wger.utils.constants import CC_BY_SA_4_ID
UUID_NEW = 'NEW'
VIDEO_AUTHOR = 'Goulart'
@@ -94,7 +93,7 @@ class Command(BaseCommand):
assert (name in file_reader.fieldnames
), '{0} not in {1}'.format(name, file_reader.fieldnames)
- default_license = License.objects.get(pk=DEFAULT_LICENSE_ID)
+ default_license = License.objects.get(pk=CC_BY_SA_4_ID)
#
# Process the exercises
diff --git a/wger/exercises/tests/test_exercise_base.py b/wger/exercises/tests/test_exercise_base.py
index 0bd9bfd90..a0bb8eb9b 100644
--- a/wger/exercises/tests/test_exercise_base.py
+++ b/wger/exercises/tests/test_exercise_base.py
@@ -22,7 +22,7 @@ from wger.exercises.models import (
Exercise,
ExerciseBase,
)
-from wger.utils.constants import DEFAULT_LICENSE_ID
+from wger.utils.constants import CC_BY_SA_4_ID
class ExerciseBaseTestCase(WgerTestCase):
@@ -132,4 +132,4 @@ class ExerciseCustomApiTestCase(ExerciseCrudApiTestCase):
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
exercise = ExerciseBase.objects.get(pk=self.pk)
- self.assertEqual(exercise.license_id, DEFAULT_LICENSE_ID)
+ self.assertEqual(exercise.license_id, CC_BY_SA_4_ID)
diff --git a/wger/exercises/tests/test_exercise_translation.py b/wger/exercises/tests/test_exercise_translation.py
index 26f5e197c..a36edcc1f 100644
--- a/wger/exercises/tests/test_exercise_translation.py
+++ b/wger/exercises/tests/test_exercise_translation.py
@@ -38,7 +38,7 @@ from wger.exercises.models import (
Muscle,
)
from wger.utils.cache import cache_mapper
-from wger.utils.constants import DEFAULT_LICENSE_ID
+from wger.utils.constants import CC_BY_SA_4_ID
class ExerciseRepresentationTestCase(WgerTestCase):
@@ -388,7 +388,7 @@ class ExerciseCustomApiTestCase(ExerciseCrudApiTestCase):
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
exercise = Exercise.objects.get(pk=self.pk)
- self.assertEqual(exercise.license_id, DEFAULT_LICENSE_ID)
+ self.assertEqual(exercise.license_id, CC_BY_SA_4_ID)
def test_patch_clean_html(self):
"""
diff --git a/wger/utils/constants.py b/wger/utils/constants.py
index 637b7099e..2abab039f 100644
--- a/wger/utils/constants.py
+++ b/wger/utils/constants.py
@@ -53,8 +53,8 @@ PAGINATION_PAGES_AROUND_CURRENT = 5
# to be accepted
MIN_EDIT_DISTANCE_THRESHOLD = 2
-# CC-BY-SA-4
-DEFAULT_LICENSE_ID = 2
+# Important license IDs
+CC_BY_SA_4_ID = 2
CC_BY_SA_3_LICENSE_ID = 1
# Default language
diff --git a/wger/utils/models.py b/wger/utils/models.py
index 5f3dc67e3..536c1b2ea 100644
--- a/wger/utils/models.py
+++ b/wger/utils/models.py
@@ -20,8 +20,7 @@ from django.utils.translation import gettext_lazy as _
# wger
from wger.core.models import License
-from wger.utils.constants import DEFAULT_LICENSE_ID
-
+from wger.utils.constants import CC_BY_SA_4_ID
"""
Abstract model classes
@@ -39,7 +38,7 @@ class AbstractLicenseModel(models.Model):
license = models.ForeignKey(
License,
verbose_name=_('License'),
- default=DEFAULT_LICENSE_ID,
+ default=CC_BY_SA_4_ID,
on_delete=models.CASCADE,
)
"""The item's license"""