Skip to content

Conversation

@kathirpsmy
Copy link
Contributor

@kathirpsmy kathirpsmy commented Sep 21, 2025

Emergency checklist — Remote Coordinator task completion, admin checklist/subtask management, and reporting

This pull request introduces the Emergency Checklist feature improvements and admin management tools. It enables SIMS Remote Coordinators (RCs) to mark tasks and subtasks as completed for their assignments, tracks who completed items and when, improves subtask ordering and error handling, and adds admin UI/endpoints to manage checklists, subtasks and report options. It also enhances reporting by adding detailed emergency task statistics and subtask completion data.

Highlights

  • Allow Remote Coordinators to mark tasks and subtasks completed for assignments.
  • Track completion metadata (completed_by user and completion timestamp) for tasks/subtasks where applicable.
  • Add admin features to create, update, reorder and delete checklists and subtasks (with permission safeguards preventing deletion when assigned to emergencies).
  • Add permission checks so only authorized users can edit subtasks and see completion metadata.
  • Improve checklist update logic to retain existing tasks/subtasks reliably and parse updates robustly.
  • Add task reports and a new report tab showing detailed emergency task statistics and per-subtask completion info.
  • Fixes and polishing: subtask date variable fix in templates, ordering improvements, and improved error handling/messages.

Why this change

Remote Coordinators need to record when they complete tasks against assignments. Admins needed better tools to manage and maintain checklists and subtasks and prevent accidental data loss. The new reporting makes it easy to audit task completion across emergencies.

Files and areas changed (high level)

  • Checklist management views / endpoints (admin)
  • Emergency checklist update paths (assignment/task tracking)
  • Subtask model fields and handling (completed metadata and ordering)
  • Task reporting code and templates
  • DB migrations (Alembic / Flask-Migrate) — new migration scripts added

Commit list from this branch (chronological newest -> oldest)

  • 5d27460a | feat: improve task and subtask handling in emergency checklist updates with robust parsing and retention logic
  • f645cf72 | feat: enhance task report with detailed emergency task statistics and subtask completion information
  • 521d68c2 | feat: add prevention for deleting checklists and subtasks assigned to emergencies
  • 89293ee5 | feat: add user permission checks for subtask editing and display completed by information
  • 565beb3f | feat: enhance subtask management with improved ordering and error handling
  • be2e55b7 | feat: add task completion tracking and user assignment
  • 3a0568f1 | feat: improve emergency checklist update logic with better task and subtask handling
  • cedc5552 | refactor: admin_manage_checklist for improved readability and functionality
  • 49efcacc | feat: add new checklist management features including task status updates and task report tab
  • 23d4081c | fix: correct subtask completion date variable in emergency template
  • 47db2376 | feat: enhance checklist management with sub-task functionality and UI improvements
  • 38ba81dc | Add sub-task management functionality to checklist system
  • fa0fba5a | feat: initial checklist changes

Database migration notes

This branch contains Flask-Migrate (Alembic) migration scripts. Before you deploy or run the app locally after pulling this branch, apply the migrations to update your database schema.

Recommended local dev steps (PowerShell)

  1. Ensure your Python environment is active and dependencies are installed. From the repository root (where flask_app/requirements.txt lives):
# create & activate a virtualenv (if you don't already have one)
python -m venv .venv
. .venv\Scripts\Activate.ps1

# install requirements
pip install -r flask_app/requirements.txt
  1. Set Flask environment variables for the session and run the DB upgrade:
$env:FLASK_APP = 'flask_app/run.py'
$env:FLASK_ENV = 'development'

# run the migration upgrade
flask db upgrade
  1. Start the app (optional):
# run the dev server
flask run --host 0.0.0.0 --port 5010

Notes and safety tips

  • Backup your database before running migrations on staging/production.
  • Inspect the migration files under flask_app/migrations/versions/ to see the exact schema changes.
  • If you're using a different Flask entrypoint, set FLASK_APP accordingly (e.g. SIMS_Portal:create_app() if applicable).

Docker / container instructions

If you run the app inside Docker (docker-compose), after building/updating the image you can run the upgrade inside the running container:

# build and run (from repository root or where docker-compose.yml exists)
docker compose up --build -d

# find the running container name (example: sims-docker-vscode)
docker ps

# run the migration inside the container (adjust container name)
docker exec -it <container-name> bash
flask db upgrade
exit

If your container doesn't have the Flask CLI available, run the upgrade using the python entrypoint and Flask-Migrate scripts (for example python -m flask db upgrade inside the container).

Testing and validation

  • After running flask db upgrade, run a quick smoke test: create a test assignment and mark a subtask complete via the UI or API. Confirm the completed_by and completion timestamp fields are present and saved.
  • Manually review the admin checklist pages: create/edit/reorder/delete checklist & subtasks. Confirm deletion prevention triggers when a checklist/subtask is assigned to an emergency.

resolves #127

Added feature to show checklist in the Emergency page.
Added Admin section to manage Checklist and Emergency Cheklist.
- Introduced SubTask and AssignmentSubTask models to handle sub-tasks associated with checklists.
- Updated forms to include fields for sub-task creation and editing.
- Enhanced routes to support adding, editing, and removing sub-tasks.
- Modified checklist management templates to display and manage sub-tasks.
- Implemented emergency checklist assignment with sub-tasks.
- Created new templates for editing checklists and sub-tasks.
- Added migration script to create sub-task related tables in the database.
…nality

- Cleaned up whitespace and formatting for better code clarity.
- Enhanced the emergency checklist section with improved structure and comments.
- Added functionality for overriding completion dates with a modal.
- Implemented JavaScript to handle checkbox interactions and form submissions.
- Removed redundant task status table to streamline the interface.
- Updated the AssignmentSubTask model to include a `task_completed_by` field to track which user completed a task.
- Modified the update_task_status route to set the `task_completed_by` field when a task is marked as completed.
- Enhanced the admin_manage_checklist template to display the user who completed a task.
- Added a new route to fetch user information by ID for displaying the name of the user who completed the task.
- Created a migration script to add the `task_completed_by` column to the assignment_sub_task table and establish the foreign key relationship with the user table.
@JonathanGarro JonathanGarro self-assigned this Oct 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add dynamic checklists for SIMS Remote Coordinators

2 participants