Commit 63decf5e authored by Victoria Ahmadi's avatar Victoria Ahmadi
Browse files

Added coach_usernamer as a field in the serializer.

parent 6f4c591b
Pipeline #112672 failed with stages
in 2 minutes
......@@ -9,10 +9,11 @@ class SuggestedWorkoutSerializer(serializers.ModelSerializer):
suggested_exercise_instances = ExerciseInstanceSerializer(
many=True, required=False)
suggested_workout_files = WorkoutFileSerializer(many=True, required=False)
coach_username = serializers.SerializerMethodField()
class Meta:
model = SuggestedWorkout
fields = ['id', 'athlete', 'name', 'notes', 'date',
fields = ['id', 'athlete', 'coach_username', 'name', 'notes', 'date',
'status', 'coach', 'suggested_exercise_instances', 'suggested_workout_files']
extra_kwargs = {"coach": {"read_only": True}}
......@@ -111,3 +112,14 @@ class SuggestedWorkoutSerializer(serializers.ModelSerializer):
return instance
def get_coach_username(self, obj):
"""Returns the owning user's username
obj (Workout): Current Workout
str: Username of owner
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment