Skip to content
Snippets Groups Projects
Verified Commit d0ba9abc authored by Ernesto Rico Schmidt's avatar Ernesto Rico Schmidt
Browse files

feat: update Radio settings serializer

parent a4897193
No related branches found
No related tags found
No related merge requests found
Pipeline #8267 passed
......@@ -1217,7 +1217,7 @@ class RadioStationSettings(TypedDict):
class ImageFrame(TypedDict):
aspect_ratio: tuple[int, int]
aspect_ratio: tuple[int, int] | tuple[float, float]
shape: Literal["rect", "round"]
......@@ -1266,18 +1266,21 @@ class RadioSettingsSerializer(serializers.ModelSerializer):
@staticmethod
def get_image_requirements(obj) -> RadioImageRequirementsSettings:
def get_aspect_ration(field) -> tuple[int, int]:
"""return the tuple of ints representing the aspect ratio of the image."""
def get_aspect_ratio(field) -> tuple[int, int] | tuple[float, float]:
"""return the tuple of ints or floats representing the aspect ratio of the image."""
values = field.split(":")
return int(values[0]), int(values[1])
try:
return int(values[0]), int(values[1])
except ValueError:
return float(values[0]), float(values[1])
aspect_ratios = {
"host.image": get_aspect_ration(obj.host_image_aspect_ratio),
"note.image": get_aspect_ration(obj.note_image_aspect_ratio),
"show.image": get_aspect_ration(obj.show_image_aspect_ratio),
"show.logo": get_aspect_ration(obj.show_logo_aspect_ratio),
"host.image": get_aspect_ratio(obj.host_image_aspect_ratio),
"note.image": get_aspect_ratio(obj.note_image_aspect_ratio),
"show.image": get_aspect_ratio(obj.show_image_aspect_ratio),
"show.logo": get_aspect_ratio(obj.show_logo_aspect_ratio),
}
return {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment