Skip to content

feat(commcare): user_fields list + set atoms#409

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

feat(commcare): user_fields list + set atoms#409
jjackson merged 1 commit into
mainfrom
emdash/ocs-vw0t6

Conversation

@jjackson
Copy link
Copy Markdown
Owner

Adds list + set for custom user data fields.

  • ✅ commcare_list_user_fields — parses initial_page_data div for current state
  • ✅ commcare_set_user_fields — POSTs CustomDataFieldsForm; DESTRUCTIVE replace semantics

V1 manual steps: 3 → 2 (only subscription + conditional alert remain). Conditional alert atom requires a known-working reference alert to safely construct the 30+ field 3-form POST; deferred until we can access the team's existing alerts.

🤖 Generated with Claude Code

…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>
@jjackson jjackson enabled auto-merge May 22, 2026 09:24
@jjackson jjackson merged commit 34b631d into main May 22, 2026
2 checks passed
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