Skip to content

Commit

Permalink
added changing exercise order by dragging
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipSnell committed Nov 22, 2021
1 parent 2c168ea commit c007c12
Show file tree
Hide file tree
Showing 6 changed files with 338 additions and 26 deletions.
18 changes: 18 additions & 0 deletions api/migrations/0010_trainingentry_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.14 on 2021-11-13 09:02

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api', '0009_auto_20211110_1936'),
]

operations = [
migrations.AddField(
model_name='trainingentry',
name='order',
field=models.IntegerField(default=0),
),
]
4 changes: 4 additions & 0 deletions api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ class TrainingEntry(models.Model):
sets = models.IntegerField()
comment = models.CharField(max_length=300, blank=True)
exercise = models.ForeignKey(ExerciseType, on_delete=models.CASCADE, related_name='Exercise')
order = models.IntegerField(default=0)

class Meta:
ordering = ['day', 'order']

def __str__(self):
return "Phase " + str(self.phase) + " Week " + str(self.week) + " Day " + str(self.day) + " " + str(self.exercise.name)
Expand Down
6 changes: 4 additions & 2 deletions api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def id_field(self, training):
return training.id
class Meta:
model = TrainingEntry
fields = ("id",

fields = ('id',
'user',
'phase',
'week',
Expand All @@ -38,7 +39,8 @@ class Meta:
'weight',
'sets',
'exercise',
'comment'
'comment',
'order'
)

class SetFeedbackSerializer(serializers.ModelSerializer):
Expand Down
Loading

0 comments on commit c007c12

Please sign in to comment.