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
6b54bf67
Verified
Commit
6b54bf67
authored
8 months ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
refactor: use the typed dicts explicitly
parent
5bd89e8a
No related branches found
No related tags found
No related merge requests found
Pipeline
#8294
failed
8 months ago
Stage: check
Stage: test
Stage: build
Stage: deploy
Stage: release
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
program/serializers.py
+33
-29
33 additions, 29 deletions
program/serializers.py
with
33 additions
and
29 deletions
program/serializers.py
+
33
−
29
View file @
6b54bf67
...
...
@@ -53,9 +53,11 @@ from program.models import (
)
from
program.typing
import
(
Logo
,
MicroProgram
,
NestedEpisode
,
NestedSchedule
,
NestedShow
,
ProgramFallback
,
RadioCBASettings
,
RadioImageRequirementsSettings
,
RadioPlayoutSettings
,
...
...
@@ -1197,12 +1199,12 @@ class RadioSettingsSerializer(serializers.ModelSerializer):
def
get_cba
(
self
,
obj
)
->
RadioCBASettings
:
if
self
.
context
.
get
(
"
request
"
).
user
.
is_authenticated
:
return
{
"
api_key
"
:
obj
.
cba_api_key
,
"
domains
"
:
obj
.
cba_domains
,
}
return
RadioCBASettings
(
api_key
=
obj
.
cba_api_key
,
domains
=
obj
.
cba_domains
,
)
else
:
return
{
"
domains
"
:
obj
.
cba_domains
}
return
RadioCBASettings
(
domains
=
obj
.
cba_domains
)
@staticmethod
def
get_image_requirements
(
obj
)
->
RadioImageRequirementsSettings
:
...
...
@@ -1252,36 +1254,38 @@ class RadioSettingsSerializer(serializers.ModelSerializer):
@staticmethod
def
get_program
(
obj
)
->
RadioProgramSettings
:
return
{
"
micro
"
:
{
"
show_id
"
:
obj
.
micro_show
.
id
if
obj
.
micro_show
else
None
}
,
"
fallback
"
:
{
"
show_id
"
:
obj
.
fallback_show
.
id
if
obj
.
fallback_show
else
None
,
"
default_pool
"
:
"
fallback
"
if
obj
.
fallback_default_pool
else
""
,
}
,
}
return
RadioProgramSettings
(
micro
=
MicroProgram
(
show_id
=
obj
.
micro_show
.
id
if
obj
.
micro_show
else
None
)
,
fallback
=
ProgramFallback
(
show_id
=
obj
.
fallback_show
.
id
if
obj
.
fallback_show
else
None
,
default_pool
=
"
fallback
"
if
obj
.
fallback_default_pool
else
""
,
)
,
)
@staticmethod
def
get_playout
(
obj
)
->
RadioPlayoutSettings
:
return
{
"
line_in_channels
"
:
obj
.
line_in_channels
,
"
pools
"
:
obj
.
pools
,
}
return
RadioPlayoutSettings
(
line_in_channels
=
obj
.
line_in_channels
,
pools
=
obj
.
pools
,
)
@staticmethod
def
get_station
(
obj
)
->
RadioStationSettings
:
return
{
"
name
"
:
obj
.
station_name
,
"
logo
"
:
(
Logo
(
url
=
f
"
{
settings
.
SITE_URL
}{
obj
.
station_logo
.
url
}
"
,
height
=
obj
.
station_logo
.
height
,
width
=
obj
.
station_logo
.
width
,
)
if
obj
.
station_logo
else
None
),
"
website
"
:
obj
.
station_website
,
}
logo
=
(
Logo
(
url
=
f
"
{
settings
.
SITE_URL
}{
obj
.
station_logo
.
url
}
"
,
height
=
obj
.
station_logo
.
height
,
width
=
obj
.
station_logo
.
width
,
)
if
obj
.
station_logo
else
None
)
return
RadioStationSettings
(
name
=
obj
.
station_name
,
logo
=
logo
,
website
=
obj
.
station_website
,
)
# done this way to get the schema annotations for datetime right
...
...
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