-
Notifications
You must be signed in to change notification settings - Fork 2
✨ (backend) Nested Organization Agreement ViewSet #2 #1231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ (backend) Nested Organization Agreement ViewSet #2 #1231
Conversation
5563a81 to
210bbc7
Compare
210bbc7 to
fe38fc5
Compare
f98b2cf to
f66eba2
Compare
619a403 to
ea8ce90
Compare
f66eba2 to
e1148dc
Compare
e1148dc to
8317f76
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a new nested API endpoint for organization administrators and owners to retrieve and manage agreements (contracts related to batch orders). The implementation includes new ViewSets, filters, serializers, comprehensive test coverage, and extends the existing contract signature link endpoint to support batch order contracts.
Key Changes
- Added
/api/v1.0/organizations/{organization_id}/agreements/endpoint for listing and retrieving batch order contracts - Extended
/api/v1.0/organizations/{organization_id}/contracts-signature-link/to support batch order contracts withfrom_batch_orderquery parameter - Created
AgreementBatchOrderSerializerandAgreementFilterfor agreement-specific serialization and filtering - Updated contract model's
get_abilities()method to support both order and batch_order contracts
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/backend/joanie/tests/swagger/swagger.json | Added OpenAPI specifications for new agreements endpoints with filtering parameters |
| src/backend/joanie/tests/core/api/organizations/test_contracts_signature_link.py | Added comprehensive tests for batch order contract signature link functionality |
| src/backend/joanie/tests/core/api/organizations/test_api_organizations_agreements.py | Added full test suite for agreements API including permissions, filtering, and retrieval |
| src/backend/joanie/tests/core/api/organizations/test_api_organizations_agreements.perf.yml | Added performance benchmarks for agreement API database queries |
| src/backend/joanie/core/serializers/client.py | Added AgreementBatchOrderSerializer to serialize batch order contracts |
| src/backend/joanie/core/models/courses.py | Extended signature_backend_references_to_sign() to support batch order contracts |
| src/backend/joanie/core/models/contracts.py | Updated get_abilities() to handle both order and batch_order organization relationships |
| src/backend/joanie/core/filters/client/init.py | Added AgreementFilter with signature state and offering filters for batch order contracts |
| src/backend/joanie/core/api/client/init.py | Implemented GenericAgreementViewSet and NestedOrganizationAgreementViewSet with proper access control |
| src/backend/joanie/client_urls.py | Registered new agreements endpoint in organization nested router |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/backend/joanie/tests/core/api/organizations/test_contracts_signature_link.py
Outdated
Show resolved
Hide resolved
src/backend/joanie/tests/core/api/organizations/test_contracts_signature_link.py
Outdated
Show resolved
Hide resolved
ea8ce90 to
14c9336
Compare
9cc661b to
be79acb
Compare
The method `get_abilities` on the Contract model was not yet updated for user's who have accesses to organization concerning bathc orders We've now updated the permissions of this method to check whether or not the user has the authorization to sign the contracts related to batch order of his organization. Also, we have updated the method 'contracts_signature_link' to be able to retrieve only batch order contracts. Organization users with owner role can now filter by contract ids or offering ids to retrieve a signature link to sign in bulk contracts. Fix #1237
199f145 to
280d0da
Compare
8e16aee to
7256e24
Compare
We want authenticated organization user who have access to be able to list, retrieve information on the contracts related to batch orders. This will allow certain user who have the rights to retrieve the list of contracts and if they are eligible to sign them. We needed to create a new viewset and serializer because the existing viewset for organization nested contract viewset was built around the relation `contract.order`, it did not correspond to the relation `batch_order.contract`. This is the reason why we created a new viewset for that matter.
7256e24 to
b35780e
Compare
Purpose
As an organization administrator / owner, they should be able to retrieve organization's agreements.
In order to do that, we added a nested in organizations route which allow to retrieve all agreements (contracts) relying on the given organization.
Also, we needed to update the contract_signature_link method that retrieve the signature link to sign in bulk contracts. The update concerned that it's now possible to retrieve the signature link for contracts that are exclusively related to batch orders.
Proposal
contract_signature_linkto return only signature link for agreements related to batch order of an organization