Add admin-controlled order lock system #20
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🚀 Overview
Introduces a database-backed lock system, empowering administrators to control hardware order submissions directly via the UI.
Problem: Previously, order windows were controlled by hard-coded date constants, requiring a redeployment to change.
Solution: A dynamic toggle that allows instant control without touching the codebase.
✨ Key Features
Admin Lock Button: A simple toggle on the Orders page for real-time control.
User Feedback: Clear, context-aware messaging for users when orders are restricted.
Superuser Override: Built-in emergency bypass for Tech Leads/Superusers.
Audit Trail: Comprehensive tracking of who engaged the lock and at what time.
🛠 Technical Changes
Backend
Model: Added OrderLockConfig to store is_locked, locked_by, locked_at, and reason.
API: Created new endpoints at GET/POST /api/hardware/orders/lock/.
Logic: Enhanced order validation middleware to verify lock status before processing.
Coverage: Added unit tests for the lock state logic and superuser permission overrides.
Frontend
State Management: Added orderLockSlice.ts for global lock status via Redux.
Components: * OrderLockButton: Admin-only toggle located on the Orders page.
OrderLockAlert: Warning banner for participants on the Cart page.
UX: Submit button is now dynamically disabled based on lock state.
Documentation
Updated README.md with instructions on how to manage the lock and view audit logs.
✅ Testing & Verification
[ ] Admin: Toggle the lock on the Orders page and verify state persists on refresh.
[ ] Participant: Attempt to submit an order while locked; verify the button is disabled and the alert is visible.
[ ] Superuser: Verify the ability to submit orders even when the global lock is active.
[ ] Audit Log: Navigate to /admin/hardware/orderlockconfig/ and verify the history reflects the correct user and timestamp.