Skip to content

Commit

Permalink
Automatic linting
Browse files Browse the repository at this point in the history
  • Loading branch information
Github-actions committed Jan 17, 2025
1 parent 2e79f27 commit 3c00a32
Show file tree
Hide file tree
Showing 28 changed files with 56 additions and 55 deletions.
4 changes: 2 additions & 2 deletions wger/core/management/commands/add-user-rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ def handle(self, *args, **options):
user.userprofile.can_add_user = False
self.stdout.write(
self.style.SUCCESS(
f"{options['name']} is now DISABLED from adding users via the API"
f'{options["name"]} is now DISABLED from adding users via the API'
)
)

else:
user.userprofile.can_add_user = True
self.stdout.write(
self.style.SUCCESS(f"{options['name']} is now ALLOWED to add users via the API")
self.style.SUCCESS(f'{options["name"]} is now ALLOWED to add users via the API')
)
user.userprofile.save()

Expand Down
4 changes: 2 additions & 2 deletions wger/core/management/commands/dummy-generator-users.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def add_arguments(self, parser):
def handle(self, **options):
faker = Faker()

self.stdout.write(f"** Generating {options['number_users']} users")
self.stdout.write(f'** Generating {options["number_users"]} users')

match options['add_to_gym']:
case 'auto':
Expand All @@ -80,7 +80,7 @@ def handle(self, **options):
first_name = faker.first_name()
last_name = faker.last_name()

username = slugify(f"{first_name}, {last_name} - {str(uid).split('-')[1]}")
username = slugify(f'{first_name}, {last_name} - {str(uid).split("-")[1]}')
email = f'{username}@example.com'
password = username

Expand Down
8 changes: 4 additions & 4 deletions wger/core/models/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class UserProfile(models.Model):

show_comments = models.BooleanField(
verbose_name=_('Show exercise comments'),
help_text=_('Check to show exercise comments on the ' 'workout view'),
help_text=_('Check to show exercise comments on the workout view'),
default=True,
)
"""
Expand Down Expand Up @@ -149,7 +149,7 @@ class UserProfile(models.Model):

workout_reminder = IntegerField(
verbose_name=_('Remind before expiration'),
help_text=_('The number of days you want to be reminded ' 'before a workout expires.'),
help_text=_('The number of days you want to be reminded before a workout expires.'),
default=14,
validators=[MinValueValidator(1), MaxValueValidator(30)],
)
Expand Down Expand Up @@ -349,8 +349,8 @@ def is_trustworthy(self) -> bool:
"""Allow anonymous read-only access"""

num_days_weight_reminder = models.IntegerField(
verbose_name=_('Automatic reminders for weight ' 'entries'),
help_text=_('Number of days after the last ' 'weight entry (enter 0 to ' 'deactivate)'),
verbose_name=_('Automatic reminders for weight entries'),
help_text=_('Number of days after the last weight entry (enter 0 to deactivate)'),
validators=[MinValueValidator(0), MaxValueValidator(30)],
default=0,
)
Expand Down
4 changes: 2 additions & 2 deletions wger/exercises/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ def validate(self, value):
~Q(id=self.instance.pk), language=value['language']
).exists():
raise serializers.ValidationError(
f"There is already a translation for this exercise in {value['language']}"
f'There is already a translation for this exercise in {value["language"]}'
)
# Creating a new object
# -> Check if the language already exists
Expand All @@ -383,7 +383,7 @@ def validate(self, value):
exercise_base=value['exercise_base'], language=value['language']
).exists():
raise serializers.ValidationError(
f"There is already a translation for this exercise in {value['language']}"
f'There is already a translation for this exercise in {value["language"]}'
)

return super().validate(value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def add_arguments(self, parser):
action='store',
dest='remote_url',
default='https://wger.de',
help='Remote URL to fetch the exercises from (default: ' 'https://wger.de)',
help='Remote URL to fetch the exercises from (default: https://wger.de)',
)

def handle(self, **options):
Expand Down
8 changes: 4 additions & 4 deletions wger/exercises/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def sync_exercises(
uuid=uuid,
defaults={'category_id': category_id, 'created': created},
)
print_fn(f"{'created' if base_created else 'updated'} exercise {uuid}")
print_fn(f'{"created" if base_created else "updated"} exercise {uuid}')

base.muscles.set(muscles)
base.muscles_secondary.set(muscles_sec)
Expand All @@ -113,8 +113,8 @@ def sync_exercises(
},
)
out = (
f"- {'created' if translation_created else 'updated'} translation "
f"{translation.language.short_name} {trans_uuid} - {name}"
f'- {"created" if translation_created else "updated"} translation '
f'{translation.language.short_name} {trans_uuid} - {name}'
)
print_fn(out)

Expand Down Expand Up @@ -344,7 +344,7 @@ def print_fn(_):
try:
obj = Exercise.objects.get(uuid=uuid)
obj.delete()
print_fn(f"Deleted translation {uuid} ({data['comment']})")
print_fn(f'Deleted translation {uuid} ({data["comment"]})')
except Exercise.DoesNotExist:
pass

Expand Down
2 changes: 1 addition & 1 deletion wger/exercises/tests/test_categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class CategoryOverviewTestCase(WgerAccessTestCase):
user_success = 'admin'
user_fail = (
'manager1',
'manager2' 'general_manager1',
'manager2general_manager1',
'manager3',
'manager4',
'test',
Expand Down
16 changes: 8 additions & 8 deletions wger/exercises/tests/test_exercise_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def test_render_main_muscles(self):
"""

