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
002032e9
Commit
002032e9
authored
9 months ago
by
Konrad Mohrfeldt
Browse files
Options
Downloads
Patches
Plain Diff
fix: add proper type info for radio settings API
refs
dashboard#282
parent
62c01d4d
No related branches found
No related tags found
No related merge requests found
Pipeline
#8115
passed
9 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
+24
-5
24 additions, 5 deletions
program/serializers.py
with
24 additions
and
5 deletions
program/serializers.py
+
24
−
5
View file @
002032e9
...
...
@@ -19,7 +19,7 @@
#
import
re
from
typing
import
TypedDict
from
typing
import
NotRequired
,
TypedDict
from
drf_jsonschema_serializer
import
JSONSchemaField
from
rest_framework
import
serializers
...
...
@@ -1085,6 +1085,25 @@ class NoteSerializer(serializers.ModelSerializer):
return
instance
class
RadioCBASettings
(
TypedDict
):
api_key
:
NotRequired
[
str
]
domains
:
list
[
str
]
class
RadioProgrammeSettings
(
TypedDict
):
fallback_show_id
:
int
|
None
class
RadioPlayoutSettings
(
TypedDict
):
line_in_channels
:
dict
[
str
,
str
]
class
RadioStationSettings
(
TypedDict
):
name
:
str
logo_id
:
int
|
None
website
:
str
class
RadioSettingsSerializer
(
serializers
.
ModelSerializer
):
cba
=
serializers
.
SerializerMethodField
()
playout
=
serializers
.
SerializerMethodField
()
...
...
@@ -1096,7 +1115,7 @@ class RadioSettingsSerializer(serializers.ModelSerializer):
fields
=
read_only_fields
model
=
RadioSettings
def
get_cba
(
self
,
obj
)
->
dict
[
str
,
str
]
|
dict
[
str
,
list
[
str
]]
:
def
get_cba
(
self
,
obj
)
->
RadioCBASettings
:
if
self
.
context
.
get
(
"
request
"
).
user
.
is_authenticated
:
return
{
"
api_key
"
:
obj
.
cba_api_key
,
...
...
@@ -1106,15 +1125,15 @@ class RadioSettingsSerializer(serializers.ModelSerializer):
return
{
"
domains
"
:
obj
.
cba_domains
}
@staticmethod
def
get_programme
(
obj
)
->
dict
[
str
,
int
]
:
def
get_programme
(
obj
)
->
RadioProgrammeSettings
:
return
{
"
fallback_show_id
"
:
obj
.
fallback_show
.
id
if
obj
.
fallback_show
else
None
}
@staticmethod
def
get_playout
(
obj
)
->
dict
[
str
,
dict
[
str
,
str
]]
:
def
get_playout
(
obj
)
->
RadioPlayoutSettings
:
return
{
"
line_in_channels
"
:
obj
.
line_in_channels
}
@staticmethod
def
get_station
(
obj
)
->
dict
[
str
,
int
|
str
]
:
def
get_station
(
obj
)
->
RadioStationSettings
:
return
{
"
name
"
:
obj
.
station_name
,
"
logo_id
"
:
obj
.
station_logo
.
id
if
obj
.
station_logo
else
None
,
...
...
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