fix: changing status on deal complete
This commit is contained in:
@@ -1164,6 +1164,16 @@ class CardsService(BaseService):
|
||||
|
||||
# endregion
|
||||
|
||||
async def _get_final_status_for_card(self, card_id: int) -> Optional[CardStatus]:
|
||||
stmt = (
|
||||
select(CardStatus)
|
||||
.join(Board)
|
||||
.join(Card)
|
||||
.where(Card.id == card_id, CardStatus.is_finishing == True)
|
||||
)
|
||||
card_status: Optional[CardStatus] = (await self.session.scalars(stmt)).one_or_none()
|
||||
return card_status
|
||||
|
||||
async def complete(self, user: User, request: CardCompleteRequest) -> CardCompleteResponse:
|
||||
try:
|
||||
# check for admin
|
||||
@@ -1178,6 +1188,11 @@ class CardsService(BaseService):
|
||||
await card_group.CardGroupService(self.session).complete_group(card.group.id)
|
||||
else:
|
||||
card.is_completed = True
|
||||
|
||||
final_status: Optional[CardStatus] = await self._get_final_status_for_card(card.id)
|
||||
if final_status:
|
||||
await self.change_status(card, final_status.id, user)
|
||||
|
||||
await self.session.commit()
|
||||
|
||||
return CardCompleteResponse(ok=True, message="Успешно завершена")
|
||||
|
||||
Reference in New Issue
Block a user