context = Context({'muscles': Muscle.objects.get(pk=2)})
template = Template('{% load wger_extras %}' '{% render_muscles muscles %}')
template = Template('{% load wger_extras %}{% render_muscles muscles %}')
rendered_template = template.render(context)
self.assertIn('images/muscles/main/muscle-2.svg', rendered_template)
self.assertNotIn('images/muscles/secondary/', rendered_template)
Expand All @@ -130,7 +130,7 @@ def test_render_main_muscles_empty_secondary(self):
"""

context = Context({'muscles': Muscle.objects.get(pk=2), 'muscles_sec': []})
template = Template('{% load wger_extras %}' '{% render_muscles muscles muscles_sec %}')
template = Template('{% load wger_extras %}{% render_muscles muscles muscles_sec %}')
rendered_template = template.render(context)
self.assertIn('images/muscles/main/muscle-2.svg', rendered_template)
self.assertNotIn('images/muscles/secondary/', rendered_template)
Expand All @@ -142,7 +142,7 @@ def test_render_secondary_muscles(self):
"""

context = Context({'muscles': Muscle.objects.get(pk=1)})
template = Template('{% load wger_extras %}' '{% render_muscles muscles_sec=muscles %}')
template = Template('{% load wger_extras %}{% render_muscles muscles_sec=muscles %}')
rendered_template = template.render(context)
self.assertIn('images/muscles/secondary/muscle-1.svg', rendered_template)
self.assertNotIn('images/muscles/main/', rendered_template)
Expand All @@ -154,7 +154,7 @@ def test_render_secondary_muscles_empty_primary(self):
"""

context = Context({'muscles_sec': Muscle.objects.get(pk=1), 'muscles': []})
template = Template('{% load wger_extras %}' '{% render_muscles muscles muscles_sec %}')
template = Template('{% load wger_extras %}{% render_muscles muscles muscles_sec %}')
rendered_template = template.render(context)
self.assertIn('images/muscles/secondary/muscle-1.svg', rendered_template)
self.assertNotIn('images/muscles/main/', rendered_template)
Expand All @@ -166,7 +166,7 @@ def test_render_secondary_muscles_list(self):
"""

context = Context({'muscles_sec': Muscle.objects.filter(is_front=True), 'muscles': []})
template = Template('{% load wger_extras %}' '{% render_muscles muscles muscles_sec %}')
template = Template('{% load wger_extras %}{% render_muscles muscles muscles_sec %}')
rendered_template = template.render(context)
self.assertIn('images/muscles/secondary/muscle-1.svg', rendered_template)
self.assertNotIn('images/muscles/secondary/muscle-2.svg', rendered_template)
Expand All @@ -185,7 +185,7 @@ def test_render_muscle_list(self):
'muscles': Muscle.objects.filter(id__in=[1, 4]),
}
)
template = Template('{% load wger_extras %}' '{% render_muscles muscles muscles_sec %}')
template = Template('{% load wger_extras %}{% render_muscles muscles muscles_sec %}')
rendered_template = template.render(context)
self.assertIn('images/muscles/main/muscle-1.svg', rendered_template)
self.assertNotIn('images/muscles/main/muscle-2.svg', rendered_template)
Expand All @@ -202,7 +202,7 @@ def test_render_empty(self):
"""

context = Context({'muscles': [], 'muscles_sec': []})
template = Template('{% load wger_extras %}' '{% render_muscles muscles muscles_sec %}')
template = Template('{% load wger_extras %}{% render_muscles muscles muscles_sec %}')
rendered_template = template.render(context)
self.assertEqual(rendered_template, '\n\n')

Expand All @@ -211,7 +211,7 @@ def test_render_no_parameters(self):
Test that the tag works when given no parameters
"""

