Self hosted FLOSS fitness/workout, nutrition and weight tracker
Some config values are always positive integers
Roland Geider17c21ff32deb
diff --git a/wger/manager/dataclasses.py b/wger/manager/dataclasses.pyindex a5079b71a..1ebca665a 100644--- a/wger/manager/dataclasses.py+++ b/wger/manager/dataclasses.py@@ -45,13 +45,13 @@ class SetConfigData:weight: Decimal | int | Nonereps: Decimal | int | Nonerir: Decimal | int | None- rest: Decimal | int | None+ rest: int | Nonemax_weight: Decimal | int | None = Nonemax_reps: Decimal | int | None = None- max_rest: Decimal | int | None = None+ max_rest: int | None = None- sets: Decimal | int = 1+ sets: int = 1weight_unit: int | None = 1reps_unit: int | None = 1weight_rounding: Decimal | int | None = 1.25diff --git a/wger/manager/migrations/0018_flexible_routines.py b/wger/manager/migrations/0018_flexible_routines.pyindex 185f7b81d..130a695ae 100644--- a/wger/manager/migrations/0018_flexible_routines.py+++ b/wger/manager/migrations/0018_flexible_routines.py@@ -505,7 +505,7 @@ class Migration(migrations.Migration):),),('iteration', models.PositiveIntegerField()),- ('value', models.DecimalField(decimal_places=2, max_digits=6)),+ ('value', models.PositiveIntegerField()),('operation',models.CharField(@@ -551,7 +551,7 @@ class Migration(migrations.Migration):),),('iteration', models.PositiveIntegerField()),- ('value', models.DecimalField(decimal_places=2, max_digits=6)),+ ('value', models.PositiveIntegerField()),('operation',models.CharField(@@ -689,7 +689,7 @@ class Migration(migrations.Migration):),),('iteration', models.PositiveIntegerField()),- ('value', models.DecimalField(decimal_places=2, max_digits=6)),+ ('value', models.PositiveIntegerField()),('operation',models.CharField(diff --git a/wger/manager/migrations/0019_flexible_routines_migration.py b/wger/manager/migrations/0019_flexible_routines_migration.pyindex 19b79bc60..8598ca1eb 100644--- a/wger/manager/migrations/0019_flexible_routines_migration.py+++ b/wger/manager/migrations/0019_flexible_routines_migration.py@@ -78,12 +78,14 @@ def migrate_routines(apps) -> dict[int, Any]:slot_entry = SlotEntry(slot=slot,exercise=setting.exercise_base,-# default "reps"- repetition_unit_id=setting.repetition_unit_id if setting.repetition_unit_id is not None else 1,-+ repetition_unit_id=setting.repetition_unit_id+ if setting.repetition_unit_id is not None+ else 1,# default "kg"- weight_unit_id=setting.weight_unit_id if setting.weight_unit_id is not None else 1,+ weight_unit_id=setting.weight_unit_id+ if setting.weight_unit_id is not None+ else 1,order=setting.order,comment=setting.comment,)diff --git a/wger/manager/models/rest_config.py b/wger/manager/models/rest_config.pyindex c2952d55d..9b8789439 100644--- a/wger/manager/models/rest_config.py+++ b/wger/manager/models/rest_config.py@@ -14,6 +14,9 @@# You should have received a copy of the GNU Affero General Public License# along with this program. If not, see <http://www.gnu.org/licenses/>.+# Django+from django.db import models+# wgerfrom wger.manager.models import AbstractChangeConfig@@ -23,7 +26,8 @@ class RestConfig(AbstractChangeConfig):Configuration model for the rest time for a workout set"""- pass+ value = models.PositiveIntegerField()+ """Rest times are always in seconds, so always positive integers"""class MaxRestConfig(AbstractChangeConfig):@@ -31,4 +35,5 @@ class MaxRestConfig(AbstractChangeConfig):Configuration model for the upper limit of the rest time for a workout set"""- pass+ value = models.PositiveIntegerField()+ """Rest times are always in seconds, so always positive integers"""diff --git a/wger/manager/models/sets_config.py b/wger/manager/models/sets_config.pyindex 13a3978ca..9585a5670 100644--- a/wger/manager/models/sets_config.py+++ b/wger/manager/models/sets_config.py@@ -14,6 +14,9 @@# You should have received a copy of the GNU Affero General Public License# along with this program. If not, see <http://www.gnu.org/licenses/>.+# Django+from django.db import models+# wgerfrom wger.manager.models import AbstractChangeConfig@@ -23,4 +26,5 @@ class SetsConfig(AbstractChangeConfig):Configuration model for the number of sets for a workout set"""- pass+ value = models.PositiveIntegerField()+ """Sets are always positive integers"""diff --git a/wger/manager/tests/test_slot_entry.py b/wger/manager/tests/test_slot_entry.pyindex 185769563..5a4633adc 100644--- a/wger/manager/tests/test_slot_entry.py+++ b/wger/manager/tests/test_slot_entry.py@@ -58,13 +58,28 @@ class SlotEntryTestCase(WgerTestCase):"""# Initial value- WeightConfig(slot_entry=self.slot_entry, iteration=1, value=80).save()+ WeightConfig(+ slot_entry=self.slot_entry,+ iteration=1,+ value=80,+ operation=OperationChoices.REPLACE,+ ).save()# Increase by 2.5- WeightConfig(slot_entry=self.slot_entry, iteration=3, value=2.5).save()+ WeightConfig(+ slot_entry=self.slot_entry,+ iteration=3,+ value=2.5,+ operation=OperationChoices.PLUS,+ ).save()# Replace with 42- WeightConfig(slot_entry=self.slot_entry, iteration=6, value=42, replace=True).save()+ WeightConfig(+ slot_entry=self.slot_entry,+ iteration=6,+ value=42,+ operation=OperationChoices.REPLACE,+ ).save()# Reduce by 2WeightConfig(@@ -128,9 +143,8 @@ class SlotEntryTestCase(WgerTestCase):slot_entry=self.slot_entry,iteration=5,value=42,- replace=True,need_log_to_apply=False,- operation=OperationChoices.PLUS,+ operation=OperationChoices.REPLACE,step=StepChoices.ABSOLUTE,).save()@@ -337,7 +351,12 @@ class SlotEntryTestCase(WgerTestCase):self.slot_entry.class_name = 'dummy'self.slot_entry.save()SetsConfig(slot_entry=self.slot_entry, iteration=1, value=5).save()- WeightConfig(slot_entry=self.slot_entry, iteration=1, value=100, replace=True).save()+ WeightConfig(+ slot_entry=self.slot_entry,+ iteration=1,+ value=100,+ operation=OperationChoices.REPLACE,+ ).save()RepsConfig(slot_entry=self.slot_entry, iteration=1, value=5).save()RestConfig(slot_entry=self.slot_entry, iteration=1, value=120).save()RiRConfig(slot_entry=self.slot_entry, iteration=1, value=2).save()