diff --git a/program/serializers.py b/program/serializers.py index 2d3b67d7e676446c316a19ad2e8bbae49cd77552..1f38d1f0b9f0aad09e9fd0f782ce3ec7d8818121 100644 --- a/program/serializers.py +++ b/program/serializers.py @@ -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 {