feat: processing of modules in card, renaming
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
from collections import defaultdict
|
||||
from typing import Union
|
||||
|
||||
import lexorank
|
||||
from fastapi import HTTPException
|
||||
@@ -48,12 +47,15 @@ class CardsService(BaseService):
|
||||
return str(prev.next())
|
||||
return str(lexorank.parse(card.lexorank).next())
|
||||
|
||||
async def change_status(self, card: Card,
|
||||
status_id: int,
|
||||
user: User,
|
||||
deadline: datetime = None,
|
||||
rank=None,
|
||||
comment: str = ''):
|
||||
async def change_status(
|
||||
self,
|
||||
card: Card,
|
||||
status_id: int,
|
||||
user: User,
|
||||
deadline: datetime = None,
|
||||
rank=None,
|
||||
comment: str = ''
|
||||
):
|
||||
if not card.current_status_id == status_id:
|
||||
deadline = deadline
|
||||
status_change = CardStatusHistory(
|
||||
@@ -92,7 +94,7 @@ class CardsService(BaseService):
|
||||
client_service = ClientService(self.session)
|
||||
client = await client_service.get_by_name(request.client_name)
|
||||
|
||||
if not client:
|
||||
if not client and request.client_name:
|
||||
client = await client_service.create_client_raw(
|
||||
user,
|
||||
request.client_name,
|
||||
@@ -101,19 +103,19 @@ class CardsService(BaseService):
|
||||
|
||||
shipping_warehouse_service = ShippingWarehouseService(self.session)
|
||||
shipping_warehouse = await shipping_warehouse_service.get_by_name(name=request.shipping_warehouse)
|
||||
if not shipping_warehouse:
|
||||
if not shipping_warehouse and request.shipping_warehouse:
|
||||
shipping_warehouse = await shipping_warehouse_service.create_by_name(name=request.shipping_warehouse)
|
||||
|
||||
rank = await self._get_rank_for_card(request.status_id)
|
||||
card = Card(
|
||||
name=request.name,
|
||||
created_at=datetime.now(),
|
||||
client_id=client.id,
|
||||
client_id=client.id if client else None,
|
||||
current_status_id=request.status_id,
|
||||
board_id=card_status.board_id,
|
||||
lexorank=rank,
|
||||
shipping_warehouse_id=shipping_warehouse.id,
|
||||
base_marketplace_key=request.base_marketplace.key
|
||||
shipping_warehouse_id=shipping_warehouse.id if shipping_warehouse else None,
|
||||
base_marketplace_key=request.base_marketplace.key if request.base_marketplace else None
|
||||
)
|
||||
self.session.add(card)
|
||||
await self.session.flush()
|
||||
@@ -225,10 +227,11 @@ class CardsService(BaseService):
|
||||
summaries.append(
|
||||
CardSummary(
|
||||
id=card.id,
|
||||
client_name=card.client.name,
|
||||
client_name=card.client.name if card.client else None,
|
||||
name=card.name,
|
||||
status=card.status,
|
||||
board=card.board,
|
||||
group=card.group,
|
||||
total_price=total_price,
|
||||
rank=rank,
|
||||
base_marketplace=base_marketplace,
|
||||
@@ -237,7 +240,6 @@ class CardsService(BaseService):
|
||||
shipment_warehouse_name=shipment_warehouse_name,
|
||||
total_products=products_count,
|
||||
bill_request=card.bill_request,
|
||||
group=card.group
|
||||
)
|
||||
)
|
||||
return CardSummaryResponse(summaries=summaries)
|
||||
@@ -334,8 +336,11 @@ class CardsService(BaseService):
|
||||
|
||||
return CardSchema.model_validate(card)
|
||||
|
||||
async def update_general_info(self, request: CardUpdateGeneralInfoRequest,
|
||||
user: User) -> CardUpdateGeneralInfoResponse:
|
||||
async def update_general_info(
|
||||
self,
|
||||
request: CardUpdateGeneralInfoRequest,
|
||||
user: User
|
||||
) -> CardUpdateGeneralInfoResponse:
|
||||
try:
|
||||
card: Card = await self.session.scalar(
|
||||
select(Card)
|
||||
|
||||
Reference in New Issue
Block a user