Skip to content

Make ExhibitForm respect the route-supplied exhibit_type (#853)#944

Open
vjpixel wants to merge 2 commits into
developfrom
claude/fix-853-exhibit-route-authoritative
Open

Make ExhibitForm respect the route-supplied exhibit_type (#853)#944
vjpixel wants to merge 2 commits into
developfrom
claude/fix-853-exhibit-route-authoritative

Conversation

@vjpixel
Copy link
Copy Markdown
Member

@vjpixel vjpixel commented Apr 25, 2026

Summary

Implements the route-authoritative direction for #853.

ExhibitForm was inferring exhibit_type from whichever data field was populated (augmenteds → MR, otherwise → AR), which let users POST mismatched payloads and get a different type than the route suggested. Worse, an existing test (test_create_exhibit_with_artworks_and_objects) was locking that behaviour in.

Make the route the source of truth:

  • ExhibitForm.__init__ accepts exhibit_type kwarg. For edits, if the caller doesn't pass it, fall back to the existing instance's type so the form can't change type silently mid-edit.
  • clean() validates the type-relevant content list — AR requires artworks, MR requires augmenteds. The legacy "must have at least one artwork or augmented" guard remains as a fallback for callers that didn't pass exhibit_type.
  • save() uses self.exhibit_type to set Exhibit.exhibit_type, with the old inference kept only as the no-type-supplied fallback.
  • _handle_exhibit_form passes exhibit_type to both bound and unbound form constructions.

Test plan

Updated tests:

  • test_create_exhibit_with_artworks_and_objects: POST to /create-ar/ with mixed payload now saves as AR, not MR.
  • test_edit_exhibit_type_changes_correctly is replaced by two new tests reflecting the new contract:
    • test_edit_ar_exhibit_keeps_type_regardless_of_augmenteds
    • test_edit_ar_exhibit_rejects_empty_artworks — now returns 200 with the "AR exhibits require at least one artwork" error instead of redirecting.

Open question

Editing an existing AR exhibit and changing its type to MR (or vice-versa) is not possible through this design — type is locked at creation. If type-change is a real workflow, we'd need a separate flow (delete + recreate, or an explicit "convert" action). Calling that out for review.

Closes #853

https://claude.ai/code/session_01XC1THLWgnGXGf5wgRhdyvB


Generated by Claude Code

claude added 2 commits April 25, 2026 18:39
The form was inferring exhibit_type from whichever data field was
populated (augmenteds → MR, otherwise → AR), which let users post
mismatched payloads and get a different type than the route
suggested. Worse, an existing test
(test_create_exhibit_with_artworks_and_objects) was locking that
behaviour in.

Make the route the source of truth:

- ExhibitForm.__init__ now accepts exhibit_type. For edits, when
  the caller doesn't pass it, fall back to the existing instance's
  type so the form can't change type silently mid-edit.
- clean() validates the type-relevant content list — AR requires
  artworks, MR requires augmenteds. The pre-existing "must have
  at least one artwork or augmented" guard remains as a fallback
  for callers that don't pass exhibit_type.
- save() uses self.exhibit_type to set Exhibit.exhibit_type, with
  the old inference kept only as the no-type-supplied fallback.
- _handle_exhibit_form passes exhibit_type to both bound and
  unbound form constructions.

Tests:

- test_create_exhibit_with_artworks_and_objects now expects the
  route-driven outcome — POST to /create-ar/ with mixed payload
  saves as AR, not MR.
- test_edit_exhibit_type_changes_correctly is replaced by two
  tests that match the new contract: the type stays AR through
  edit-ar regardless of augmenteds content, and posting only
  augmenteds against the AR edit route returns the validation
  error.

Closes #853

https://claude.ai/code/session_01XC1THLWgnGXGf5wgRhdyvB
@pablodiegoss
Copy link
Copy Markdown
Member

pablodiegoss commented May 12, 2026

@vjpixel, the new tests are not working and this branch has some conflict after I've merged some of the previous merge, could you please fix them?

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.

ExhibitForm.clean() validation ignores exhibit_type, allowing inconsistent AR/MR data

3 participants