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

Add constraints for featured values

parent 1f6da757
No related branches found
No related tags found
No related merge requests found
...@@ -90,6 +90,21 @@ class Featured(DeletableApiObject, VisibilityApiObject, Base): ...@@ -90,6 +90,21 @@ class Featured(DeletableApiObject, VisibilityApiObject, Base):
"with_polymorphic": "*", # Always load all attributes for all types, "with_polymorphic": "*", # Always load all attributes for all types,
"polymorphic_identity": FeaturedType.PLAIN "polymorphic_identity": FeaturedType.PLAIN
} }
__table_args__ = (
CheckConstraint(
f"type NOT IN ('image') OR image_url IS NOT NULL",
name="check_image_set"
),
CheckConstraint(
f"type NOT IN ('course') OR course_id IS NOT NULL",
name="check_course_id_set"
),
CheckConstraint(
f"type NOT IN ('lecture') OR lecture_id IS NOT NULL",
name="check_lecture_id_set"
),
)
title: Mapped[str] = api_mapped( title: Mapped[str] = api_mapped(
mapped_column(Text(collation=STRING_COLLATION), nullable=False, default=""), mapped_column(Text(collation=STRING_COLLATION), nullable=False, default=""),
ApiStringField( ApiStringField(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment