Self hosted FLOSS fitness/workout, nutrition and weight tracker
Move rounding to SlotConfig, as it makes more sense here
Roland Geider6b078f20f346
diff --git a/wger/manager/dataclasses.py b/wger/manager/dataclasses.pyindex f1f8090e1..63ee0d564 100644--- a/wger/manager/dataclasses.py+++ b/wger/manager/dataclasses.py@@ -63,4 +63,4 @@ class WorkoutDayData:@propertydef slots(self) -> List[SlotData]:- return self.day.get_sets(self.iteration)+ return self.day.get_slots(self.iteration)diff --git a/wger/manager/migrations/0018_flexible_routines.py b/wger/manager/migrations/0018_flexible_routines.pyindex 36e5d01d4..06d3223ff 100644--- a/wger/manager/migrations/0018_flexible_routines.py+++ b/wger/manager/migrations/0018_flexible_routines.py@@ -115,6 +115,8 @@ class Migration(migrations.Migration):to='core.repetitionunit',),),+ ('repetition_rounding',+ models.DecimalField(decimal_places=2, default=1, max_digits=4)),('slot',models.ForeignKey(@@ -131,6 +133,8 @@ class Migration(migrations.Migration):verbose_name='Unit',),),+ ('weight_rounding',+ models.DecimalField(decimal_places=2, default=1.25, max_digits=4, )),],options={'ordering': ['order', 'id'],@@ -258,7 +262,6 @@ class Migration(migrations.Migration):),),('value', models.DecimalField(decimal_places=2, max_digits=6)),- ('rounding', models.DecimalField(decimal_places=2, default=1, max_digits=4)),('operation',models.CharField(@@ -312,7 +315,6 @@ class Migration(migrations.Migration):),),('value', models.DecimalField(decimal_places=2, max_digits=6)),- ('rounding', models.DecimalField(decimal_places=2, default=1, max_digits=4)),('operation',models.CharField(@@ -366,7 +368,6 @@ class Migration(migrations.Migration):),),('value', models.DecimalField(decimal_places=2, max_digits=6)),- ('rounding', models.DecimalField(decimal_places=2, default=1, max_digits=4)),('operation',models.CharField(@@ -420,7 +421,6 @@ class Migration(migrations.Migration):),),('value', models.DecimalField(decimal_places=2, max_digits=6)),- ('rounding', models.DecimalField(decimal_places=2, default=1, max_digits=4)),('operation',models.CharField(@@ -477,7 +477,6 @@ class Migration(migrations.Migration):),),('value', models.DecimalField(decimal_places=2, max_digits=6)),- ('rounding', models.DecimalField(decimal_places=2, default=1, max_digits=4)),('operation',models.CharField(diff --git a/wger/manager/models/abstract_config.py b/wger/manager/models/abstract_config.pyindex ce934565e..2d58f0614 100644--- a/wger/manager/models/abstract_config.py+++ b/wger/manager/models/abstract_config.py@@ -70,13 +70,6 @@ class AbstractChangeConfig(models.Model):)"""The actual increment"""- rounding = models.DecimalField(decimal_places=2, max_digits=4, default=1)- """- The amount by which the value will be rounded-- Note that this will happen in the UI, and not in the backend- """-operation = models.CharField(choices=OperationChoices.choices,max_length=1,diff --git a/wger/manager/models/day.py b/wger/manager/models/day.pyindex 24bdaacde..625168d7d 100644--- a/wger/manager/models/day.py+++ b/wger/manager/models/day.py@@ -101,7 +101,7 @@ class DayNg(models.Model):return False- def get_sets(self, iteration: int) -> List[SlotData]:+ def get_slots(self, iteration: int) -> List[SlotData]:"""Return the sets for this day"""diff --git a/wger/manager/models/slot_config.py b/wger/manager/models/slot_config.pyindex 74c5738c9..e27d22cc8 100644--- a/wger/manager/models/slot_config.py+++ b/wger/manager/models/slot_config.py@@ -60,6 +60,17 @@ class SlotConfig(models.Model):The repetition unit of a set. This can be e.g. a repetition, a minute, etc."""+ repetition_rounding = models.DecimalField(+ decimal_places=2,+ max_digits=4,+ default=1,+ )+ """+ The amount by which the repetitions will be rounded++ Note that this will happen in the UI, and not in the backend+ """+weight_unit = models.ForeignKey(WeightUnit,verbose_name=_('Unit'),@@ -70,6 +81,17 @@ class SlotConfig(models.Model):The weight unit of a set. This can be e.g. kg, lb, km/h, etc."""+ weight_rounding = models.DecimalField(+ decimal_places=2,+ max_digits=4,+ default=1.25,+ )+ """+ The amount by which the weight will be rounded++ Note that this will happen in the UI, and not in the backend+ """+order = models.PositiveIntegerField(blank=True,)@@ -101,7 +123,7 @@ class SlotConfig(models.Model):"""Returns the object that has owner information"""- return self.set.day.routine+ return self.slot.day.routine@staticmethoddef calculate_config_value(configs: list[AbstractChangeConfig]) -> Decimal:@@ -180,10 +202,10 @@ class SlotConfig(models.Model):return SetConfigData(sets=self.get_sets(iteration),weight=self.get_weight(max_iter_weight),- weight_rounding=self.get_weight_rounding(max_iter_weight),+ weight_rounding=self.weight_rounding,weight_unit=self.weight_unit.pk,reps=self.get_reps(max_iter_reps),- reps_rounding=self.get_reps_rounding(max_iter_reps),+ reps_rounding=self.repetition_rounding,reps_unit=self.repetition_unit.pk,rir=self.get_rir(iteration),rest=self.get_rest(iteration),@@ -195,15 +217,9 @@ class SlotConfig(models.Model):def get_weight(self, iteration: int) -> Decimal:return self.calculate_config_value(self.weightconfig_set.filter(iteration__lte=iteration))- def get_weight_rounding(self, iteration: int) -> Decimal:- return self.weightconfig_set.filter(iteration__lte=iteration).last().rounding-def get_reps(self, iteration: int) -> Decimal:return self.calculate_config_value(self.repsconfig_set.filter(iteration__lte=iteration))- def get_reps_rounding(self, iteration: int) -> Decimal:- return self.repsconfig_set.filter(iteration__lte=iteration).last().rounding-def get_rir(self, iteration: int) -> Decimal:return self.calculate_config_value(self.rirconfig_set.filter(iteration__lte=iteration))