mirror of
https://github.com/flibusta-apps/services_manager_server.git
synced 2025-12-06 12:35:39 +01:00
Add service count limit
This commit is contained in:
@@ -45,6 +45,11 @@ async def delete_service(id: int):
|
||||
|
||||
@router.post("/", response_model=ServiceDetail)
|
||||
async def register_service(data: ServiceCreate):
|
||||
user_services_count = await Service.objects.filter(user=data.user).count()
|
||||
|
||||
if user_services_count >= 3:
|
||||
raise HTTPException(status.HTTP_402_PAYMENT_REQUIRED)
|
||||
|
||||
return await Service.objects.create(**data.dict())
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user