feat: generation of modules from the server, moved modules fields from the general tab
This commit is contained in:
@@ -368,14 +368,6 @@ class CardsService(BaseService):
|
||||
card.board_id = request.data.board_id
|
||||
await self.change_status(card, request.data.status_id, user)
|
||||
|
||||
# Updating shipping warehouse
|
||||
shipping_warehouse_service = ShippingWarehouseService(self.session)
|
||||
shipping_warehouse = await shipping_warehouse_service.get_by_name(request.data.shipping_warehouse)
|
||||
if not shipping_warehouse and request.data.shipping_warehouse:
|
||||
shipping_warehouse = await shipping_warehouse_service.create_by_name(request.data.shipping_warehouse)
|
||||
|
||||
card.shipping_warehouse = shipping_warehouse
|
||||
|
||||
# Updating manager
|
||||
if request.data.manager:
|
||||
card.manager_id = request.data.manager.id
|
||||
@@ -391,6 +383,47 @@ class CardsService(BaseService):
|
||||
await self.session.rollback()
|
||||
return CardUpdateGeneralInfoResponse(ok=False, message=str(e))
|
||||
|
||||
async def update_products_and_services_general_info(self, request: ProductsAndServicesGeneralInfoRequest) -> (
|
||||
ProductsAndServicesGeneralInfoResponse
|
||||
):
|
||||
card: Optional[Card] = await self.session.get(Card, request.card_id)
|
||||
if not card:
|
||||
raise HTTPException(status_code=404, detail='Карточка не найдена')
|
||||
|
||||
# Updating shipping warehouse
|
||||
shipping_warehouse_service = ShippingWarehouseService(self.session)
|
||||
shipping_warehouse = await shipping_warehouse_service.get_by_name(request.data.shipping_warehouse)
|
||||
if not shipping_warehouse and request.data.shipping_warehouse:
|
||||
shipping_warehouse = await shipping_warehouse_service.create_by_name(request.data.shipping_warehouse)
|
||||
|
||||
if card.group:
|
||||
for card in card.group.cards:
|
||||
card.is_services_profit_accounted = request.data.is_services_profit_accounted
|
||||
else:
|
||||
card.is_services_profit_accounted = request.data.is_services_profit_accounted
|
||||
|
||||
card.shipping_warehouse = shipping_warehouse
|
||||
await self.session.commit()
|
||||
return ProductsAndServicesGeneralInfoResponse(ok=True, message='Данные карточки успешно обновлены')
|
||||
|
||||
async def update_card_manager(self, request: UpdateCardManagerRequest) -> UpdateCardManagerResponse:
|
||||
card: Optional[Card] = await self.session.get(Card, request.card_id)
|
||||
if not card:
|
||||
raise HTTPException(status_code=404, detail='Карточка не найдена')
|
||||
|
||||
card.manager_id = request.manager_id
|
||||
await self.session.commit()
|
||||
return UpdateCardManagerResponse(ok=True, message='Данные карточки успешно обновлены')
|
||||
|
||||
async def update_card_client(self, request: UpdateCardClientRequest) -> UpdateCardClientResponse:
|
||||
card: Optional[Card] = await self.session.get(Card, request.card_id)
|
||||
if not card:
|
||||
raise HTTPException(status_code=404, detail='Карточка не найдена')
|
||||
|
||||
card.client_id = request.client_id
|
||||
await self.session.commit()
|
||||
return UpdateCardClientResponse(ok=True, message='Данные карточки успешно обновлены')
|
||||
|
||||
async def reorder(self, request: CardSummaryReorderRequest, user: User) -> CardSummaryResponse:
|
||||
card: Card = await self.session.scalar(select(Card).where(Card.id == request.card_id))
|
||||
if request.index == 1:
|
||||
|
||||
Reference in New Issue
Block a user