diff --git a/app/main.py b/app/main.py index ccdc7d5..81094dd 100644 --- a/app/main.py +++ b/app/main.py @@ -20,7 +20,7 @@ logger = logging.getLogger(__name__) async def ensure_legacy_schema(conn) -> None: - """Add columns from alembic migrations that legacy create_all databases lack.""" + """Add columns/data changes from alembic migrations that legacy create_all databases lack.""" result = await conn.execute(text("PRAGMA table_info(categories)")) columns = {row[1] for row in result} if "show_in_form" not in columns: @@ -28,6 +28,16 @@ async def ensure_legacy_schema(conn) -> None: text("ALTER TABLE categories ADD COLUMN show_in_form BOOLEAN NOT NULL DEFAULT 1") ) logger.info("Added missing categories.show_in_form column (legacy database)") + result = await conn.execute( + text( + "UPDATE categories SET name = 'Missing Item' " + "WHERE type = 'cs' AND name = 'Lost Property' AND parent_id IS NULL " + "AND NOT EXISTS (SELECT 1 FROM categories c2 " + "WHERE c2.type = 'cs' AND c2.name = 'Missing Item' AND c2.parent_id IS NULL)" + ) + ) + if result.rowcount: + logger.info("Renamed legacy 'Lost Property' category to 'Missing Item'") @asynccontextmanager diff --git a/app/templates/tickets/new.html b/app/templates/tickets/new.html index 204a55b..461f638 100644 --- a/app/templates/tickets/new.html +++ b/app/templates/tickets/new.html @@ -111,19 +111,19 @@
@@ -207,6 +207,7 @@ reporter: '', reported_via: '' }, + priorityAuto: false, categories: [], subCategories: [], unitGroups: {}, @@ -237,6 +238,7 @@ } else { this.form.priority = ''; } + this.priorityAuto = false; this.loadCategories(); }, @@ -319,8 +321,16 @@ 'Aluminum/Glass': 'Windows, doors, sliding/fixed panels, glass and mirror replacement.' }; if (parent?.name && hints[parent.name]) this.selectedCategoryHint = hints[parent.name]; - // Mould & Damp defaults to Medium priority - if (parent?.name === 'Mould & Damp' && !this.form.priority) this.form.priority = 'medium'; + // Mould & Damp defaults to Medium priority; clear the auto-default + // when switching away so a non-Mould ticket doesn't keep it silently + if (parent?.name !== 'Mould & Damp' && this.priorityAuto) { + this.form.priority = ''; + this.priorityAuto = false; + } + if (parent?.name === 'Mould & Damp' && !this.form.priority) { + this.form.priority = 'medium'; + this.priorityAuto = true; + } }, handlePhotos(e) {