Tasks - Work Management & Scheduling
Domain: Tasks
Location: api/nextango/apps/tasks/
Last Updated: 2025-12-21
Overview
The Tasks app provides comprehensive work management capabilities including task creation, assignment workflows, priority tracking, deadline management, delivery scheduling, and completion tracking. Supports store operations, employee workflows, and delivery logistics with Sanity CMS synchronization.
Documentation Quick Links
Core Documentation
| File | Description |
|---|---|
| models.md | Task, DeliverySchedule, TaskAssignment models |
| serializers.md | Task API serializers and validation |
| views.md | Task management API endpoints |
| services.md | TaskService, scheduling, assignment logic |
| signals.md | Task lifecycle signals and notifications |
| examples.md | Usage examples and patterns |
Key Features
Task Management
- Task creation - Create tasks with title, description, priority
- Task assignment - Assign tasks to employees
- Priority levels - Low, medium, high, urgent priority
- Due dates - Deadline tracking and overdue detection
- Status tracking - Pending, in_progress, completed, cancelled
- Task dependencies - Tasks can depend on other tasks
Assignment Workflows
- Employee assignment - Assign to specific employees
- Role-based assignment - Assign to managers, staff, etc.
- Store-specific tasks - Tasks scoped to specific stores
- Reassignment - Transfer tasks between employees
- Bulk assignment - Assign multiple tasks at once
Priority & Scheduling
- Priority-based sorting - Urgent tasks bubble to top
- Deadline tracking - Track due dates and overdue tasks
- Recurring tasks - Daily, weekly, monthly recurring tasks
- Time estimates - Estimated completion time
- Actual time tracking - Track actual time spent
Delivery Scheduling
- Delivery schedules - Schedule deliveries to stores
- Time windows - Delivery time windows
- Delivery status - Pending, in_transit, delivered, cancelled
- Store assignment - Delivery destination stores
- Notes and instructions - Delivery-specific notes
Completion Tracking
- Completion status - Mark tasks complete
- Completion notes - Document completion details
- Completion photos - Photo evidence of completion
- Completion timestamp - Track when completed
- Completion verification - Manager verification
Notifications & Alerts
- Assignment notifications - Notify on task assignment
- Deadline alerts - Alert before deadline
- Overdue alerts - Notify when task overdue
- Completion notifications - Notify on task completion
- Reassignment notifications - Notify on reassignment
API Endpoints
Task Management
| Endpoint | Method | Description | Doc Reference |
|---|---|---|---|
/tasks/ | GET, POST, PUT, PATCH, DELETE | Task CRUD operations | views.md |
/tasks/{id}/ | GET, PUT, PATCH, DELETE | Individual task operations | views.md |
/tasks/{id}/assign/ | POST | Assign task to employee | views.md |
/tasks/{id}/complete/ | POST | Mark task complete | views.md |
/tasks/{id}/cancel/ | POST | Cancel task | views.md |
Task Filtering
| Endpoint | Method | Description | Doc Reference |
|---|---|---|---|
/tasks/by_store/ | GET | Get tasks for store | views.md |
/tasks/by_employee/ | GET | Get employee tasks | views.md |
/tasks/overdue/ | GET | Get overdue tasks | views.md |
/tasks/high_priority/ | GET | Get high priority tasks | views.md |
/tasks/pending/ | GET | Get pending tasks | views.md |
Delivery Scheduling
| Endpoint | Method | Description | Doc Reference |
|---|---|---|---|
/delivery-schedules/ | GET, POST, PUT, PATCH, DELETE | Delivery schedule CRUD | views.md |
/delivery-schedules/{id}/ | GET, PUT, PATCH, DELETE | Individual schedule operations | views.md |
/delivery-schedules/by_store/ | GET | Get store delivery schedules | views.md |
/delivery-schedules/{id}/mark_delivered/ | POST | Mark delivery complete | views.md |
Full endpoint documentation: views.md
v0.70.0: Delivery schedule endpoints (/delivery-schedules/*) are now active. The DeliverySchedule model stores recurring or one-off delivery windows per store, including capacity limits and cutoff times.
Architecture Highlights
Task State Machine
Tasks flow through well-defined states:
PENDING → IN_PROGRESS → COMPLETED
↓ ↑
CANCELLED ←──────────────────┘
Read more: models.md
Priority-Based Organization
Tasks organized by priority for efficient workflow:
- Urgent (priority 4) - Immediate attention required
- High (priority 3) - Important, complete today
- Medium (priority 2) - Standard tasks
- Low (priority 1) - Nice to have
Read more: services.md
Service Layer Architecture
Task logic centralized in service classes:
- TaskService - Task lifecycle management
- AssignmentService - Assignment and reassignment logic
- SchedulingService - Delivery scheduling
- NotificationService - Task notifications
Read more: services.md
Signal-Based Notifications
Signals trigger notifications on task events:
- Assignment notifications
- Deadline alerts
- Completion notifications
- Overdue alerts
Read more: signals.md
Getting Started
1. Understand the Models
Start with models.md to understand:
- Task model (title, description, priority, due_date, status)
- DeliverySchedule model (delivery_date, time_window, store, status)
- TaskAssignment model (task, employee, assigned_date)
- Task state machine and priority levels
2. Review Task Service
Read services.md to understand:
- Task creation workflow
- Assignment logic
- Priority-based sorting
- Deadline tracking
- Completion workflow
3. Explore Task Flows
Check views.md to learn:
- Task CRUD operations
- Assignment and reassignment
- Filtering and querying
- Delivery scheduling
4. Study Notification System
Review signals.md for:
- Assignment notifications
- Deadline alerts
- Completion notifications
- Notification delivery
Related Domains
- Users - Employee task assignments
- Stores - Store-specific tasks
- Integrations - Task synchronization with Sanity
Key Architectural Decisions
- State machine pattern - Clear task lifecycle management
- Priority-based organization - Efficient workflow management
- Service layer - Business logic centralized
- Signal-based notifications - Automatic notification delivery
- Store-scoped tasks - Tasks organized by location
- Flexible assignment - Support individual and role-based assignment
Common Use Cases
- Store opening tasks - Daily opening checklist for employees
- Inventory tasks - Stock counting, restocking tasks
- Maintenance tasks - Equipment maintenance, cleaning schedules
- Delivery coordination - Schedule and track deliveries
- Compliance tasks - Regular compliance checks and audits
- Manager assignments - Manager-level approval tasks
- Recurring tasks - Daily, weekly, monthly recurring tasks
- High priority alerts - Urgent tasks requiring immediate attention
- Task delegation - Reassign tasks to different employees
Service Methods
TaskService
Task Management:
create_task(task_data)- Create new taskupdate_task(task_id, updates)- Update task detailsassign_task(task_id, employee_id)- Assign to employeereassign_task(task_id, new_employee_id)- Reassign taskcomplete_task(task_id, completion_notes)- Mark completecancel_task(task_id, reason)- Cancel task
Task Querying:
get_tasks_by_store(store_id, filters)- Get store tasksget_tasks_by_employee(employee_id, filters)- Get employee tasksget_overdue_tasks(store_id=None)- Get overdue tasksget_high_priority_tasks(store_id=None)- Get urgent tasksget_pending_tasks(store_id=None)- Get pending tasks
Priority Management:
update_priority(task_id, new_priority)- Update task priorityescalate_priority(task_id)- Increase prioritysort_by_priority(tasks)- Sort tasks by priority
SchedulingService
Delivery Scheduling:
create_delivery_schedule(schedule_data)- Schedule deliveryupdate_delivery_schedule(schedule_id, updates)- Update schedulemark_delivered(schedule_id, notes)- Mark delivery completecancel_delivery(schedule_id, reason)- Cancel deliveryget_store_schedules(store_id, date_range)- Get store deliveries
Recurring Tasks:
create_recurring_task(task_data, frequency)- Create recurring taskgenerate_recurring_instances(recurring_task)- Generate instancesupdate_recurring_series(recurring_task_id, updates)- Update series
NotificationService
Notification Management:
notify_assignment(task_id, employee_id)- Send assignment notificationnotify_deadline(task_id)- Send deadline alertnotify_overdue(task_id)- Send overdue alertnotify_completion(task_id)- Send completion notification
Full documentation: services.md
Next Steps
- Start with models.md - Understand the data structure
- Then services.md - Learn task management logic
- Review views.md - Explore API endpoints
- Check signals.md - See notification system
- Study serializers.md - Understand validation