Once a restaurant marks an order asDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/lffiesco-svg/gastromovil/llms.txt
Use this file to discover all available pages before exploring further.
enviado, GastroMóvil’s delivery system takes over. An available driver receives an instant WebSocket notification, accepts the pickup, and then begins sharing their GPS location in real time. Customers watch the driver’s position update live on a Google Maps embed at the tracking page — all without polling.
Data Models
Repartidor
Extends the core Usuario model with delivery-specific fields through a OneToOneField:
UbicacionRepartidor
A single-row record per driver that stores the most recent GPS coordinates. Every time the driver’s browser sends a location update the row is overwritten via update_or_create:
auto_now=True on actualizado means the timestamp is refreshed on every save, giving a reliable “last seen” marker for each driver.Driver Panel
The driver dashboard at/panel-repartidor/ is divided into three sections:
Pending Deliveries
Orders with
estado='enviado' that are waiting for a driver to accept.In Transit
Orders with
estado='en_camino' assigned to the logged-in driver.Completed Today
Orders with
estado='entregado' for the current date assigned to this driver.How Location Sharing Works
The live tracking system uses two separate WebSocket consumers that share the same channel group.Driver Connects
The driver’s browser opens a WebSocket connection to:
UbicacionConsumer.connect() adds the connection to the group ubicacion_{repartidor_id}.Driver Sends Coordinates
As the driver moves, the browser sends JSON messages at regular intervals:The consumer’s
receive() method calls guardar_ubicacion() (an async database write using database_sync_to_async) and then broadcasts the update to the group.Customer Receives Updates
The customer connects to the same WebSocket group from the tracking page. Whenever the driver’s browser sends a new location, The tracking page at
ubicacion_actualizada fires on all group members:/repartidores/seguimiento/<repartidor_id>/ uses the Google Maps JavaScript API to move a marker on the map each time a location message arrives.UbicacionConsumer — Full Flow
RepartidorConsumer — Order Assignment Channel
Each driver also maintains a second, private WebSocket connection for receiving order assignment events:
A driver joins the
repartidores_disponibles group automatically at connection time if their Repartidor.estado is 'disponible'. This group is also used by the post_save signal on Pedido when the restaurant accepts an order.Automatic Order Assignment
When the restaurant accepts an order (setsestado to 'aceptado'), a post_save signal on Pedido broadcasts a pedido_disponible event to the shared repartidores_disponibles channel group. Every driver whose RepartidorConsumer joined that group at connection time receives the notification:
Driver Action Endpoints
| Method | Endpoint | Description |
|---|---|---|
POST | /pedidos/<pk>/aceptar-entrega/ | Accept a delivery — sets order estado to en_camino and assigns repartidor to the logged-in user |
POST | /pedidos/<pk>/marcar-entregado/ | Mark the order delivered — sets estado to entregado |
Customer Tracking Page
GET /repartidores/seguimiento/<repartidor_id>/ renders the tracking view. The page template receives the repartidor_id as context and uses it to open the ubicacion_{repartidor_id} WebSocket channel. Incoming latitude/longitude messages are fed into the Google Maps JavaScript API to animate a marker representing the driver’s current position.