Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/JuanDiego3030/Planta_Milenio/llms.txt

Use this file to discover all available pages before exploring further.

Before anyone can log in to Planta Milenio, at least one User_admin record must exist in the database. Because the web panel itself requires a logged-in user to operate, the first account must always be created from the command line using CreateUser.py. Subsequent accounts can be created either via the CLI or through the web panel at /usuarios/.

Via CLI (CreateUser.py)

CreateUser.py is an interactive script located at the project root. It configures Django’s settings module, calls django.setup(), and then provides a three-option menu for managing users without a running server.
CreateUser.py must be run from the project root directory with the virtual environment activated and after python manage.py migrate has been executed. Running it before migrations will fail because the app2_user_admin table does not yet exist.
# Correct way to invoke it
cd /path/to/Planta_Milenio
source venv/bin/activate   # or venv\Scripts\activate on Windows
python CreateUser.py

Running the script

python CreateUser.py
The script opens a persistent menu loop. Select an option by typing its number and pressing Enter.
=== Menú de administración de usuarios ===
1. Registrar nuevo usuario
2. Cambiar contraseña de usuario
3. Salir
Seleccione una opción:
Selecting option 1 walks through the full registration flow:
=== Menú de administración de usuarios ===
1. Registrar nuevo usuario
2. Cambiar contraseña de usuario
3. Salir
Seleccione una opción: 1

=== Registro de nuevo usuario ===
Nombre de usuario: operador1
Contraseña: ••••••••
Email (opcional): [email protected]
Teléfono (opcional): 
¿El usuario solo podrá consultar y descargar historial? (s/n): n
[OK] Usuario 'operador1' registrado correctamente. Permiso solo consulta: False
The script validates the inputs before saving:The script validates the inputs: empty nombre or password prints [ERROR] Nombre y contraseña son obligatorios. and returns to the menu. A duplicate nombre or email prints the corresponding [ERROR] message and aborts. The solo_consulta prompt only accepts s or n; any other input loops with an error message.

Password hashing

All passwords are hashed using Django’s make_password function before being stored:
from django.contrib.auth.hashers import make_password

hashed_password = make_password(password)
user = User_admin(nombre=nombre, password=hashed_password, ...)
user.save()
The default hasher is PBKDF2 with SHA-256 and 720,000 iterations (Django 5 default). The login view verifies passwords using check_password(plain, hashed), which supports this format transparently.
Permission flags (permiso_control, permiso_control_personas, etc.) default to False for users created via CreateUser.py. After registering the first user, log in through the web panel and use the Gestión de Usuarios interface to assign the specific module permissions that account needs.

Via Web Panel (/usuarios/)

Once at least one user with permiso_usuarios = True exists, all subsequent user management can be done through the browser-based panel at /usuarios/.
1

Navigate to /usuarios/

Log in and click the Usuarios section in the navigation menu. Access requires permiso_usuarios = True on the authenticated account. Without it, the view redirects to the login page with an access-denied message.
2

Create a new user

Click the Crear usuario button to open the creation form. Fill in the required fields (nombre, password) and any optional fields (email, telefono). Toggle the desired permission flags and the solo_consulta / bloqueado checkboxes, then submit the form.
3

Edit an existing user

Each row in the user list includes an Edit action. The edit form pre-populates all current values. Leave the password field empty to keep the existing password unchanged — only populate it to set a new one.
4

Delete a user

Each row also includes a Delete action. Deletion is immediate and permanent; there is no soft-delete or confirmation dialog beyond the browser’s native form submission.
The panel lists users alphabetically (ordered by nombre) and paginates at 10 records per page.

Validation rules (web panel)

The control_usuarios view enforces the following before calling ControlUsuarios.crear_usuario():
RuleBehaviour on failure
nombre is requiredError: “Nombre y contraseña son obligatorios.”
password is required on createError: “Nombre y contraseña son obligatorios.”
nombre must be uniqueDatabase raises IntegrityError; displayed as “Error al crear usuario: …”
email must be unique if providedDatabase raises IntegrityError; displayed as “Error al crear usuario: …”

Read-only users and the web panel

A solo_consulta user who also has permiso_usuarios = True can open /usuarios/ and browse the user list. However, any attempt to submit the Create, Edit, or Delete forms is blocked at the view level before touching the database:
No tiene permisos para crear, editar o eliminar usuarios. Solo puede consultar.
The view redirects them back to /usuarios/ with this error message after every blocked POST.

Build docs developers (and LLMs) love