Skip to content

fix(views): accept 12-hour AM/PM times in the asset edit form - #3002

Merged
vpetersson merged 4 commits into
masterfrom
fix/issue-2988-12h-time-picker
Jun 6, 2026
Merged

fix(views): accept 12-hour AM/PM times in the asset edit form#3002
vpetersson merged 4 commits into
masterfrom
fix/issue-2988-12h-time-picker

Conversation

@vpetersson

Copy link
Copy Markdown
Contributor

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_update split them on : and int()'d the pieces, so int('30 PM') raised ValueError → HTTP 500 and the advanced schedule could never be saved.

  • Added _parse_local_time (mirrors _parse_local_datetime): tries %H:%M and %I:%M %p, falls back to ISO.
  • Unparseable date/time input (the pickers run with allowInput) now surfaces an error toast instead of a 500, without half-saving the form.
  • Reproduced the bug with a Playwright integration test that drives the real time-picker UI (it returned HTTP 500 before the fix), plus parametrized form-POST regression tests for every clock shape.
  • Expanded UI integration coverage: 24-hour-clock and date-format settings round-trips driven end-to-end through the edit modal, rename + success toast, advanced switches (nocache / skip asset check), webpage refresh interval, video duration lock, add/edit/delete modal cancels, preview modal content, day-parting schedule chips, and navbar navigation.

Test results: unit suite 973 passed, integration suite 59 passed, ruff + mypy clean.

Checklist

  • I have performed a self-review of my own code.
  • New and existing unit tests pass locally and on CI with my changes.
  • I have done an end-to-end test for Raspberry Pi devices.
  • I have tested my changes for x86 devices.
  • I added a documentation for the changes I have made (when necessary).

🤖 Generated with Claude Code

- 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]>
@vpetersson
vpetersson requested a review from a team as a code owner June 6, 2026 19:36
@vpetersson vpetersson self-assigned this Jun 6, 2026
@vpetersson
vpetersson requested a review from Copilot June 6, 2026 19:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 parse HH:MM, h:MM AM/PM, and ISO time strings.
  • Updated assets_update to 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.

Comment thread src/anthias_server/app/views.py
- 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]>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment thread tests/test_app.py Outdated
Comment thread tests/test_app.py Outdated
Comment thread tests/test_app.py Outdated
- _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]>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread tests/test_app.py Outdated
@sonarqubecloud

sonarqubecloud Bot commented Jun 6, 2026

Copy link
Copy Markdown

@vpetersson
vpetersson merged commit 886a81d into master Jun 6, 2026
9 checks passed
@vpetersson vpetersson mentioned this pull request Jun 7, 2026
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]>
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.

[BUG] 500 error when trying to save using 12-hour format from the time picker in Ver 2026.06.1

2 participants