feature/permisos-pedimentos
This commit is contained in:
@@ -23,4 +23,8 @@ router = TenantCRUDRoutes(
|
||||
parent_id_name="pedimento_id",
|
||||
enable_list=False,
|
||||
validate_parent_match=True,
|
||||
get_permissions=["pedimentos_mgmt.view"],
|
||||
create_permissions=["pedimentos_mgmt.edit"],
|
||||
update_permissions=["pedimentos_mgmt.edit"],
|
||||
delete_permissions=["pedimentos_mgmt.edit"],
|
||||
).router
|
||||
|
||||
@@ -23,4 +23,8 @@ router = TenantCRUDRoutes(
|
||||
parent_id_name="pedimento_id",
|
||||
enable_list=False,
|
||||
validate_parent_match=True,
|
||||
get_permissions=["pedimentos_mgmt.view"],
|
||||
create_permissions=["pedimentos_mgmt.edit"],
|
||||
update_permissions=["pedimentos_mgmt.edit"],
|
||||
delete_permissions=["pedimentos_mgmt.edit"],
|
||||
).router
|
||||
|
||||
@@ -23,4 +23,8 @@ router = TenantCRUDRoutes(
|
||||
parent_id_name="pedimento_id",
|
||||
enable_list=False,
|
||||
validate_parent_match=True,
|
||||
get_permissions=["pedimentos_mgmt.view"],
|
||||
create_permissions=["pedimentos_mgmt.edit"],
|
||||
update_permissions=["pedimentos_mgmt.edit"],
|
||||
delete_permissions=["pedimentos_mgmt.edit"],
|
||||
).router
|
||||
|
||||
@@ -23,4 +23,8 @@ router = TenantCRUDRoutes(
|
||||
parent_id_name="pedimento_id",
|
||||
enable_list=False,
|
||||
validate_parent_match=True,
|
||||
get_permissions=["pedimentos_mgmt.view"],
|
||||
create_permissions=["pedimentos_mgmt.edit"],
|
||||
update_permissions=["pedimentos_mgmt.edit"],
|
||||
delete_permissions=["pedimentos_mgmt.edit"],
|
||||
).router
|
||||
|
||||
@@ -25,4 +25,8 @@ router = TenantCRUDRoutes(
|
||||
parent_id_name="pedimento_id",
|
||||
enable_list=False,
|
||||
validate_parent_match=True,
|
||||
get_permissions=["pedimentos_mgmt.view"],
|
||||
create_permissions=["pedimentos_mgmt.edit"],
|
||||
update_permissions=["pedimentos_mgmt.edit"],
|
||||
delete_permissions=["pedimentos_mgmt.edit"],
|
||||
).router
|
||||
|
||||
@@ -23,4 +23,8 @@ router = TenantCRUDRoutes(
|
||||
parent_id_name="pedimento_id",
|
||||
enable_list=False,
|
||||
validate_parent_match=True,
|
||||
get_permissions=["pedimentos_mgmt.view"],
|
||||
create_permissions=["pedimentos_mgmt.edit"],
|
||||
update_permissions=["pedimentos_mgmt.edit"],
|
||||
delete_permissions=["pedimentos_mgmt.edit"],
|
||||
).router
|
||||
|
||||
@@ -27,7 +27,9 @@ async def list_customs_offices(
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Get all customs offices for a pedimento"""
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
tenant_id = validate_access_to_resource(
|
||||
db, company_id, current_user, ["pedimentos_mgmt.view"]
|
||||
)
|
||||
|
||||
offices = PedimentoCustomsOfficesService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id, company_id
|
||||
@@ -44,7 +46,9 @@ async def get_customs_office(
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Get a specific customs office by ID"""
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
tenant_id = validate_access_to_resource(
|
||||
db, company_id, current_user, ["pedimentos_mgmt.view"]
|
||||
)
|
||||
|
||||
office = PedimentoCustomsOfficesService.get_by_id(
|
||||
db, office_id, pedimento_id, tenant_id, company_id
|
||||
@@ -64,7 +68,9 @@ async def create_customs_office(
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Create a new customs office"""
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
tenant_id = validate_access_to_resource(
|
||||
db, company_id, current_user, ["pedimentos_mgmt.edit"]
|
||||
)
|
||||
|
||||
# Ensure pedimento_id matches
|
||||
if data.pedimento_id != pedimento_id:
|
||||
@@ -84,7 +90,9 @@ async def update_customs_office(
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Update a customs office"""
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
tenant_id = validate_access_to_resource(
|
||||
db, company_id, current_user, ["pedimentos_mgmt.edit"]
|
||||
)
|
||||
|
||||
office = PedimentoCustomsOfficesService.update(
|
||||
db, office_id, pedimento_id, tenant_id, company_id, data
|
||||
@@ -104,7 +112,9 @@ async def delete_customs_office(
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Delete a customs office"""
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
tenant_id = validate_access_to_resource(
|
||||
db, company_id, current_user, ["pedimentos_mgmt.edit"]
|
||||
)
|
||||
|
||||
success = PedimentoCustomsOfficesService.delete(
|
||||
db, office_id, pedimento_id, tenant_id, company_id
|
||||
|
||||
@@ -23,4 +23,8 @@ router = TenantCRUDRoutes(
|
||||
parent_id_name="pedimento_id",
|
||||
enable_list=False,
|
||||
validate_parent_match=True,
|
||||
get_permissions=["pedimentos_mgmt.view"],
|
||||
create_permissions=["pedimentos_mgmt.edit"],
|
||||
update_permissions=["pedimentos_mgmt.edit"],
|
||||
delete_permissions=["pedimentos_mgmt.edit"],
|
||||
).router
|
||||
|
||||
@@ -27,7 +27,9 @@ async def list_decrementables(
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Get all decrementables for a pedimento"""
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
tenant_id = validate_access_to_resource(
|
||||
db, company_id, current_user, ["pedimentos_mgmt.view"]
|
||||
)
|
||||
|
||||
decrementables = PedimentoDecrementablesService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id, company_id
|
||||
@@ -44,7 +46,9 @@ async def get_decrementable(
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Get a specific decrementable by ID"""
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
tenant_id = validate_access_to_resource(
|
||||
db, company_id, current_user, ["pedimentos_mgmt.view"]
|
||||
)
|
||||
|
||||
decrementable = PedimentoDecrementablesService.get_by_id(
|
||||
db, decrementable_id, pedimento_id, tenant_id, company_id
|
||||
@@ -64,7 +68,9 @@ async def create_decrementable(
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Create a new decrementable"""
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
tenant_id = validate_access_to_resource(
|
||||
db, company_id, current_user, ["pedimentos_mgmt.edit"]
|
||||
)
|
||||
|
||||
# Ensure pedimento_id matches
|
||||
if data.pedimento_id != pedimento_id:
|
||||
@@ -86,7 +92,9 @@ async def update_decrementable(
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Update a decrementable"""
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
tenant_id = validate_access_to_resource(
|
||||
db, company_id, current_user, ["pedimentos_mgmt.edit"]
|
||||
)
|
||||
|
||||
decrementable = PedimentoDecrementablesService.update(
|
||||
db, decrementable_id, pedimento_id, tenant_id, company_id, data
|
||||
@@ -106,7 +114,9 @@ async def delete_decrementable(
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Delete a decrementable"""
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
tenant_id = validate_access_to_resource(
|
||||
db, company_id, current_user, ["pedimentos_mgmt.edit"]
|
||||
)
|
||||
|
||||
success = PedimentoDecrementablesService.delete(
|
||||
db, decrementable_id, pedimento_id, tenant_id, company_id
|
||||
|
||||
@@ -27,7 +27,9 @@ async def list_incrementables(
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Get all incrementables for a pedimento"""
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
tenant_id = validate_access_to_resource(
|
||||
db, company_id, current_user, ["pedimentos_mgmt.view"]
|
||||
)
|
||||
|
||||
incrementables = PedimentoIncrementablesService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id, company_id
|
||||
@@ -44,7 +46,9 @@ async def get_incrementable(
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Get a specific incrementable by ID"""
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
tenant_id = validate_access_to_resource(
|
||||
db, company_id, current_user, ["pedimentos_mgmt.view"]
|
||||
)
|
||||
|
||||
incrementable = PedimentoIncrementablesService.get_by_id(
|
||||
db, incrementable_id, pedimento_id, tenant_id, company_id
|
||||
@@ -64,7 +68,9 @@ async def create_incrementable(
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Create a new incrementable"""
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
tenant_id = validate_access_to_resource(
|
||||
db, company_id, current_user, ["pedimentos_mgmt.edit"]
|
||||
)
|
||||
|
||||
# Ensure pedimento_id matches
|
||||
if data.pedimento_id != pedimento_id:
|
||||
@@ -86,7 +92,9 @@ async def update_incrementable(
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Update an incrementable"""
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
tenant_id = validate_access_to_resource(
|
||||
db, company_id, current_user, ["pedimentos_mgmt.edit"]
|
||||
)
|
||||
|
||||
incrementable = PedimentoIncrementablesService.update(
|
||||
db, incrementable_id, pedimento_id, tenant_id, company_id, data
|
||||
@@ -106,7 +114,9 @@ async def delete_incrementable(
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Delete an incrementable"""
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
tenant_id = validate_access_to_resource(
|
||||
db, company_id, current_user, ["pedimentos_mgmt.edit"]
|
||||
)
|
||||
|
||||
success = PedimentoIncrementablesService.delete(
|
||||
db, incrementable_id, pedimento_id, tenant_id, company_id
|
||||
|
||||
@@ -23,4 +23,8 @@ router = TenantCRUDRoutes(
|
||||
parent_id_name="pedimento_id",
|
||||
enable_list=False,
|
||||
validate_parent_match=True,
|
||||
get_permissions=["pedimentos_mgmt.view"],
|
||||
create_permissions=["pedimentos_mgmt.edit"],
|
||||
update_permissions=["pedimentos_mgmt.edit"],
|
||||
delete_permissions=["pedimentos_mgmt.edit"],
|
||||
).router
|
||||
|
||||
@@ -27,7 +27,9 @@ async def list_payments(
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Get all payments for a pedimento"""
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
tenant_id = validate_access_to_resource(
|
||||
db, company_id, current_user, ["pedimentos_mgmt.view"]
|
||||
)
|
||||
|
||||
payments = PedimentoPaymentsService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id, company_id
|
||||
@@ -44,7 +46,9 @@ async def get_payment(
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Get a specific payment by ID"""
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
tenant_id = validate_access_to_resource(
|
||||
db, company_id, current_user, ["pedimentos_mgmt.view"]
|
||||
)
|
||||
|
||||
payment = PedimentoPaymentsService.get_by_id(
|
||||
db, id, pedimento_id, tenant_id, company_id
|
||||
@@ -64,7 +68,9 @@ async def create_payment(
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Create a new payment"""
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
tenant_id = validate_access_to_resource(
|
||||
db, company_id, current_user, ["pedimentos_mgmt.edit"]
|
||||
)
|
||||
|
||||
# Ensure pedimento_id matches
|
||||
if data.pedimento_id != pedimento_id:
|
||||
@@ -84,7 +90,9 @@ async def update_payment(
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Update a payment"""
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
tenant_id = validate_access_to_resource(
|
||||
db, company_id, current_user, ["pedimentos_mgmt.edit"]
|
||||
)
|
||||
|
||||
payment = PedimentoPaymentsService.update(
|
||||
db, id, pedimento_id, tenant_id, company_id, data
|
||||
@@ -104,7 +112,9 @@ async def delete_payment(
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Delete a payment"""
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
tenant_id = validate_access_to_resource(
|
||||
db, company_id, current_user, ["pedimentos_mgmt.edit"]
|
||||
)
|
||||
|
||||
success = PedimentoPaymentsService.delete(
|
||||
db, id, pedimento_id, tenant_id, company_id
|
||||
|
||||
@@ -25,4 +25,8 @@ router = TenantCRUDRoutes(
|
||||
parent_id_name="pedimento_id",
|
||||
enable_list=False,
|
||||
validate_parent_match=True,
|
||||
get_permissions=["pedimentos_mgmt.view"],
|
||||
create_permissions=["pedimentos_mgmt.edit"],
|
||||
update_permissions=["pedimentos_mgmt.edit"],
|
||||
delete_permissions=["pedimentos_mgmt.edit"],
|
||||
).router
|
||||
|
||||
@@ -25,4 +25,8 @@ router = TenantCRUDRoutes(
|
||||
parent_id_name="pedimento_id",
|
||||
enable_list=False,
|
||||
validate_parent_match=True,
|
||||
get_permissions=["pedimentos_mgmt.view"],
|
||||
create_permissions=["pedimentos_mgmt.edit"],
|
||||
update_permissions=["pedimentos_mgmt.edit"],
|
||||
delete_permissions=["pedimentos_mgmt.edit"],
|
||||
).router
|
||||
|
||||
@@ -27,7 +27,9 @@ async def list_transport_means(
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Get all transport means for a pedimento"""
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
tenant_id = validate_access_to_resource(
|
||||
db, company_id, current_user, ["pedimentos_mgmt.view"]
|
||||
)
|
||||
|
||||
transport_means = PedimentoTransportMeansService.get_by_pedimento_id(
|
||||
db, pedimento_id, tenant_id, company_id
|
||||
@@ -44,7 +46,9 @@ async def get_transport_mean(
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Get a specific transport mean by ID"""
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
tenant_id = validate_access_to_resource(
|
||||
db, company_id, current_user, ["pedimentos_mgmt.view"]
|
||||
)
|
||||
|
||||
transport_mean = PedimentoTransportMeansService.get_by_id(
|
||||
db, transport_mean_id, pedimento_id, tenant_id, company_id
|
||||
@@ -64,7 +68,9 @@ async def create_transport_mean(
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Create a new transport mean"""
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
tenant_id = validate_access_to_resource(
|
||||
db, company_id, current_user, ["pedimentos_mgmt.edit"]
|
||||
)
|
||||
|
||||
# Ensure pedimento_id matches
|
||||
if data.pedimento_id != pedimento_id:
|
||||
@@ -86,7 +92,9 @@ async def update_transport_mean(
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Update a transport mean"""
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
tenant_id = validate_access_to_resource(
|
||||
db, company_id, current_user, ["pedimentos_mgmt.edit"]
|
||||
)
|
||||
|
||||
transport_mean = PedimentoTransportMeansService.update(
|
||||
db, transport_mean_id, pedimento_id, tenant_id, company_id, data
|
||||
@@ -106,7 +114,9 @@ async def delete_transport_mean(
|
||||
current_user: Dict[str, Any] = Depends(get_current_user),
|
||||
):
|
||||
"""Delete a transport mean"""
|
||||
tenant_id = validate_access_to_resource(db, company_id, current_user)
|
||||
tenant_id = validate_access_to_resource(
|
||||
db, company_id, current_user, ["pedimentos_mgmt.edit"]
|
||||
)
|
||||
|
||||
success = PedimentoTransportMeansService.delete(
|
||||
db, transport_mean_id, pedimento_id, tenant_id, company_id
|
||||
|
||||
@@ -23,4 +23,8 @@ router = TenantCRUDRoutes(
|
||||
parent_id_name="pedimento_id",
|
||||
enable_list=False, # Child resource - no list endpoint
|
||||
validate_parent_match=True, # Validate pedimento_id matches in create
|
||||
get_permissions=["pedimentos_mgmt.view"],
|
||||
create_permissions=["pedimentos_mgmt.edit"],
|
||||
update_permissions=["pedimentos_mgmt.edit"],
|
||||
delete_permissions=["pedimentos_mgmt.edit"],
|
||||
).router
|
||||
|
||||
@@ -30,7 +30,8 @@ async def get_creation_data(
|
||||
Consolidates multiple catalog calls into a single endpoint.
|
||||
"""
|
||||
from core.security import validate_access_to_resource
|
||||
validate_access_to_resource(db, company_id, current_user, ["pedimentos_mgmt.view"])
|
||||
# Alta de pedimento: misma capacidad que editar en negocio / UI (pedimento-permissions).
|
||||
validate_access_to_resource(db, company_id, current_user, ["pedimentos_mgmt.edit"])
|
||||
|
||||
tenant_id = current_user["tenant_id"]
|
||||
|
||||
@@ -55,7 +56,7 @@ async def get_edition_data(
|
||||
Consolidates multiple catalog calls + pedimento fetch into a single endpoint.
|
||||
"""
|
||||
from core.security import validate_access_to_resource
|
||||
validate_access_to_resource(db, company_id, current_user, ["pedimentos_mgmt.view"])
|
||||
validate_access_to_resource(db, company_id, current_user, ["pedimentos_mgmt.edit"])
|
||||
|
||||
tenant_id = current_user["tenant_id"]
|
||||
|
||||
@@ -92,7 +93,7 @@ crud_router = TenantCRUDRoutes(
|
||||
max_page_size=1000,
|
||||
list_permissions=["pedimentos_mgmt.view"],
|
||||
get_permissions=["pedimentos_mgmt.view"],
|
||||
create_permissions=["pedimentos_mgmt.create"],
|
||||
create_permissions=["pedimentos_mgmt.edit"],
|
||||
update_permissions=["pedimentos_mgmt.edit"],
|
||||
delete_permissions=["pedimentos_mgmt.delete"],
|
||||
).router
|
||||
|
||||
Reference in New Issue
Block a user