Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
steering
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AURA
steering
Commits
7ea297db
Commit
7ea297db
authored
2 years ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
Add created_{at,by}, updated_{at,by} to serializers
- fixed image field names, - removed fields that are no longer used
parent
cafe5a96
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
program/serializers.py
+47
-9
47 additions, 9 deletions
program/serializers.py
with
47 additions
and
9 deletions
program/serializers.py
+
47
−
9
View file @
7ea297db
...
...
@@ -201,6 +201,11 @@ class HostSerializer(serializers.ModelSerializer):
"
image_height
"
,
"
image_credits
"
,
"
image_alt_text
"
,
# ModelWithCreatedUpdatedFields
"
created_at
"
,
"
created_by
"
,
"
updated_at
"
,
"
updated_by
"
,
)
def
create
(
self
,
validated_data
):
...
...
@@ -222,7 +227,13 @@ class HostSerializer(serializers.ModelSerializer):
instance
.
email
=
validated_data
.
get
(
"
email
"
,
instance
.
email
)
instance
.
biography
=
validated_data
.
get
(
"
biography
"
,
instance
.
biography
)
instance
.
image
=
validated_data
.
get
(
"
image
"
,
instance
.
image
)
instance
.
ppoi
=
validated_data
.
get
(
"
ppoi
"
,
instance
.
ppoi
)
instance
.
image_ppoi
=
validated_data
.
get
(
"
image_ppoi
"
,
instance
.
image_ppoi
)
instance
.
image_credits
=
validated_data
.
get
(
"
image_credits
"
,
instance
.
image_credits
)
instance
.
image_alt_text
=
validated_data
.
get
(
"
image_alt_text
"
,
instance
.
image_alt_text
)
if
instance
.
links
.
count
()
>
0
:
for
link
in
instance
.
links
.
all
():
...
...
@@ -340,6 +351,11 @@ class ShowSerializer(serializers.HyperlinkedModelSerializer):
"
image_height
"
,
"
image_credits
"
,
"
image_alt_text
"
,
# ModelWithCreatedUpdatedFields
"
created_at
"
,
"
created_by
"
,
"
updated_at
"
,
"
updated_by
"
,
)
def
create
(
self
,
validated_data
):
...
...
@@ -379,7 +395,13 @@ class ShowSerializer(serializers.HyperlinkedModelSerializer):
instance
.
name
=
validated_data
.
get
(
"
name
"
,
instance
.
name
)
instance
.
slug
=
validated_data
.
get
(
"
slug
"
,
instance
.
slug
)
instance
.
image
=
validated_data
.
get
(
"
image
"
,
instance
.
image
)
instance
.
ppoi
=
validated_data
.
get
(
"
ppoi
"
,
instance
.
ppoi
)
instance
.
image_ppoi
=
validated_data
.
get
(
"
image_ppoi
"
,
instance
.
image_ppoi
)
instance
.
image_credits
=
validated_data
.
get
(
"
image_credits
"
,
instance
.
image_credits
)
instance
.
image_alt_text
=
validated_data
.
get
(
"
image_alt_text
"
,
instance
.
image_alt_text
)
instance
.
logo
=
validated_data
.
get
(
"
logo
"
,
instance
.
logo
)
instance
.
short_description
=
validated_data
.
get
(
"
short_description
"
,
instance
.
short_description
...
...
@@ -618,9 +640,8 @@ class NoteLinkSerializer(LinkSerializer):
class
NoteSerializer
(
serializers
.
ModelSerializer
):
links
=
NoteLinkSerializer
(
many
=
True
,
required
=
False
)
show
=
serializers
.
PrimaryKeyRelatedField
(
queryset
=
Show
.
objects
.
all
())
timeslot
=
serializers
.
PrimaryKeyRelatedField
(
queryset
=
TimeSlot
.
objects
.
all
())
host
=
serializers
.
PrimaryKeyRelatedField
(
queryset
=
Host
.
objects
.
all
())
contributors
=
serializers
.
PrimaryKeyRelatedField
(
queryset
=
Host
.
objects
.
all
())
thumbnails
=
serializers
.
SerializerMethodField
()
@staticmethod
...
...
@@ -650,19 +671,28 @@ class NoteSerializer(serializers.ModelSerializer):
"
image
"
,
"
image_ppoi
"
,
"
image_width
"
,
"
image_height
"
"
image_credits
"
,
"
image_height
"
,
"
image_credits
"
,
"
image_alt_text
"
,
# ModelWithCreatedUpdatedFields
"
created_at
"
,
"
created_by
"
,
"
updated_at
"
,
"
updated_by
"
,
)
def
create
(
self
,
validated_data
):
"""
Create and return a new Note instance, given the validated data.
"""
links_data
=
validated_data
.
pop
(
"
links
"
,
[])
contributors
=
validated_data
.
pop
(
"
contributors
"
,
[])
#
Save
the creator
# the creator
of the note is the owner
validated_data
[
"
owner
"
]
=
self
.
context
[
"
user_id
"
]
note
=
Note
.
objects
.
create
(
**
validated_data
)
note
.
contributors
.
set
(
contributors
)
if
cba_id
:
=
validated_data
.
get
(
"
cba_id
"
):
if
audio_url
:
=
get_audio_url
(
cba_id
):
NoteLink
.
objects
.
create
(
note
=
note
,
description
=
"
CBA
"
,
url
=
audio_url
)
...
...
@@ -693,11 +723,19 @@ class NoteSerializer(serializers.ModelSerializer):
instance
.
summary
=
validated_data
.
get
(
"
summary
"
,
instance
.
summary
)
instance
.
content
=
validated_data
.
get
(
"
content
"
,
instance
.
content
)
instance
.
image
=
validated_data
.
get
(
"
image
"
,
instance
.
image
)
instance
.
ppoi
=
validated_data
.
get
(
"
ppoi
"
,
instance
.
ppoi
)
instance
.
status
=
validated_data
.
get
(
"
status
"
,
instance
.
status
)
instance
.
host
=
validated_data
.
get
(
"
host
"
,
instance
.
host
)
instance
.
image_ppoi
=
validated_data
.
get
(
"
image_ppoi
"
,
instance
.
image_ppoi
)
instance
.
image_credits
=
validated_data
.
get
(
"
image_credits
"
,
instance
.
image_credits
)
instance
.
image_alt_text
=
validated_data
.
get
(
"
image_alt_text
"
,
instance
.
image_alt_text
)
instance
.
cba_id
=
validated_data
.
get
(
"
cba_id
"
,
instance
.
cba_id
)
instance
.
contributors
.
set
(
validated_data
.
get
(
"
contributors
"
,
instance
.
contributors
)
)
if
instance
.
links
.
count
()
>
0
:
for
link
in
instance
.
links
.
all
():
link
.
delete
(
keep_parents
=
True
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment