fix(views): accept 12-hour AM/PM times in the asset edit form - #3002
Merged
Conversation
- assets_update split play_time_from/to on ':' and int()'d the pieces, so the "02:30 PM" values Flatpickr posts under the default 12-hour clock raised ValueError -> HTTP 500 - add _parse_local_time mirroring _parse_local_datetime: try H:M and I:M p, fall back to ISO - unparseable date/time input now returns an error toast instead of a 500 (allowInput lets operators type anything) - reproduce via Playwright tests that drive the real time picker in both clock modes, plus parametrized form-POST regression tests - expand UI integration coverage: rename, success toast, advanced switches, refresh interval, video duration lock, modal cancels, preview content, delete cancel, schedule chips, navbar, settings round-trips (24h clock, date format, player name) Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR fixes a server-side parsing bug in the asset edit form where Flatpickr’s 12-hour h:i K values (e.g. "02:30 PM") caused assets_update to raise ValueError and return HTTP 500, preventing advanced schedule updates when use_24_hour_clock is disabled.
Changes:
- Added
_parse_local_time()to correctly parseHH:MM,h:MM AM/PM, and ISO time strings. - Updated
assets_updateto catch date/time parsing failures and surface them as error toasts (instead of HTTP 500) without saving partial updates. - Added regression and end-to-end Playwright coverage for 12-hour/24-hour clock and date format round-trips, plus additional edit modal flows.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/anthias_server/app/views.py |
Adds local time parsing helper and prevents 500s by turning parse failures into toast errors. |
tests/test_template_views.py |
Adds POST-level regression tests for 12-hour/24-hour/ISO time parsing and invalid-input toast behavior. |
tests/test_app.py |
Adds Playwright integration tests that drive the real Flatpickr UI and broader edit/settings flows end-to-end. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- only one endpoint set now returns an error toast and saves nothing, matching the v2 API's _validate_time_window - previously a half-filled form silently wiped an existing window - both fields empty still deliberately resets to "play all day" Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- _submit_edit_form already awaits the POST, so the DB assertion needs no delay - the cancel paths fire no request once Alpine state clears Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ected Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
5 tasks
vpetersson
added a commit
that referenced
this pull request
Jun 7, 2026
- CalVer (YYYY.0M.MICRO); still June 2026, micro 1 -> 2 - Ships the Qt 6 video audio fix (#3001) — PulseAudio in the viewer container; videos were silent on pi4-64/pi5/x86/arm64 since the QtMultimedia migration - Adds the arm64/Qt6 pi3-64 board and the Rock Pi 4 fleet (#2985) - Page-load watchdog so a stalled fetch can't freeze the display (#3003), Sentry error tracking for the Django services (#3007) - Redis data persisted to the mounted volume so device identity survives recreation (#2983); unpinner also rolls OS + supervisor updates (#2984) - Streamed backup downloads (#3005), 12-hour AM/PM asset times (#3002), BuildKit frontend via mirror.gcr.io (#3008) Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



Issues Fixed
Description
With the default 12-hour clock (
use_24_hour_clock: False), the Play from / Play until Flatpickr pickers post"02:30 PM"-shaped values.assets_updatesplit them on:andint()'d the pieces, soint('30 PM')raisedValueError→ HTTP 500 and the advanced schedule could never be saved._parse_local_time(mirrors_parse_local_datetime): tries%H:%Mand%I:%M %p, falls back to ISO.allowInput) now surfaces an error toast instead of a 500, without half-saving the form.Test results: unit suite 973 passed, integration suite 59 passed, ruff + mypy clean.
Checklist
🤖 Generated with Claude Code