Self hosted FLOSS fitness/workout, nutrition and weight tracker
issue(2053): added the diemnsions and updated historical data
Shantanu20ed4c121957
diff --git a/wger/exercises/migrations/0033_rename_exercises_e_name_ac11f4_gin_exercises_t_name_6264c9_gin_and_more.py b/wger/exercises/migrations/0033_rename_exercises_e_name_ac11f4_gin_exercises_t_name_6264c9_gin_and_more.pynew file mode 100644index 000000000..3dba45b2c--- /dev/null+++ b/wger/exercises/migrations/0033_rename_exercises_e_name_ac11f4_gin_exercises_t_name_6264c9_gin_and_more.py@@ -0,0 +1,116 @@+# Generated by Django 5.2.6 on 2025-10-02 06:32++import django.db.models.deletion+import wger.exercises.models.image+import wger.utils.images+from django.db import migrations, models+++class Migration(migrations.Migration):++ dependencies = [+ ('exercises', '0032_rename_exercise'),+ ]++ operations = [+ migrations.RenameIndex(+ model_name='translation',+ new_name='exercises_t_name_6264c9_gin',+ old_name='exercises_e_name_ac11f4_gin',+ ),+ migrations.AddField(+ model_name='exerciseimage',+ name='height',+ field=models.PositiveIntegerField(blank=True, editable=False, null=True, verbose_name='Height'),+ ),+ migrations.AddField(+ model_name='exerciseimage',+ name='width',+ field=models.PositiveIntegerField(blank=True, editable=False, null=True, verbose_name='Width'),+ ),+ migrations.AddField(+ model_name='historicalexerciseimage',+ name='height',+ field=models.PositiveIntegerField(blank=True, editable=False, null=True, verbose_name='Height'),+ ),+ migrations.AddField(+ model_name='historicalexerciseimage',+ name='width',+ field=models.PositiveIntegerField(blank=True, editable=False, null=True, verbose_name='Width'),+ ),+ migrations.AlterField(+ model_name='deletionlog',+ name='replaced_by',+ field=models.UUIDField(default=None, editable=False, help_text='UUID of the object replaced by the deleted one. At the moment only available for exercises', null=True, verbose_name='Replaced by'),+ ),+ migrations.AlterField(+ model_name='exercise',+ name='license_author',+ field=models.TextField(blank=True, help_text='If you are not the author, enter the name or source here.', max_length=3500, null=True, verbose_name='Author(s)'),+ ),+ migrations.AlterField(+ model_name='exerciseimage',+ name='image',+ field=models.ImageField(height_field='height', help_text='Only PNG and JPEG formats are supported', upload_to=wger.exercises.models.image.exercise_image_upload_dir, validators=[wger.utils.images.validate_image_static_no_animation], verbose_name='Image', width_field='width'),+ ),+ migrations.AlterField(+ model_name='exerciseimage',+ name='is_main',+ field=models.BooleanField(default=False, verbose_name='Main picture'),+ ),+ migrations.AlterField(+ model_name='exerciseimage',+ name='license_author',+ field=models.TextField(blank=True, help_text='If you are not the author, enter the name or source here.', max_length=3500, null=True, verbose_name='Author(s)'),+ ),+ migrations.AlterField(+ model_name='exercisevideo',+ name='license_author',+ field=models.TextField(blank=True, help_text='If you are not the author, enter the name or source here.', max_length=3500, null=True, verbose_name='Author(s)'),+ ),+ migrations.AlterField(+ model_name='historicalexercise',+ name='license_author',+ field=models.TextField(blank=True, help_text='If you are not the author, enter the name or source here.', max_length=3500, null=True, verbose_name='Author(s)'),+ ),+ migrations.AlterField(+ model_name='historicalexerciseimage',+ name='image',+ field=models.TextField(help_text='Only PNG and JPEG formats are supported', max_length=100, validators=[wger.utils.images.validate_image_static_no_animation], verbose_name='Image'),+ ),+ migrations.AlterField(+ model_name='historicalexerciseimage',+ name='is_main',+ field=models.BooleanField(default=False, verbose_name='Main picture'),+ ),+ migrations.AlterField(+ model_name='historicalexerciseimage',+ name='license_author',+ field=models.TextField(blank=True, help_text='If you are not the author, enter the name or source here.', max_length=3500, null=True, verbose_name='Author(s)'),+ ),+ migrations.AlterField(+ model_name='historicalexercisevideo',+ name='license_author',+ field=models.TextField(blank=True, help_text='If you are not the author, enter the name or source here.', max_length=3500, null=True, verbose_name='Author(s)'),+ ),+ migrations.AlterField(+ model_name='historicaltranslation',+ name='exercise',+ field=models.ForeignKey(blank=True, db_constraint=False, default=None, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='exercises.exercise'),+ ),+ migrations.AlterField(+ model_name='historicaltranslation',+ name='license_author',+ field=models.TextField(blank=True, help_text='If you are not the author, enter the name or source here.', max_length=3500, null=True, verbose_name='Author(s)'),+ ),+ migrations.AlterField(+ model_name='translation',+ name='exercise',+ field=models.ForeignKey(default=None, on_delete=django.db.models.deletion.CASCADE, related_name='translations', to='exercises.exercise'),+ ),+ migrations.AlterField(+ model_name='translation',+ name='license_author',+ field=models.TextField(blank=True, help_text='If you are not the author, enter the name or source here.', max_length=3500, null=True, verbose_name='Author(s)'),+ ),+ ]diff --git a/wger/exercises/migrations/0034_populate_image_dimensions.py b/wger/exercises/migrations/0034_populate_image_dimensions.pynew file mode 100644index 000000000..4e6c46f21--- /dev/null+++ b/wger/exercises/migrations/0034_populate_image_dimensions.py@@ -0,0 +1,27 @@+# Generated by Django 5.2.6 on 2025-10-02 06:20++from django.db import migrations+++def update_image_dimensions(apps, schema_editor):+ ExerciseImage = apps.get_model('exercises', 'ExerciseImage')+ for image in ExerciseImage.objects.all():+ if image.image:+ try:+ image.width = image.image.width+ image.height = image.image.height+ image.save(update_fields=['width', 'height'])+ except FileNotFoundError:+ # Handle missing image files gracefully+ pass+++class Migration(migrations.Migration):++ dependencies = [+ ('exercises', '0033_rename_exercises_e_name_ac11f4_gin_exercises_t_name_6264c9_gin_and_more'),+ ]++ operations = [+ migrations.RunPython(update_image_dimensions, migrations.RunPython.noop),+ ]\ No newline at end of filediff --git a/wger/exercises/models/image.py b/wger/exercises/models/image.pyindex 740cdc0e2..5dd7a2f10 100644--- a/wger/exercises/models/image.py+++ b/wger/exercises/models/image.py@@ -82,9 +82,27 @@ class ExerciseImage(AbstractLicenseModel, AbstractHistoryMixin, models.Model, Bahelp_text='Only PNG and JPEG formats are supported',upload_to=exercise_image_upload_dir,validators=[validate_image_static_no_animation],+ height_field='height',+ width_field='width',)"""Uploaded image"""+ height = models.PositiveIntegerField(+ verbose_name=_('Height'),+ null=True,+ blank=True,+ editable=False,+ )+ """Image height"""++ width = models.PositiveIntegerField(+ verbose_name=_('Width'),+ null=True,+ blank=True,+ editable=False,+ )+ """Image width"""+is_main = models.BooleanField(verbose_name=_('Main picture'),default=False,