wip
This commit is contained in:
18
workout/migrations/0004_workoutexercise_duration.py
Normal file
18
workout/migrations/0004_workoutexercise_duration.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 4.2.2 on 2023-06-14 13:24
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('workout', '0003_alter_workout_name'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='workoutexercise',
|
||||
name='duration',
|
||||
field=models.IntegerField(blank=True, max_length=4, null=True),
|
||||
),
|
||||
]
|
||||
@@ -39,10 +39,19 @@ class WorkoutExercise(models.Model):
|
||||
)
|
||||
weight = models.IntegerField(null=True, blank=True, max_length=4)
|
||||
reps = models.IntegerField(null=True, blank=True, max_length=4)
|
||||
duration = models.IntegerField(null=True, blank=True, max_length=4)
|
||||
|
||||
def __str__(self):
|
||||
return self.workout.name + " : " + self.exercise.name
|
||||
|
||||
def duration_audio(self):
|
||||
if self.duration is not None:
|
||||
return str(settings.MEDIA_URL) + "quantities_audio/" + "for_"+str(self.duration)+"_seconds.m4a"
|
||||
|
||||
def weight_audio(self):
|
||||
if self.weight is not None:
|
||||
return str(settings.MEDIA_URL) + "quantities_audio/" + "for_"+str(self.weight)+"_pounds.m4a"
|
||||
|
||||
class CompletedWorkout(models.Model):
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
@@ -5,10 +5,14 @@ from registered_user.serializers import GetRegisteredUserSerializer
|
||||
|
||||
class WorkoutExerciseSerializer(serializers.ModelSerializer):
|
||||
exercise = ExerciseSerializer(read_only=True)
|
||||
duration_audio = serializers.ReadOnlyField()
|
||||
weight_audio = serializers.ReadOnlyField()
|
||||
|
||||
class Meta:
|
||||
model = WorkoutExercise
|
||||
fields = ('workout', 'exercise','weight','reps')
|
||||
fields = ('workout', 'exercise','weight','reps','duration','duration_audio','weight_audio', 'created_at',)
|
||||
|
||||
|
||||
|
||||
class CompleteWorkoutSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
|
||||
Reference in New Issue
Block a user