Commit a15c063c authored by ibooking-sigurd's avatar ibooking-sigurd
Browse files

Rewrite part of the workout-serializer to reduce the complexity.

parent 5fd7d955
......@@ -167,8 +167,12 @@ class WorkoutSerializer(serializers.HyperlinkedModelSerializer):
if "files" in validated_data:
files_data = validated_data.pop("files")
files = instance.files
handle_workout_files(self, files, files_data)
for file, file_data in zip(files.all(), files_data):
return instance
def handle_workout_files(self, files, files_data):
for file, file_data in zip(files.all(), files_data):
file.file = file_data.get("file", file.file)
# If new files have been added, creating new WorkoutFiles
......@@ -184,8 +188,6 @@ class WorkoutSerializer(serializers.HyperlinkedModelSerializer):
for i in range(len(files_data), len(files.all())):
return instance
def get_owner_username(self, obj):
"""Returns the owning user's username
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