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.

Planta Milenio generates PDF reports on demand using WeasyPrint. Each report endpoint queries the database, renders a Django HTML template, converts it to PDF in-process, and streams the result back to the client as a direct file download. All three endpoints respond with Content-Type: application/pdf and a Content-Disposition: attachment header so that browsers prompt the user to save the file rather than attempting to display it inline.
All PDF endpoints that accept date filters are capped at 200 records per request. If your date range contains more than 200 entries, only the first 200 records (ordered by timestamp descending) will appear in the PDF. Use a narrower date range to export larger datasets in multiple files.
Users with solo_consulta enabled on their profile are permitted to download PDF reports. The solo_consulta flag only blocks POST-based write operations (registering or modifying entries). It does not restrict access to report endpoints.

Authentication Requirements

The three endpoints have different authentication requirements:
EndpointSession requiredPermission required
GET /reporte_pdf/materia_prima/Yespermiso_reportes
GET /reporte_pdf/personal/NoNone
GET /reporte_historial/NoNone
reporte_pdf_personal and reporte_historial do not perform any session or permission check in their view implementations — they are accessible to any request that reaches the Django application.

Shared Query Parameters

All three report endpoints accept the same optional date-range filter:
fecha_inicio
string
Start date of the report range in YYYY-MM-DD format, e.g. 2024-01-01. Filtering is inclusive — records on this date are included.
fecha_fin
string
End date of the report range in YYYY-MM-DD format, e.g. 2024-01-31. Filtering is inclusive — records on this date are included (the system applies a < fecha_fin + 1 day bound internally).
Date filters are inclusive on both ends. Internally the endpoint adds one day to fecha_fin and uses a strict less-than comparison, so setting fecha_fin=2024-01-31 captures all entries timestamped on January 31 up to 23:59:59. You do not need to adjust your end date to account for this.

GET /reporte_pdf/materia_prima/

Generates a PDF report of raw-material intake entries recorded in the Historial model. This endpoint is restricted to users who hold the permiso_reportes permission on their profile. If the requesting user does not have an active session or lacks permiso_reportes, they are redirected to the /control/ view. Auth: Active session + permiso_reportes permission required. Behavior: Returns up to 200 records from the Historial model, ordered by fecha_hora descending. When fecha_inicio and fecha_fin are supplied, only records whose fecha_hora falls within the range are included. Response headers:
HeaderValue
Content-Typeapplication/pdf
Content-Dispositionattachment; filename="reporte_materia_prima.pdf"
fecha_inicio
string
Start date in YYYY-MM-DD format. Optional.
fecha_fin
string
End date in YYYY-MM-DD format. Optional.
curl -b cookies.txt \
  'http://localhost:8000/reporte_pdf/materia_prima/?fecha_inicio=2024-01-01&fecha_fin=2024-01-31' \
  -o reporte_materia_prima.pdf

GET /reporte_pdf/personal/

Generates a PDF report of personnel and visitor access records from the AccesoPersona model. This endpoint does not check for an active session or any permission — it is accessible without authentication. Auth: None required. Behavior: Returns up to 200 records from AccesoPersona, ordered by hora_entrada descending. When fecha_inicio and fecha_fin are supplied, only records whose hora_entrada falls within the range are included. Response headers:
HeaderValue
Content-Typeapplication/pdf
Content-Dispositionattachment; filename="reporte_personal.pdf"
fecha_inicio
string
Start date in YYYY-MM-DD format. Optional.
fecha_fin
string
End date in YYYY-MM-DD format. Optional.
curl 'http://localhost:8000/reporte_pdf/personal/?fecha_inicio=2024-01-01&fecha_fin=2024-01-31' \
  -o reporte_personal.pdf

GET /reporte_historial/

Generates a PDF of the full raw-material intake history from the Historial model. When no date range is provided, this endpoint returns the last 100 records rather than an empty report, making it useful for a quick operational snapshot without needing to specify dates. This endpoint does not check for an active session or any permission — it is accessible without authentication. Auth: None required. Behavior: When fecha_inicio and fecha_fin are both provided, returns up to 200 records filtered by that range, ordered by fecha_hora descending. When either parameter is absent, returns the 100 most recent records (no date filtering applied). Response headers:
HeaderValue
Content-Typeapplication/pdf
Content-Dispositionattachment; filename="reporte_historial.pdf"
fecha_inicio
string
Start date in YYYY-MM-DD format. Optional — if either date parameter is absent, the last 100 records are returned instead of applying a date filter.
fecha_fin
string
End date in YYYY-MM-DD format. Optional — if either date parameter is absent, the last 100 records are returned instead of applying a date filter.
# Filtered by date range
curl 'http://localhost:8000/reporte_historial/?fecha_inicio=2024-01-01&fecha_fin=2024-01-31' \
  -o reporte_historial.pdf

# No filters — returns the last 100 records
curl 'http://localhost:8000/reporte_historial/' \
  -o reporte_historial.pdf

Complete Download Example

The following sequence shows a full authenticated PDF download flow for the raw-material report (which requires permiso_reportes) alongside the unauthenticated downloads:
# 1. Load the login page to receive the csrftoken cookie
curl -c cookies.txt http://localhost:8000/login/

# 2. Authenticate (replace <token> with the value from the csrftoken cookie)
curl -c cookies.txt -b cookies.txt -X POST http://localhost:8000/login/ \
  -d 'nombre=operador1&password=mypassword&csrfmiddlewaretoken=<token>'

# 3. Download the raw-material report for January 2024 (requires permiso_reportes)
curl -b cookies.txt \
  'http://localhost:8000/reporte_pdf/materia_prima/?fecha_inicio=2024-01-01&fecha_fin=2024-01-31' \
  -o reporte_materia_prima.pdf

# 4. Download the personnel access report (no session required)
curl 'http://localhost:8000/reporte_pdf/personal/?fecha_inicio=2024-01-01&fecha_fin=2024-01-31' \
  -o reporte_personal.pdf

# 5. Download a quick operational snapshot (last 100 history records, no session required)
curl 'http://localhost:8000/reporte_historial/' \
  -o reporte_historial.pdf

Build docs developers (and LLMs) love