Vistas API
The Vistas (Views) endpoint manages view-level entries in the hierarchical permission system. Vistas belong to Menus and contain multiple Opciones (action options).
Hierarchy
Menu (Top Level)
└── Vista (Views within menu) ← Current Level
└── Opciones (Actions within view)
Model Structure
The Vista model represents the middle level of the permission hierarchy, connecting Menus to specific actions (Opciones).
Fields
Auto-incremented primary key identifying the vista
Foreign key reference to the parent Menu
Name of the vista (max 40 characters)
Description of the vista’s purpose (max 40 characters)
Endpoints
List All Vistas
Retrieve all vistas in the system.
Query Parameters
Filter by status (0: Inactive, 1: Active)
Response
Unique identifier for the vista
Example Response
{
"results": [
{
"id_vista": 1,
"id_menu": 1,
"nombre_vista": "Panel Principal",
"descripcion": "Main dashboard view",
"estado": 1
},
{
"id_vista": 2,
"id_menu": 2,
"nombre_vista": "Gestión de Campañas",
"descripcion": "Campaign management view",
"estado": 1
},
{
"id_vista": 3,
"id_menu": 2,
"nombre_vista": "Estadísticas de Campañas",
"descripcion": "Campaign statistics view",
"estado": 1
}
]
}
Get Vista by ID
GET /api/vistas/{id_vista}/
Retrieve details of a specific vista.
Path Parameters
The unique identifier of the vista
Response
Unique identifier for the vista
Example Response
{
"id_vista": 1,
"id_menu": 1,
"nombre_vista": "Panel Principal",
"descripcion": "Main dashboard view",
"estado": 1
}
GET /api/vistas/?id_menu={id_menu}
Retrieve all vistas belonging to a specific menu.
Example Response
{
"results": [
{
"id_vista": 2,
"id_menu": 2,
"nombre_vista": "Gestión de Campañas",
"descripcion": "Campaign management view",
"estado": 1
},
{
"id_vista": 3,
"id_menu": 2,
"nombre_vista": "Estadísticas de Campañas",
"descripcion": "Campaign statistics view",
"estado": 1
}
]
}
Create Vista
Create a new vista within a menu.
Request Body
The ID of the parent menu
Name of the vista (max 40 characters)
Description of the vista (max 40 characters)
Status of the vista (0: Inactive, 1: Active)
Example Request
{
"id_menu": 2,
"nombre_vista": "Crear Campaña",
"descripcion": "Create new campaign view",
"estado": 1
}
Response
The ID of the newly created vista
Update Vista
PUT /api/vistas/{id_vista}/
PATCH /api/vistas/{id_vista}/
Update an existing vista. Use PUT for full updates or PATCH for partial updates.
Path Parameters
The unique identifier of the vista to update
Request Body
Delete Vista
DELETE /api/vistas/{id_vista}/
Delete a vista from the system. Note: This will cascade delete all associated Opciones.
Path Parameters
The unique identifier of the vista to delete
Hierarchy Example
Here’s how Vistas fit into the permission hierarchy:
{
"menu": {
"id_menu": 2,
"nombre_menu": "Campañas",
"vistas": [
{
"id_vista": 2,
"nombre_vista": "Gestión de Campañas",
"opciones": [
{"id_opcion": 1, "nombre_vista": "Crear"},
{"id_opcion": 2, "nombre_vista": "Editar"},
{"id_opcion": 3, "nombre_vista": "Eliminar"}
]
},
{
"id_vista": 3,
"nombre_vista": "Estadísticas de Campañas",
"opciones": [
{"id_opcion": 4, "nombre_vista": "Ver Reportes"},
{"id_opcion": 5, "nombre_vista": "Exportar Datos"}
]
}
]
}
}
- Menus - Parent menus containing vistas
- Opciones - Actions within vistas
- PermisosXRol - Role-based permissions linking to vistas
Usage Notes
- Vistas must belong to a valid Menu (id_menu foreign key)
- Each vista can contain multiple Opciones (action options)
- Deleting a vista will cascade delete all associated Opciones
- Set estado to 0 to disable rather than deleting
- Use PermisosXRol to control which roles can access specific vistas