6.9 KiB
Plan: Appreciation Review & Activation Workflow
Current State
The appreciation system already exists with:
- Models:
Appreciation,AppreciationCategory,AppreciationBadge,AppreciationStats - Public submission:
/appreciation/public/submit/— creates withstatus=SENTimmediately - Email notifications: Goes to the recipient (staff member) via signals
- Department model: Has
manager(User FK) andrespondent(Staff FK) - Staff model: Has
is_headboolean flag
Problem
Current workflow immediately sends public appreciations to recipients without staff review. The user wants:
- Appreciations saved as pending for staff review
- Staff selects the actual staff member and assigns to department
- Staff "activates" the appreciation
- Department head receives email notification upon activation
Solution
1. Modify Public Submission (DRAFT instead of SENT)
File: apps/appreciation/ui_views.py — public_appreciation_submit
Changes:
- Create appreciation with
status=DRAFTinstead ofSENT - Remove
appreciation.send()call - Store raw submitted data in
metadataJSON field:{ "submitted_by_name": "...", "submitted_by_phone": "...", "submitted_by_email": "...", "staff_name_mentioned": "...", "source": "public_form" } - Keep
message_enclean (just the message, not the formatted metadata string)
2. Add Review List Page
New file: templates/appreciation/review_list.html
Modified file: apps/appreciation/ui_views.py — add appreciation_review_list view
Features:
- Table of appreciations with
status=DRAFT - Columns: Reference, Hospital, Category, Message, Submitted Date, Actions
- "Review" button links to detail page
- "Activate" button (shortcut to activate without detail page)
- Filters: Hospital, Category, Date range
- Pagination
Permissions: PX Staff, Hospital Admin, PX Admin
3. Add Review Detail Page
New file: templates/appreciation/review_detail.html
Modified file: apps/appreciation/ui_views.py — add appreciation_review view
Features:
- Display appreciation details (message, submitted info from metadata)
- Staff selection: Dropdown of staff members (TomSelect)
- Filtered by hospital
- Searchable by name, staff ID
- Department: Auto-populated from selected staff's department
- Or manual override dropdown
- Category: Dropdown (can change from default)
- "Activate & Send" button
- Sets
status=SENT - Sets
recipientto selected Staff - Sets
departmentto staff's department - Triggers notification signal
- Sets
- "Save as Draft" button (keep as DRAFT, update fields)
4. Update Email Notification to Department Head
File: apps/appreciation/signals.py — send_appreciation_notification
Changes:
- Current: Sends to
appreciation.recipient(staff member) - New: Also send to department head
- Department head =
appreciation.department.manager(User) - OR Staff in department with
is_head=True→ then get their user
- Department head =
- Send separate email to department head with subject: "New Appreciation for [Staff Name] in [Department]"
- Keep existing recipient email unchanged
5. Update Sidebar Navigation
File: templates/layouts/partials/sidebar.html
Changes:
- Add "Review Appreciations" link under Appreciations section
- Only visible to staff with review permissions (PX Staff, Admin roles)
- Show badge count of pending (DRAFT) appreciations
6. Update Appreciation List View
File: apps/appreciation/ui_views.py — existing list view
Changes:
- Add filter for
status(DRAFT, SENT, ACKNOWLEDGED) - Show DRAFT appreciations only to reviewers
- Show status badge (color-coded)
7. URL Routes
File: apps/appreciation/urls.py
New routes:
/appreciation/review/— Review list/appreciation/review/<uuid:pk>/— Review detail/appreciation/review/<uuid:pk>/activate/— Activate action (POST)
8. Permissions
- Public: Can submit appreciations (no login)
- Reviewers (PX Staff, Hospital Admin, PX Admin): Can review and activate
- Department Heads: Receive email notifications on activation
- Recipients (Staff): View their appreciations after activation
Database Changes
No schema changes needed. The existing status field already has DRAFT choice. Just need to:
- Use
metadataJSON field to store submission data - Use existing
recipientgeneric FK to link to Staff
Files to Modify
apps/appreciation/ui_views.py— Modify public submit, add review viewsapps/appreciation/signals.py— Update notification to include department headapps/appreciation/urls.py— Add review routestemplates/layouts/partials/sidebar.html— Add review navigationtemplates/core/public_submit.html— Update appreciation form (if needed)
New Files to Create
templates/appreciation/review_list.html— Review list pagetemplates/appreciation/review_detail.html— Review detail pagetemplates/appreciation/emails/department_head_notification.html— Email template for dept headtemplates/appreciation/emails/department_head_notification.txt— Plain text version
Expected User Flow
- Patient visits public page → selects "Appreciation" → fills form (name, phone, message, staff name mentioned) → submits
- System saves appreciation as DRAFT with metadata
- PX Staff logs in → sees "Review Appreciations" in sidebar with badge count → clicks
- Staff views list of draft appreciations → clicks "Review" on one
- Staff sees form with:
- Patient info (from metadata)
- Staff selector (searchable dropdown)
- Department (auto-filled)
- Category selector
- Staff selects staff member → clicks "Activate & Send"
- System:
- Sets status to SENT
- Links recipient to selected Staff
- Sets department from staff
- Triggers signal
- Signal handler sends emails:
- To recipient (staff member) — existing
- To department head — NEW
- Department Head receives email: "New appreciation for [Staff] in [Department]"
- Staff (recipient) receives email: "You've received an appreciation!"
Email Recipients
When appreciation is activated, send to:
- Recipient (staff member who received appreciation) — existing behavior
- Department Head — NEW:
- Primary:
department.manager(User) if exists and has email - Fallback: Staff in department with
is_head=True→ get their user → send to user.email - If no department head found, skip (don't fail)
- Primary:
User Clarifications
- Hospital selection: Patient selects from dropdown (keep current)
- Staff mention: Patient mentions staff name as free text (keep current)
- Department head: BOTH
department.manager(User) AND Staff withis_head=True→ get user → send to user.email - Tracking code: Not needed
- Department head UI access: Not specified — will only send emails for now