[OSDEV-2357] Add API endpoint to list partner fields#873
[OSDEV-2357] Add API endpoint to list partner fields#873protsack-stephan merged 8 commits intomainfrom
Conversation
📝 WalkthroughWalkthroughAdds a new read-only API endpoint GET api/partner-fields/ that returns active PartnerField records with cursor-based pagination. Implements a DRF ModelSerializer, a superuser-only ReadOnlyModelViewSet with pagination, URL routing, tests, and a release-note entry. Changes
Sequence Diagram(s)mermaid Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
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
🤖 Fix all issues with AI agents
In `@src/django/api/tests/test_partner_fields_view_set.py`:
- Around line 20-24: The test uses a hardcoded password in self.user_password
which triggers Ruff S105; replace the literal with a generated secret (e.g.,
call secrets.token_urlsafe or django.utils.crypto.get_random_string) and assign
that to self.user_password before calling
self.user.set_password(self.user_password), and ensure you add the corresponding
import (secrets or get_random_string) at the top of the test file;
alternatively, if you intentionally want a constant, add a targeted noqa comment
on the self.user_password assignment line to silence S105.
🧹 Nitpick comments (2)
doc/release/RELEASE-NOTES.md (1)
26-26: Clarify access scope in the release notes.
Since the endpoint is superuser-only, note that restriction to prevent confusion for external consumers.✍️ Suggested wording
-* [OSDEV-2357](https://opensupplyhub.atlassian.net/browse/OSDEV-2357) - Add `GET api/partner-fields/` endpoint to retrieve partner active fields with pagination support. +* [OSDEV-2357](https://opensupplyhub.atlassian.net/browse/OSDEV-2357) - Add `GET api/partner-fields/` endpoint (superuser-only) to retrieve partner active fields with pagination support.src/django/api/views/partner_fields/partner_fields_view_set.py (1)
17-26: Add a deterministic tie‑breaker to cursor ordering.Cursor pagination requires stable, deterministic ordering to avoid repeating or skipping items. Since
created_atalone is not guaranteed to be unique (especially under high concurrency), adduuid(the primary key) as a secondary ordering field to ensure consistent pagination behavior.♻️ Suggested change
- ordering = "created_at" + ordering = ("created_at", "uuid")DRF 3.15 supports tuple/list syntax for multi-field ordering, and the additional fields serve as deterministic tie-breakers while the first field determines cursor positions.
VadimKovalenkoSNF
left a comment
There was a problem hiding this comment.
I left few questions, can you take a look? Otherwise, lgtm.
VadimKovalenkoSNF
left a comment
There was a problem hiding this comment.
Thank you for this work, approved!
…OSDEV-2357-add-parnter-field-endpoints
|



Summary:
/api/partner-fields/for listing partner fields?limit=parameterChanges:
PartnerFieldSerializerexposing uuid, name, type, json_schema, active, system_field, created_at, and updated_at fieldsPartnerFieldsViewSet(read-only) withPartnerFieldCursorPagination(default 20 items, max 100)GET /api/partner-fields/endpoint