Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Reformat code

Roland Geider335bc2d7abbc
diff --git a/wger/core/tests/api_base_test.py b/wger/core/tests/api_base_test.py
index 29fc2a195..62235483d 100644
--- a/wger/core/tests/api_base_test.py
+++ b/wger/core/tests/api_base_test.py
@@ -295,8 +295,7 @@ class ApiPostTestCase(object):
self.get_credentials(self.user_fail)
response = self.client.post(self.url, data=self.data)
if self.protected_resource:
- self.assertIn(response.status_code,
- (status.HTTP_200_OK, status.HTTP_201_CREATED))
+ self.assertIn(response.status_code, (status.HTTP_200_OK, status.HTTP_201_CREATED))
else:
self.assertIn(
response.status_code,
@@ -379,8 +378,7 @@ class ApiPatchTestCase(object):
self.get_credentials(self.user_fail)
response = self.client.patch(self.url_detail, data=self.data)
if self.protected_resource:
- self.assertIn(response.status_code,
- (status.HTTP_200_OK, status.HTTP_201_CREATED))
+ self.assertIn(response.status_code, (status.HTTP_200_OK, status.HTTP_201_CREATED))
else:
self.assertIn(
response.status_code,
@@ -506,15 +504,13 @@ class ApiPutTestCase(object):
self.get_credentials(self.user_fail)
response = self.client.put(self.url_detail, data=self.data)
if self.protected_resource:
- self.assertIn(response.status_code,
- (status.HTTP_200_OK, status.HTTP_201_CREATED))
+ self.assertIn(response.status_code, (status.HTTP_200_OK, status.HTTP_201_CREATED))
else:
self.assertIn(
response.status_code,
(status.HTTP_405_METHOD_NOT_ALLOWED, status.HTTP_403_FORBIDDEN)
)
-
def test_put(self):
"""
Tests PUTTING (adding) a new object
diff --git a/wger/exercises/management/commands/change-exercise-author.py b/wger/exercises/management/commands/change-exercise-author.py
index e0819e31e..79559c398 100644
--- a/wger/exercises/management/commands/change-exercise-author.py
+++ b/wger/exercises/management/commands/change-exercise-author.py
@@ -36,10 +36,7 @@ class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument(
- '--author-name',
- action='store',
- dest='author_name',
- help='The name of the new author'
+ '--author-name', action='store', dest='author_name', help='The name of the new author'
)
parser.add_argument(
'--exercise-base-id',
@@ -48,10 +45,7 @@ class Command(BaseCommand):
help='The ID of the exercise base'
)
parser.add_argument(
- '--exercise-id',
- action='store',
- dest='exercise_id',
- help='The ID of the exercise'
+ '--exercise-id', action='store', dest='exercise_id', help='The ID of the exercise'
)
def handle(self, **options):
@@ -85,13 +79,7 @@ class Command(BaseCommand):
exercise.license_author = author_name
exercise.save()
- self.stdout.write(
- self.style.SUCCESS(f"Exercise and/or exercise base has been updated")
- )
+ self.stdout.write(self.style.SUCCESS(f"Exercise and/or exercise base has been updated"))
def print_error(self, error_message):
- self.stdout.write(
- self.style.WARNING(
- f"{error_message}"
- )
- )
+ self.stdout.write(self.style.WARNING(f"{error_message}"))
diff --git a/wger/exercises/migrations/0022_auto_20220529_0029.py b/wger/exercises/migrations/0022_auto_20220529_0029.py
index 7d24cc09f..0faedde2e 100644
--- a/wger/exercises/migrations/0022_auto_20220529_0029.py
+++ b/wger/exercises/migrations/0022_auto_20220529_0029.py
@@ -12,19 +12,39 @@ class Migration(migrations.Migration):
operations = [
migrations.AlterModelOptions(
name='historicalalias',
- options={'get_latest_by': ('history_date', 'history_id'), 'ordering': ('-history_date', '-history_id'), 'verbose_name': 'historical alias', 'verbose_name_plural': 'historical aliass'},
+ options={
+ 'get_latest_by': ('history_date', 'history_id'),
+ 'ordering': ('-history_date', '-history_id'),
+ 'verbose_name': 'historical alias',
+ 'verbose_name_plural': 'historical aliass'
+ },
),
migrations.AlterModelOptions(
name='historicalexercise',
- options={'get_latest_by': ('history_date', 'history_id'), 'ordering': ('-history_date', '-history_id'), 'verbose_name': 'historical exercise', 'verbose_name_plural': 'historical exercises'},
+ options={
+ 'get_latest_by': ('history_date', 'history_id'),
+ 'ordering': ('-history_date', '-history_id'),
+ 'verbose_name': 'historical exercise',
+ 'verbose_name_plural': 'historical exercises'
+ },
),
migrations.AlterModelOptions(
name='historicalexercisebase',
- options={'get_latest_by': ('history_date', 'history_id'), 'ordering': ('-history_date', '-history_id'), 'verbose_name': 'historical exercise base', 'verbose_name_plural': 'historical exercise bases'},
+ options={
+ 'get_latest_by': ('history_date', 'history_id'),
+ 'ordering': ('-history_date', '-history_id'),
+ 'verbose_name': 'historical exercise base',
+ 'verbose_name_plural': 'historical exercise bases'
+ },
),
migrations.AlterModelOptions(
name='historicalexercisecomment',
- options={'get_latest_by': ('history_date', 'history_id'), 'ordering': ('-history_date', '-history_id'), 'verbose_name': 'historical exercise comment', 'verbose_name_plural': 'historical exercise comments'},
+ options={
+ 'get_latest_by': ('history_date', 'history_id'),
+ 'ordering': ('-history_date', '-history_id'),
+ 'verbose_name': 'historical exercise comment',
+ 'verbose_name_plural': 'historical exercise comments'
+ },
),
migrations.AlterField(
model_name='historicalalias',
diff --git a/wger/exercises/models/base.py b/wger/exercises/models/base.py
index ada9ed3a2..aaa9cd570 100644
--- a/wger/exercises/models/base.py
+++ b/wger/exercises/models/base.py
@@ -36,7 +36,10 @@ from simple_history.models import HistoricalRecords
# wger
from wger.core.models import Language
from wger.utils.constants import DEFAULT_LANGUAGE
-from wger.utils.models import AbstractHistoryMixin, AbstractLicenseModel
+from wger.utils.models import (
+ AbstractHistoryMixin,
+ AbstractLicenseModel,
+)
# Local
from .category import ExerciseCategory
diff --git a/wger/exercises/models/exercise.py b/wger/exercises/models/exercise.py
index 85cc35660..2fd389c06 100644
--- a/wger/exercises/models/exercise.py
+++ b/wger/exercises/models/exercise.py
@@ -43,8 +43,8 @@ from wger.utils.cache import (
reset_workout_canonical_form,
)
from wger.utils.models import (
- AbstractLicenseModel,
AbstractHistoryMixin,
+ AbstractLicenseModel,
)
diff --git a/wger/exercises/tests/test_change_exercise_author.py b/wger/exercises/tests/test_change_exercise_author.py
index 8fafc5a5f..62c66cb39 100644
--- a/wger/exercises/tests/test_change_exercise_author.py
+++ b/wger/exercises/tests/test_change_exercise_author.py
@@ -12,8 +12,10 @@
#
# You should have received a copy of the GNU Affero General Public License
+# Standard Library
from io import StringIO
+# Django
from django.core.management import call_command
# wger
@@ -42,13 +44,9 @@ class ChangeExerciseAuthorTestCase(WgerTestCase):
"""
Test to ensure command handles a missing exercise parameters
"""
- args = [
- "--author-name",
- "tom"
- ]
+ args = ["--author-name", "tom"]
call_command('change-exercise-author', *args, stdout=self.out, no_color=True)
- self.assertIn(
- 'Please enter an exercise base or exercise ID', self.out.getvalue())
+ self.assertIn('Please enter an exercise base or exercise ID', self.out.getvalue())
def test_can_update_exercise_base(self):
"""
@@ -57,15 +55,9 @@ class ChangeExerciseAuthorTestCase(WgerTestCase):
exercise_base = ExerciseBase.objects.get(id=2)
self.assertNotEquals(exercise_base.license_author, "tom")
- args = [
- "--author-name",
- "tom",
- "--exercise-base-id",
- "2"
- ]
+ args = ["--author-name", "tom", "--exercise-base-id", "2"]
call_command('change-exercise-author', *args, stdout=self.out, no_color=True)
- self.assertIn(
- 'Exercise and/or exercise base has been updated', self.out.getvalue())
+ self.assertIn('Exercise and/or exercise base has been updated', self.out.getvalue())
exercise_base = ExerciseBase.objects.get(id=2)
self.assertEquals(exercise_base.license_author, "tom")
@@ -77,15 +69,9 @@ class ChangeExerciseAuthorTestCase(WgerTestCase):
exercise = Exercise.objects.get(id=1)
self.assertNotEquals(exercise.license_author, "tom")
- args = [
- "--author-name",
- "tom",
- "--exercise-id",
- "1"
- ]
+ args = ["--author-name", "tom", "--exercise-id", "1"]
call_command('change-exercise-author', *args, stdout=self.out, no_color=True)
- self.assertIn(
- 'Exercise and/or exercise base has been updated', self.out.getvalue())
+ self.assertIn('Exercise and/or exercise base has been updated', self.out.getvalue())
exercise = Exercise.objects.get(id=1)
self.assertEquals(exercise.license_author, "tom")
diff --git a/wger/manager/migrations/0017_alter_workoutlog_exercise_base.py b/wger/manager/migrations/0017_alter_workoutlog_exercise_base.py
index f61e5cb55..6ff978be0 100644
--- a/wger/manager/migrations/0017_alter_workoutlog_exercise_base.py
+++ b/wger/manager/migrations/0017_alter_workoutlog_exercise_base.py
@@ -15,6 +15,10 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='workoutlog',
name='exercise_base',
- field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='exercises.exercisebase', verbose_name='Exercise'),
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ to='exercises.exercisebase',
+ verbose_name='Exercise'
+ ),
),
]
diff --git a/wger/urls.py b/wger/urls.py
index 50bef1e5a..b7e9fcd24 100644
--- a/wger/urls.py
+++ b/wger/urls.py
@@ -237,9 +237,7 @@ urlpatterns += [
# The api user login
path(
- 'api/v2/login/',
- core_api_views.UserAPILoginView.as_view({'post': 'post'}),
- name='api_user'
+ 'api/v2/login/', core_api_views.UserAPILoginView.as_view({'post': 'post'}), name='api_user'
),
path(
'api/v2/register/',
diff --git a/wger/utils/models.py b/wger/utils/models.py
index d6a70dafa..2e7492092 100644
--- a/wger/utils/models.py
+++ b/wger/utils/models.py
@@ -104,4 +104,5 @@ class AbstractHistoryMixin(models.Model):
for history in set(self.history.all()):
out.append(history.license_author)
return set(out)
+
"""Author history is the unique set of license authors from historical records"""