Skip to content

Conversation

@jonathanreveille
Copy link
Member

@jonathanreveille jonathanreveille commented Oct 29, 2025

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

  • Update contract_signature_link to return only signature link for agreements related to batch order of an organization
  • Add nested organization agreements route

@jonathanreveille jonathanreveille self-assigned this Oct 29, 2025
@jonathanreveille jonathanreveille changed the base branch from main to batch-orders October 29, 2025 14:52
@jonathanreveille jonathanreveille force-pushed the refactor/get_contract_agreements_of_organizatios branch 4 times, most recently from 5563a81 to 210bbc7 Compare November 3, 2025 17:44
@jonathanreveille jonathanreveille force-pushed the refactor/get_contract_agreements_of_organizatios branch from 210bbc7 to fe38fc5 Compare November 13, 2025 17:21
@jonathanreveille jonathanreveille changed the base branch from batch-orders to refactor/change_contract_relation_of_batch_order_to_onetoone November 13, 2025 17:22
@jonathanreveille jonathanreveille changed the title ✨ (backend) Nested Organization Agreement ViewSet ✨ (backend) Nested Organization Agreement ViewSet #2 Nov 17, 2025
@jonathanreveille jonathanreveille force-pushed the refactor/get_contract_agreements_of_organizatios branch 3 times, most recently from f98b2cf to f66eba2 Compare November 17, 2025 15:28
@jonathanreveille jonathanreveille force-pushed the refactor/change_contract_relation_of_batch_order_to_onetoone branch from 619a403 to ea8ce90 Compare November 17, 2025 17:08
@jonathanreveille jonathanreveille force-pushed the refactor/get_contract_agreements_of_organizatios branch from f66eba2 to e1148dc Compare November 18, 2025 10:39
@jonathanreveille jonathanreveille force-pushed the refactor/get_contract_agreements_of_organizatios branch from e1148dc to 8317f76 Compare November 18, 2025 17:11
@kernicPanel kernicPanel requested a review from Copilot November 20, 2025 10:27
Copilot finished reviewing on behalf of kernicPanel November 20, 2025 10:31
Copy link

Copilot AI left a 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 with from_batch_order query parameter
  • Created AgreementBatchOrderSerializer and AgreementFilter for 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.

@jonathanreveille jonathanreveille force-pushed the refactor/change_contract_relation_of_batch_order_to_onetoone branch from ea8ce90 to 14c9336 Compare November 26, 2025 10:19
Base automatically changed from refactor/change_contract_relation_of_batch_order_to_onetoone to batch-orders November 26, 2025 10:38
@jonathanreveille jonathanreveille force-pushed the refactor/get_contract_agreements_of_organizatios branch 2 times, most recently from 9cc661b to be79acb Compare November 26, 2025 11:34
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
@jonathanreveille jonathanreveille force-pushed the refactor/get_contract_agreements_of_organizatios branch 2 times, most recently from 199f145 to 280d0da Compare November 26, 2025 11:45
@jonathanreveille jonathanreveille force-pushed the refactor/get_contract_agreements_of_organizatios branch 2 times, most recently from 8e16aee to 7256e24 Compare November 26, 2025 11:52
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.
@jonathanreveille jonathanreveille force-pushed the refactor/get_contract_agreements_of_organizatios branch from 7256e24 to b35780e Compare November 26, 2025 13:09
@jonathanreveille jonathanreveille merged commit 8508743 into batch-orders Nov 26, 2025
17 checks passed
@jonathanreveille jonathanreveille deleted the refactor/get_contract_agreements_of_organizatios branch November 26, 2025 13:23
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