Skip to content

feat(commcare): UCR expression atoms + CRUD response parsing fix#397

Merged
jjackson merged 1 commit into
mainfrom
emdash/ocs-vw0t6
May 22, 2026
Merged

feat(commcare): UCR expression atoms + CRUD response parsing fix#397
jjackson merged 1 commit into
mainfrom
emdash/ocs-vw0t6

Conversation

@jjackson
Copy link
Copy Markdown
Owner

Removes the manual-UCR step from V1 bootstrap.

  • ✅ commcare_list_ucr_expressions
  • ✅ commcare_create_ucr_expression (verified end-to-end on connect-ace-prod)
  • 🐛 Fix: CRUDPaginatedViewMixin wraps create response as {newItem: {itemData}} not {itemData} — was affecting createInboundApi silently. Both atoms now read newItem.itemData first.

V1 manual steps: 4 → 3 (subscription + custom user data field + conditional alert remain).

🤖 Generated with Claude Code

Adds list + create for named UCR expressions / filters. Removes the
"manual UCR push from master" step that was blocking clean V1 bootstrap.

  - commcare_list_ucr_expressions: POST paginate to /data/ucr_expressions/.
  - commcare_create_ucr_expression: action=create with name + expression_type
    ("named_expression" | "named_filter") + JSON definition + optional
    description. Verified end-to-end on connect-ace-prod (created id=291
    named_filter with a real boolean_expression definition).

Also fixes a CRUDPaginatedViewMixin response parsing bug that affected
createInboundApi: the wrapper is `{newItem: {itemData, template}}`, not
`{itemData, template}` directly. The previous parser silently fell back
to list-and-find which worked but was slower and didn't surface
IntegrityError messages. Both createUcrExpression and createInboundApi
now read newItem.itemData first, surface newItem.error explicitly.

V1 manual steps reduced from 4 to 3:
  - DONE: UCR expressions (this PR)
  - STILL MANUAL: subscription provisioning (out-of-band, accounts@)
  - STILL MANUAL: custom user data field (Knockout-bound form, read of
    existing state isn't HTML-scrapable — needs careful "set" semantics
    to avoid destroying existing fields; defer to V1.5)
  - STILL MANUAL: conditional alert create (3-form combined POST with
    dynamic fields; defer to V1.5)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@jjackson jjackson enabled auto-merge May 22, 2026 07:58
@jjackson jjackson merged commit 1209cd6 into main May 22, 2026
2 checks passed
jjackson added a commit that referenced this pull request May 22, 2026
…moved)

  - commcare_list_user_fields: GETs /a/<domain>/users/user_data/, parses
    the <div data-name="custom_fields" data-value="<json>"> initial_page_data
    div (HQ's Django→JS bootstrap mechanism, per
    corehq/apps/hqwebapp/templatetags/hq_shared_tags.py:650). Returns
    the list of current fields + profiles. Surfaces the 302-to-settings
    /users/ permission-redirect as a typed error.

  - commcare_set_user_fields: POSTs the CustomDataFieldsForm to the
    same URL with `data_fields` JSON-encoded. Direct form POST bypasses
    the React/Knockout UI (verified against apps/custom_data_fields/
    edit_model.py:491 — post() calls form.is_valid() then
    save_custom_fields(), no UI involvement). DESTRUCTIVE: replaces
    the existing list; callers should list_user_fields → merge → set.

V1 manual steps reduced from 3 to 2:
  - DONE: UCR expressions (PR #397)
  - DONE: custom user data field (this PR)
  - STILL MANUAL: subscription provisioning (out-of-band, accounts@)
  - STILL MANUAL: conditional alert (30+ field 3-form combined POST
    with dynamic criteria + schedule choice tree; needs a known-working
    reference to safely construct field combos. Defer until we have
    access to one of the team's existing alerts to model against.)

Conditional alert API hunt confirmed via codebase:
  - corehq/messaging/scheduling/urls.py — only admin views (list/create/
    edit/download/upload). No Tastypie, no DRF.
  - The download/upload variants are XLS, not CSV (Format.XLS_2007).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.

1 participant