Skip to content

Automatic Verification Flag#1168

Open
pxwxnvermx wants to merge 5 commits intomainfrom
pkv/ccct-2394-automatic-verification-flag
Open

Automatic Verification Flag#1168
pxwxnvermx wants to merge 5 commits intomainfrom
pkv/ccct-2394-automatic-verification-flag

Conversation

@pxwxnvermx
Copy link
Copy Markdown
Contributor

@pxwxnvermx pxwxnvermx commented May 8, 2026

Product Description

  • Added the AUTOMATIC_VERIFICATION flag.
  • Added an Opportunity property that is set when the above flag is active for an Organization.

Technical Summary

Ticket Link

Safety Assurance

Safety story

  • Tested Locally

Automated test coverage

  • Added automated tests

Labels & Review

  • The set of people pinged as reviewers is appropriate for the level of risk of the change

@pxwxnvermx pxwxnvermx self-assigned this May 8, 2026
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@pxwxnvermx pxwxnvermx marked this pull request as ready for review May 8, 2026 08:06
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 8, 2026

Review Change Stack

Warning

Rate limit exceeded

@pxwxnvermx has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 48 minutes and 41 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8b8e2479-9710-4f7e-86c4-cf4a85e9e7c9

📥 Commits

Reviewing files that changed from the base of the PR and between eb74bd9 and 7213dc1.

📒 Files selected for processing (1)
  • commcare_connect/opportunity/tests/test_forms.py

Walkthrough

This PR introduces a new AUTOMATIC_VERIFICATION feature flag and integrates it throughout the opportunity workflow. The flag constant is added to the flag registry, the Opportunity model receives a corresponding automatic_verification boolean field via migration, and both the form initialization and API serializer are updated to conditionally enable automatic verification for new opportunities based on organization-level flag status. Tests verify the form behavior across flag activation states.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Automatic Verification Flag' directly and concisely summarizes the main change: introducing a new feature flag for automatic verification.
Description check ✅ Passed The description is clearly related to the changeset, providing product and technical context for the automatic verification flag feature and its implementation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pkv/ccct-2394-automatic-verification-flag

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
commcare_connect/program/api/serializers.py (1)

296-317: ⚡ Quick win

Consider exposing automatic_verification in the response serializer.

automatic_verification is set on the created ManagedOpportunity at Line 270, but it is absent from ManagedOpportunityResponseSerializer.Meta.fields. If the calling service needs to confirm whether the flag was applied, the field should be included in the response.

Please confirm whether the managed opportunity creation API response intentionally omits automatic_verification. If it should be included:

➕ Proposed addition to response serializer fields
         "active",
+        "automatic_verification",
     ]
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@commcare_connect/program/api/serializers.py` around lines 296 - 317, The
response serializer currently omits the automatic_verification flag even though
ManagedOpportunity sets it on creation; update
ManagedOpportunityResponseSerializer by adding "automatic_verification" to its
Meta.fields so the API response includes that attribute, and ensure any
serializer-level constraints (e.g., read_only status) are applied as needed and
tests/assertions updated to verify the flag is returned.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@commcare_connect/opportunity/tests/test_forms.py`:
- Around line 480-514: The test method
test_init_form_sets_automatic_verification_from_workspace_flag belongs to
OpportunityInitForm tests, not the update form class; move this method out of
TestOpportunityInitUpdateForm into a new TestOpportunityInitForm class (create
class TestOpportunityInitForm: and paste the method there), removing the
duplicate from TestOpportunityInitUpdateForm so the test now lives under the
dedicated TestOpportunityInitForm group that directly references
OpportunityInitForm.

---

Nitpick comments:
In `@commcare_connect/program/api/serializers.py`:
- Around line 296-317: The response serializer currently omits the
automatic_verification flag even though ManagedOpportunity sets it on creation;
update ManagedOpportunityResponseSerializer by adding "automatic_verification"
to its Meta.fields so the API response includes that attribute, and ensure any
serializer-level constraints (e.g., read_only status) are applied as needed and
tests/assertions updated to verify the flag is returned.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 63f3d7b1-598f-43a7-aaf4-3e30ca570b9c

📥 Commits

Reviewing files that changed from the base of the PR and between 0245f06 and eb74bd9.

📒 Files selected for processing (6)
  • commcare_connect/flags/flag_names.py
  • commcare_connect/opportunity/forms.py
  • commcare_connect/opportunity/migrations/0129_add_automatic_verification.py
  • commcare_connect/opportunity/models.py
  • commcare_connect/opportunity/tests/test_forms.py
  • commcare_connect/program/api/serializers.py

Comment thread commcare_connect/opportunity/tests/test_forms.py
The test exercises OpportunityInitForm and was sitting under
TestOpportunityInitUpdateForm only because that class had a convenient
fixture. Use the global opportunity fixture from conftest and put the
test under a dedicated TestOpportunityInitForm class.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@ajeety4 ajeety4 left a comment

Choose a reason for hiding this comment

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

Looks great.

Optional naming suggestion in case it makes sense.

country = models.ForeignKey(Country, on_delete=models.PROTECT, null=True)
auto_approve_visits = models.BooleanField(default=True)
auto_approve_payments = models.BooleanField(default=True)
automatic_verification = models.BooleanField(default=False)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: Consider renaming to auto_visits_verify to be explicit.

@@ -1,3 +1,4 @@
AUTOMATIC_VERIFICATION = "automatic_verification"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: Consider renaming to AUTOMATIC_VISIT_VERIFICATION to be explicit.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1

api_key=learn_api_key,
hq_server=learn_data["hq_server"],
active=False,
automatic_verification=is_flag_active(AUTOMATIC_VERIFICATION, organization),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I find it strange that ManagedOpportunity and Opportunity are two separate models.

@pytest.mark.django_db
class TestOpportunityInitForm:
@pytest.mark.parametrize("flag_active_for_org", [True, False])
def test_init_form_sets_automatic_verification_from_workspace_flag(self, opportunity, flag_active_for_org):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what is a workspace?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Organizations were renamed to Workspaces.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

so workspace flag is the opportunity property here?

or just the flag? but that isn't opportunity dependent right?

Copy link
Copy Markdown
Contributor

@mkangia mkangia left a comment

Choose a reason for hiding this comment

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

Looks good, just one query about what a "workspace" is?

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.

3 participants