Self hosted FLOSS fitness/workout, nutrition and weight tracker
Fix: Auto-calculate SlotEntry.order when not provided via API
ndimoro677da4427b06
diff --git a/wger/manager/models/slot_entry.py b/wger/manager/models/slot_entry.pyindex dfc4a606f..7bae76835 100644--- a/wger/manager/models/slot_entry.py+++ b/wger/manager/models/slot_entry.py@@ -140,6 +140,7 @@ class SlotEntry(models.Model):order = models.PositiveIntegerField(blank=True,+ null=True,db_index=True,)@@ -213,6 +214,12 @@ class SlotEntry(models.Model):)if not self.weight_rounding:self.weight_rounding = self.slot.day.routine.user.userprofile.weight_rounding++ # Auto-calculate order if not provided+ if self.order is None:+ max_order = self.slot.entries.aggregate(models.Max('order'))['order__max']+ self.order = (max_order or 0) + 1+return super().save(*args, **kwargs)def get_owner_object(self):