fix(task8): delivery cleanliness, line endings, and package target
This commit is contained in:
@@ -0,0 +1 @@
|
||||
* text=auto eol=lf
|
||||
+21
-7
@@ -1,16 +1,19 @@
|
||||
backend/data/ams.db
|
||||
backend/data/test.db
|
||||
# SQLite databases
|
||||
backend/data/*.db
|
||||
*.sqlite
|
||||
*.sqlite3
|
||||
*.db
|
||||
|
||||
# Data directories
|
||||
backend/data/backups/
|
||||
backend/data/uploads/*
|
||||
!backend/data/uploads/.gitkeep
|
||||
backend/data/backups/*
|
||||
!backend/data/backups/.gitkeep
|
||||
backend/data/*.db
|
||||
backend/data/*.zip
|
||||
backend/data/*.tar.gz
|
||||
backend/data/*
|
||||
!backend/data/.gitkeep
|
||||
!backend/data/uploads/
|
||||
!backend/data/backups/
|
||||
|
||||
# Python
|
||||
.venv/
|
||||
backend/.venv/
|
||||
.pytest_cache/
|
||||
@@ -19,10 +22,21 @@ __pycache__/
|
||||
**/__pycache__/
|
||||
**/*.pyc
|
||||
*.pyc
|
||||
|
||||
# Frontend
|
||||
frontend/node_modules/
|
||||
frontend/dist/
|
||||
frontend/*.tsbuildinfo
|
||||
*.tsbuildinfo
|
||||
**/*.tsbuildinfo
|
||||
|
||||
# Archives
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.tgz
|
||||
|
||||
# Environment & OS
|
||||
.env
|
||||
*.env.local
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.PHONY: dev backend frontend test seed install
|
||||
.PHONY: dev backend frontend test seed install package
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
VENV_BIN := .venv/Scripts
|
||||
@@ -27,3 +27,6 @@ install:
|
||||
$(PYTHON_SYS) -m venv backend/.venv
|
||||
"backend/$(VENV_BIN)/pip" install -r backend/requirements.txt
|
||||
cd frontend && npm install
|
||||
|
||||
package:
|
||||
git archive --format=zip --output=../poona-ams-delivery.zip HEAD
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import subprocess
|
||||
import zipfile
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def test_package_target_creates_clean_delivery_zip(tmp_path):
|
||||
repo_root = Path(__file__).resolve().parent.parent.parent
|
||||
zip_path = tmp_path / "poona-ams-delivery.zip"
|
||||
|
||||
# Run git archive command (matching Makefile package target)
|
||||
cmd = ["git", "archive", "--format=zip", f"--output={zip_path}", "HEAD"]
|
||||
res = subprocess.run(cmd, cwd=repo_root, capture_output=True, text=True)
|
||||
assert res.returncode == 0, f"git archive failed: {res.stderr}"
|
||||
assert zip_path.exists()
|
||||
|
||||
with zipfile.ZipFile(zip_path, "r") as z:
|
||||
names = z.namelist()
|
||||
assert len(names) > 0
|
||||
|
||||
# Assert no .db database files
|
||||
db_files = [n for n in names if n.endswith(".db") or n.endswith(".sqlite") or n.endswith(".sqlite3")]
|
||||
assert db_files == [], f"Delivery archive must not contain SQLite databases: {db_files}"
|
||||
|
||||
# Assert no frontend dist/ build files
|
||||
dist_files = [n for n in names if "dist/" in n or n.startswith("dist/")]
|
||||
assert dist_files == [], f"Delivery archive must not contain dist/ directory: {dist_files}"
|
||||
|
||||
# Assert no __pycache__ or compiled bytecode
|
||||
pycache_files = [n for n in names if "__pycache__" in n or n.endswith(".pyc")]
|
||||
assert pycache_files == [], f"Delivery archive must not contain __pycache__: {pycache_files}"
|
||||
|
||||
# Assert no node_modules or .venv
|
||||
vendor_files = [n for n in names if "node_modules/" in n or ".venv/" in n]
|
||||
assert vendor_files == [], f"Delivery archive must not contain vendor/env files: {vendor_files}"
|
||||
|
||||
# Assert essential source files are included
|
||||
assert "backend/app/main.py" in names
|
||||
assert "frontend/src/App.tsx" in names
|
||||
assert "Makefile" in names
|
||||
assert "README.md" in names
|
||||
assert ".gitignore" in names
|
||||
@@ -52,3 +52,4 @@ Items marked "to be confirmed" or left flexible in the proposal are recorded her
|
||||
28. **Admin Reset Password Interface (Task 5)**: `frontend/src/api/users.ts` and `frontend/src/pages/MastersPage.tsx` expose an administrator password reset modal for users with role `system_admin`. The dialog features password masking toggles, client-side mismatch validation (`Passwords do not match`), universal password policy helper instructions, and displays backend 422 validation errors inline. Successful resets trigger a notification toast and close the modal without affecting the active administrator session.
|
||||
29. **Department User Scoping & Empty Scope Resolution (Task 6)**: `backend/app/services/scoping.py` implements `resolve_department_scope(user, requested_dept_id)`. Non-department roles are unconstrained and may optionally filter by `requested_dept_id`. Assigned `department_user` accounts are strictly bound to `user.department_id`, ignoring any client-requested department parameter. Unassigned `department_user` accounts (`department_id=None`) resolve to `is_empty=True`, immediately returning 0 counters on Dashboard summary, empty results on global search, and empty row lists across all accessible report endpoints without running hospital-wide queries. Report key aliases are registered to support both canonical paths and audit identifiers (e.g., `equipment-inventory`, `condemned-equipment`, `pm-schedule`).
|
||||
30. **Token Versioning & Session Invalidation (Task 7)**: A `token_version` integer column (default 0, not null) is added to `users` and reconciled automatically via `run_sqlite_migrations`. Access tokens encode the user's `token_version` in claim `"tv"`. `get_current_user` rejects tokens with mismatched `"tv"` with HTTP 401 (`Token has been invalidated. Please log in again.`). Password changes and administrator password resets increment `user.token_version`, invalidating previous tokens. `POST /api/auth/change-password` returns a renewed access token, and `ChangePasswordModal.tsx` stores the new token in the active auth store to keep the user's session active without re-login.
|
||||
31. **Delivery Cleanliness, Line Endings & Packaging (Task 8)**: `.gitattributes` enforces standard LF line endings across the repository (`* text=auto eol=lf`). `.gitignore` excludes all SQLite databases (`*.db`), backups, volatile uploads, frontend dist artifacts, and build info files. The `make package` target generates `../poona-ams-delivery.zip` using `git archive` to ensure zero uncommitted, ignored, or temporary files leak into handoff archives.
|
||||
|
||||
Reference in New Issue
Block a user