Добавлены endpoints:
- start_work: APPROVED → IN_PROGRESS
- complete: IN_PROGRESS → COMPLETED
- cancel: отмена заявки с любого статуса кроме завершённых
- create_equipment: создание оборудования из позиции завершённой заявки
Frontend:
- Модальные окна approve/reject/cancel
- POST handler для создания заявок
- Django формы для заявок
Тесты: 19 новых тестов lifecycle, всего 136 тестов procurement passed
- Add DeptPerm.MANAGE_EQUIPMENT scoped permission constant
- Create migration 0035 for new DepartmentPermission
- Refactor CanManageEquipment permission class with:
* Admin/staff/superuser → full access
* Model permissions → full access (add/change/delete_equipment)
* Department head → own department, can choose responsible
* Scoped permission → own department, responsible forced to head
* Regular members → no access
- Update EquipmentListSerializer with:
* Permission level detection (full/dept_head/scoped/None)
* Auto-fill department and responsible based on permission level
* Validation that responsible is in same department
- Add create_options endpoint returning:
* allowed_departments, can_choose_department, can_choose_responsible
* default_responsible, permission_level
- Add bulk equipment creation support with auto-generated inventory numbers
- Implement 45 comprehensive permission tests (all passing)
- Fix is_active=True in test make_user() fixture
Tests: 45/45 passing ✅
Stage 7 - Integration:
- Create notification types migration for procurement
- Fix signals to use pre_save for status tracking
- Add broadcast_request_update function for WebSocket events
- Add procurement_update handler in UserConsumer
- Add 6 integration tests for signals and notifications
- Update README with integration details
All 72 tests passing (66 base + 6 integration).
- Added Q(approvals__approver=user) filter to ProcurementRequestViewSet.get_queryset()
- Ensures users can see requests where they are designated approvers
- Added .distinct() to prevent duplicate results from approval JOIN
- Updated test_cannot_approve_without_permission to accept 404 (more secure)
- Cleaned up debug statements from test_workflow.py
This fixes the 404 errors in multi-level approval workflow:
- test_multi_level_approval: PASSED ✅
- test_cannot_approve_without_permission: PASSED ✅
All 41 procurement tests now passing: 20 models + 12 API + 9 workflow
- Add estimated_cost to all test ProcurementRequests
- Fix budget year from 2024 Q1 to 2025 Q4
- Fix finance manager lookup to check user_permissions too
- Remove debug print from test_submit_request_creates_approvals
Result: 39/41 tests PASSED (was 38/41)
Remaining: 2 tests with 404 on /approve/ endpoint