Automatic Verification Flag#1168
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Warning Rate limit exceeded
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 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThis PR introduces a new Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
commcare_connect/program/api/serializers.py (1)
296-317: ⚡ Quick winConsider exposing
automatic_verificationin the response serializer.
automatic_verificationis set on the createdManagedOpportunityat Line 270, but it is absent fromManagedOpportunityResponseSerializer.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
📒 Files selected for processing (6)
commcare_connect/flags/flag_names.pycommcare_connect/opportunity/forms.pycommcare_connect/opportunity/migrations/0129_add_automatic_verification.pycommcare_connect/opportunity/models.pycommcare_connect/opportunity/tests/test_forms.pycommcare_connect/program/api/serializers.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>
ajeety4
left a comment
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
nit: Consider renaming to auto_visits_verify to be explicit.
| @@ -1,3 +1,4 @@ | |||
| AUTOMATIC_VERIFICATION = "automatic_verification" | |||
There was a problem hiding this comment.
nit: Consider renaming to AUTOMATIC_VISIT_VERIFICATION to be explicit.
| api_key=learn_api_key, | ||
| hq_server=learn_data["hq_server"], | ||
| active=False, | ||
| automatic_verification=is_flag_active(AUTOMATIC_VERIFICATION, organization), |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
Organizations were renamed to Workspaces.
There was a problem hiding this comment.
so workspace flag is the opportunity property here?
or just the flag? but that isn't opportunity dependent right?
mkangia
left a comment
There was a problem hiding this comment.
Looks good, just one query about what a "workspace" is?
Product Description
Technical Summary
Ticket Link
Safety Assurance
Safety story
Automated test coverage
Labels & Review