template = Template('{% load wger_extras %}' '{% render_muscles %}')
template = Template('{% load wger_extras %}{% render_muscles %}')
rendered_template = template.render(Context({}))
self.assertEqual(rendered_template, '\n\n')

Expand Down
2 changes: 1 addition & 1 deletion wger/exercises/tests/test_muscles.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class MuscleAdminOverviewTest(WgerAccessTestCase):
user_success = 'admin'
user_fail = (
'manager1',
'manager2' 'general_manager1',
'manager2general_manager1',
'manager3',
'manager4',
'test',
Expand Down
4 changes: 2 additions & 2 deletions wger/gym/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ class Meta:
label=_('Username'),
max_length=30,
regex=r'^[\w.@+-]+$',
help_text=_('Required. 30 characters or fewer. Letters, digits and ' '@/./+/-/_ only.'),
help_text=_('Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only.'),
error_messages={
'invalid': _('This value may contain only letters, numbers and ' '@/.//-/_ characters.')
'invalid': _('This value may contain only letters, numbers and @/.//-/_ characters.')
},
)

Expand Down
2 changes: 1 addition & 1 deletion wger/gym/management/commands/dummy-generator-gyms.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def handle(self, **options):
faker.add_provider(gym_names_1)
faker.add_provider(gym_names_2)

self.stdout.write(f"** Generating {options['number_gyms']} gyms")
self.stdout.write(f'** Generating {options["number_gyms"]} gyms')

gym_list = []
for i in range(options['number_gyms']):
Expand Down
2 changes: 1 addition & 1 deletion wger/gym/models/user_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class Meta:

include_inactive = m.BooleanField(
verbose_name=_('Include in inactive overview'),
help_text=_('Include this user in the email list with ' 'inactive members'),
help_text=_('Include this user in the email list with inactive members'),
default=True,
)
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def add_arguments(self, parser):
)

def handle(self, **options):
self.stdout.write(f"** Generating {options['nr_diary_entries']} dummy diary entries")
self.stdout.write(f'** Generating {options["nr_diary_entries"]} dummy diary entries')

users = (
[User.objects.get(pk=options['user_id'])] if options['user_id'] else User.objects.all()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def add_arguments(self, parser):
)

def handle(self, **options):
self.stdout.write(f"** Generating {options['nr_plans']} dummy workout plan(s) per user")
self.stdout.write(f'** Generating {options["nr_plans"]} dummy workout plan(s) per user')

