-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added tags for images, events and news #103
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from typing import TYPE_CHECKING | ||
|
||
from sqlalchemy import String | ||
|
||
from helpers.constants import MAX_TAG_NAME | ||
from .base_model import BaseModel_DB | ||
from sqlalchemy.orm import mapped_column, Mapped | ||
from sqlalchemy.ext.associationproxy import association_proxy, AssociationProxy | ||
|
||
if TYPE_CHECKING: | ||
from news_model import News_DB | ||
from event_model import Event_DB | ||
from img_model import Img_DB | ||
|
||
|
||
class Tag_DB(BaseModel_DB): | ||
__tablename__ = "tag_table" | ||
|
||
id: Mapped[int] = mapped_column(primary_key=True, init=False) | ||
tag_name: Mapped[str] = mapped_column(String(MAX_TAG_NAME)) | ||
color: Mapped[str] = mapped_column(String(7)) # Defined as #ff0000 for example | ||
|
||
events: AssociationProxy[list["Event_DB"]] = association_proxy( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Detta är inte rätt implementerat, ska vara kopplat på annat sätt, skulle läsa att du vill göra typ en EventTags model också istället |
||
target_collection="event_tags", attr="tag", init=False | ||
) | ||
|
||
news: AssociationProxy[list["News_DB"]] = association_proxy(target_collection="news_tags", attr="tag", init=False) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. samma sak som ovam |
||
|
||
images: AssociationProxy[list["Img_DB"]] = association_proxy(target_collection="image_tags", attr="tag", init=False) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. samma sak igen |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,3 +32,6 @@ | |
|
||
# Imgs | ||
MAX_IMG_NAME = 200 | ||
|
||
# Tag | ||
MAX_TAG_NAME = 100 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kan vara värt att kolla på detta: https://docs.pydantic.dev/2.0/usage/types/extra_types/color_types/