feat: colors for card tags
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.orm import selectinload
|
||||
|
||||
from models import CardTag, Card, CardGroup
|
||||
from models import CardTag, Card, CardGroup, CardTagColor
|
||||
from schemas.card_tag import *
|
||||
from services.base import BaseService
|
||||
|
||||
@@ -24,7 +24,11 @@ class CardTagService(BaseService):
|
||||
if existing_tag:
|
||||
return UpdateTagResponse(ok=False, message='Тег с таким названием уже существует')
|
||||
|
||||
tag = CardTag(name=request.tag.name, project_id=request.tag.project_id)
|
||||
tag = CardTag(
|
||||
name=request.tag.name,
|
||||
project_id=request.tag.project_id,
|
||||
tag_color_id=request.tag.tag_color_id,
|
||||
)
|
||||
self.session.add(tag)
|
||||
await self.session.commit()
|
||||
return CreateTagResponse(ok=True, message='Тег успешно создан')
|
||||
@@ -41,6 +45,8 @@ class CardTagService(BaseService):
|
||||
|
||||
card_tag.name = request.tag.name
|
||||
|
||||
card_tag.tag_color_id = request.tag.tag_color_id
|
||||
|
||||
await self.session.commit()
|
||||
return UpdateTagResponse(ok=True, message='Тег успешно обновлен')
|
||||
|
||||
@@ -127,3 +133,11 @@ class CardTagService(BaseService):
|
||||
card.tags = tags
|
||||
|
||||
await self.session.flush()
|
||||
|
||||
async def get_tag_colors(self) -> GetTagColorsResponse:
|
||||
stmt = (
|
||||
select(CardTagColor)
|
||||
.where(CardTagColor.is_deleted==False)
|
||||
)
|
||||
colors = (await self.session.scalars(stmt)).all()
|
||||
return GetTagColorsResponse(colors=colors)
|
||||
|
||||
Reference in New Issue
Block a user