users = (
[User.objects.get(pk=options['user_id'])] if options['user_id'] else User.objects.all()
Expand Down
2 changes: 1 addition & 1 deletion wger/manager/models/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Schedule(models.Model):
name = models.CharField(
verbose_name=_('Name'),
max_length=100,
help_text=_('Name or short description of the schedule. ' "For example 'Program XYZ'."),
help_text=_("Name or short description of the schedule. For example 'Program XYZ'."),
)
"""Name or short description of the schedule."""

Expand Down
4 changes: 2 additions & 2 deletions wger/manager/models/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class WorkoutSession(models.Model):
verbose_name=_('Notes'),
null=True,
blank=True,
help_text=_('Any notes you might want to save about this workout ' 'session.'),
help_text=_('Any notes you might want to save about this workout session.'),
)
"""
User notes about the workout
Expand All @@ -85,7 +85,7 @@ class WorkoutSession(models.Model):
choices=IMPRESSION,
default=IMPRESSION_NEUTRAL,
help_text=_(
'Your impression about this workout session. ' 'Did you exercise as well as you could?'
'Your impression about this workout session. Did you exercise as well as you could?'
),
)
"""
Expand Down
2 changes: 1 addition & 1 deletion wger/manager/models/workout.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Meta:
is_template = models.BooleanField(
verbose_name=_('Workout template'),
help_text=_(
'Marking a workout as a template will freeze it and allow you to ' 'make copies of it'
'Marking a workout as a template will freeze it and allow you to make copies of it'
),
default=False,
null=False,
Expand Down
2 changes: 1 addition & 1 deletion wger/manager/tests/test_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ def test_smart_repr_custom_setting(self):
setting_text = set_obj.reps_smart_text(ExerciseBase.objects.get(pk=1))
self.assertEqual(
setting_text,
'8 (90 kg, 3 RiR) – 10 (80 kg, 2.5 RiR) – ' '10 (80 kg, 2 RiR) – 12 (80 kg, 1 RiR)',
'8 (90 kg, 3 RiR) – 10 (80 kg, 2.5 RiR) – 10 (80 kg, 2 RiR) – 12 (80 kg, 1 RiR)',
)

def test_synthetic_settings(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def add_arguments(self, parser):

def handle(self, **options):
self.stdout.write(
f"** Generating {options['nr_categories']} dummy measurement categories per user"
f'** Generating {options["nr_categories"]} dummy measurement categories per user'
)

users = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def add_arguments(self, parser):
)

def handle(self, **options):
self.stdout.write(f"** Generating {options['nr_measurements']} dummy measurements per user")
self.stdout.write(f'** Generating {options["nr_measurements"]} dummy measurements per user')

users = (
[User.objects.get(pk=options['user_id'])] if options['user_id'] else User.objects.all()
Expand Down
6 changes: 2 additions & 4 deletions wger/nutrition/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,16 +206,14 @@ class DailyCaloriesForm(forms.ModelForm):

base_calories = forms.IntegerField(
label=_('Basic caloric intake'),
help_text=_('Your basic caloric intake as calculated for ' 'your data'),
help_text=_('Your basic caloric intake as calculated for your data'),
required=False,
widget=Html5NumberInput(),
)
additional_calories = forms.IntegerField(
label=_('Additional calories'),
help_text=_(
'Additional calories to add to the base '
'rate (to substract, enter a negative '
'number)'
'Additional calories to add to the base rate (to substract, enter a negative number)'
),
initial=0,
required=False,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def add_arguments(self, parser):
)

def handle(self, **options):
self.stdout.write(f"** Generating {options['nr_plans']} dummy nutritional plan(s) per user")
self.stdout.write(f'** Generating {options["nr_plans"]} dummy nutritional plan(s) per user')

users = (
[User.objects.get(pk=options['user_id'])] if options['user_id'] else User.objects.all()
Expand Down Expand Up @@ -147,6 +147,6 @@ def handle(self, **options):
diary_entries.append(log)

if int(options['verbosity']) >= 2:
self.stdout.write(f" created {options['nr_diary_dates']} diary entries")
self.stdout.write(f' created {options["nr_diary_dates"]} diary entries')

LogItem.objects.bulk_create(diary_entries)
13 changes: 8 additions & 5 deletions wger/nutrition/management/commands/sync-ingredients-async.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,22 @@
#
# You should have received a copy of the GNU Affero General Public License

# Django
from django.core.management.base import BaseCommand

# wger
from wger.nutrition.tasks import sync_all_ingredients_task


class Command(BaseCommand):

help = "Asynchronously synchronize all ingredients from another wger instance."
help = 'Asynchronously synchronize all ingredients from another wger instance.'

def handle(self, *args, **options):

self.stdout.write("Triggering the Celery task to synchronize all ingredients...")
self.stdout.write('Triggering the Celery task to synchronize all ingredients...')

# Trigger the task asynchronously
sync_all_ingredients_task.delay()

self.stdout.write("Synchronization task has been triggered. Check the Celery worker logs for progress.")
self.stdout.write(
'Synchronization task has been triggered. Check the Celery worker logs for progress.'
)
2 changes: 1 addition & 1 deletion wger/nutrition/models/plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Meta:
blank=True,
verbose_name=_('Description'),
help_text=_(
'A description of the goal of the plan, e.g. ' '"Gain mass" or "Prepare for summer"'
'A description of the goal of the plan, e.g. "Gain mass" or "Prepare for summer"'
),
)

Expand Down
Loading

0 comments on commit 3c00a32

Please sign in to comment.