Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Rolf Erik Sesseng Aas
tdt4242-base
Commits
bad0363d
Commit
bad0363d
authored
Apr 19, 2021
by
ibooking-sigurd
Browse files
Fix indentation error.
parent
a15c063c
Changes
1
Hide whitespace changes
Inline
Side-by-side
backend/secfit/workouts/serializers.py
View file @
bad0363d
...
...
@@ -172,21 +172,21 @@ class WorkoutSerializer(serializers.HyperlinkedModelSerializer):
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
if
len
(
files_data
)
>
len
(
files
.
all
()):
for
i
in
range
(
len
(
files
.
all
()),
len
(
files_data
)):
WorkoutFile
.
objects
.
create
(
workout
=
instance
,
owner
=
instance
.
owner
,
file
=
files_data
[
i
].
get
(
"file"
),
)
# Else if files have been removed, delete WorkoutFiles
elif
len
(
files_data
)
<
len
(
files
.
all
()):
for
i
in
range
(
len
(
files_data
),
len
(
files
.
all
())):
files
.
all
()[
i
].
delete
()
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
if
len
(
files_data
)
>
len
(
files
.
all
()):
for
i
in
range
(
len
(
files
.
all
()),
len
(
files_data
)):
WorkoutFile
.
objects
.
create
(
workout
=
instance
,
owner
=
instance
.
owner
,
file
=
files_data
[
i
].
get
(
"file"
),
)
# Else if files have been removed, delete WorkoutFiles
elif
len
(
files_data
)
<
len
(
files
.
all
()):
for
i
in
range
(
len
(
files_data
),
len
(
files
.
all
())):
files
.
all
()[
i
].
delete
()
def
get_owner_username
(
self
,
obj
):
"""Returns the owning user's username
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment