Skip to content
Snippets Groups Projects
Commit b0ebbfa6 authored by Simon Künzel's avatar Simon Künzel
Browse files

Add image target medium

parent b4d6c81c
Branches
No related tags found
No related merge requests found
...@@ -156,6 +156,7 @@ class TargetMediumType(Enum): ...@@ -156,6 +156,7 @@ class TargetMediumType(Enum):
PLAIN_VIDEO = "plain_video" PLAIN_VIDEO = "plain_video"
PLAIN_AUDIO = "plain_audio" PLAIN_AUDIO = "plain_audio"
THUMBNAIL = "thumbnail" THUMBNAIL = "thumbnail"
IMAGE = "image"
_TARGET_MEDIUM_TYPE_ENUM = create_enum_type(TargetMediumType) _TARGET_MEDIUM_TYPE_ENUM = create_enum_type(TargetMediumType)
...@@ -194,12 +195,12 @@ class TargetMedium(DeletableApiObject, Base): ...@@ -194,12 +195,12 @@ class TargetMedium(DeletableApiObject, Base):
name="check_audio_channel_count_not_null" name="check_audio_channel_count_not_null"
), ),
CheckConstraint( CheckConstraint(
f"type NOT IN ('plain_video') OR NOT is_produced OR video_vertical_resolution IS NOT NULL", f"type NOT IN ('plain_video', 'thumbnail') OR NOT is_produced OR vertical_resolution IS NOT NULL",
name="check_video_vertical_resolution_not_null" name="check_vertical_resolution_not_null"
), ),
CheckConstraint( CheckConstraint(
f"type NOT IN ('plain_video') OR NOT is_produced OR video_horizontal_resolution IS NOT NULL", f"type NOT IN ('plain_video', 'thumbnail') OR NOT is_produced OR horizontal_resolution IS NOT NULL",
name="check_video_horizontal_resolution_not_null" name="check_horizontal_resolution_not_null"
), ),
CheckConstraint( CheckConstraint(
f"type NOT IN ('plain_video') OR NOT is_produced OR video_frame_rate_numerator IS NOT NULL", f"type NOT IN ('plain_video') OR NOT is_produced OR video_frame_rate_numerator IS NOT NULL",
...@@ -371,13 +372,13 @@ class SingleAudioContainingMedium(ApiObject): ...@@ -371,13 +372,13 @@ class SingleAudioContainingMedium(ApiObject):
class SingleVideoContainingMedium(ApiObject): class SingleVideoContainingMedium(ApiObject):
video_vertical_resolution: Mapped[int] = api_mapped( vertical_resolution: Mapped[int] = api_mapped(
mapped_column(nullable=True, use_existing_column=True), mapped_column(nullable=True, use_existing_column=True),
ApiIntegerField( ApiIntegerField(
include_in_data=True include_in_data=True
) )
) )
video_horizontal_resolution: Mapped[int] = api_mapped( horizontal_resolution: Mapped[int] = api_mapped(
mapped_column(nullable=True, use_existing_column=True), mapped_column(nullable=True, use_existing_column=True),
ApiIntegerField( ApiIntegerField(
include_in_data=True include_in_data=True
...@@ -397,6 +398,22 @@ class SingleVideoContainingMedium(ApiObject): ...@@ -397,6 +398,22 @@ class SingleVideoContainingMedium(ApiObject):
) )
class SingleImageContainingMedium(ApiObject):
vertical_resolution: Mapped[int] = api_mapped(
mapped_column(nullable=True, use_existing_column=True),
ApiIntegerField(
include_in_data=True
)
)
horizontal_resolution: Mapped[int] = api_mapped(
mapped_column(nullable=True, use_existing_column=True),
ApiIntegerField(
include_in_data=True
)
)
class PlainVideoTargetMedium(TargetMedium, FileMedium, SingleVideoContainingMedium, SingleAudioContainingMedium): class PlainVideoTargetMedium(TargetMedium, FileMedium, SingleVideoContainingMedium, SingleAudioContainingMedium):
__tablename__ = None # Prevent our own base from adding a table name. This should be a single-table inheritance __tablename__ = None # Prevent our own base from adding a table name. This should be a single-table inheritance
__mapper_args__ = { __mapper_args__ = {
...@@ -425,13 +442,21 @@ class PlainAudioTargetMedium(TargetMedium, FileMedium, SingleAudioContainingMedi ...@@ -425,13 +442,21 @@ class PlainAudioTargetMedium(TargetMedium, FileMedium, SingleAudioContainingMedi
) )
class ThumbnailTargetMedium(TargetMedium, FileMedium): # Thumbnail is a different type so that the Frontend knows what to display as the thumbnail
class ThumbnailTargetMedium(TargetMedium, FileMedium, SingleImageContainingMedium):
__tablename__ = None # Prevent our own base from adding a table name. This should be a single-table inheritance __tablename__ = None # Prevent our own base from adding a table name. This should be a single-table inheritance
__mapper_args__ = { __mapper_args__ = {
"polymorphic_identity": TargetMediumType.THUMBNAIL "polymorphic_identity": TargetMediumType.THUMBNAIL
} }
class ImageTargetMedium(TargetMedium, FileMedium, SingleImageContainingMedium):
__tablename__ = None # Prevent our own base from adding a table name. This should be a single-table inheritance
__mapper_args__ = {
"polymorphic_identity": TargetMediumType.IMAGE
}
class PublishMedium(VisibilityApiObject, DeletableApiObject, Base): class PublishMedium(VisibilityApiObject, DeletableApiObject, Base):
__api_data__ = ApiObjectClass( __api_data__ = ApiObjectClass(
parent_relationship_config_ids=["lecture"] parent_relationship_config_ids=["lecture"]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment