Add functionality to run formulas on existing records - #395
Merged
Conversation
arsen-vs
requested review from
datamik,
domdinicola,
roma-valor and
vitali-yanushchyk-valor
June 5, 2026 07:49
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #395 +/- ##
========================================
Coverage 96.94% 96.95%
========================================
Files 238 238
Lines 9822 9905 +83
Branches 1091 1104 +13
========================================
+ Hits 9522 9603 +81
+ Misses 143 142 -1
- Partials 157 160 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
|
|
added 9 commits
June 8, 2026 13:59
- Introduced a new form, `RunTransformerForm`, to allow users to select a batch and specify the record type for formula application. - Implemented a new admin action, `run_on_existing_records`, to handle the execution of formulas directly in the Country Workspace. - Created a corresponding HTML template for the form, enhancing the user interface for running formulas without rule commits. - Added permission checks to ensure users can only run formulas on batches they are authorized to process.
…ctionality - Introduced tests for the `RunTransformerForm` to validate choices based on program type. - Added tests for the `run_on_existing_records` method in the `CountryTransformerAdmin`, covering scenarios for rendering the form, handling permissions, and processing valid and invalid submissions. - Utilized mocking to simulate requests and responses, ensuring isolated and reliable test outcomes.
- Updated the ApplyToOptions class in RunTransformerForm to inherit from models.TextChoices instead of forms.TextChoices, aligning with Django best practices for defining choice fields. - This change enhances the integration with Django's model layer, improving maintainability and consistency across the application.
- Updated test cases in `test_transformer.py` to use explicit patching for the `get_object` and `get_change_url` methods of `CountryTransformerAdmin`, improving clarity and maintainability of the tests. - This change enhances the readability of the test setup by clearly indicating the target of the mocks.
…stance - Modified the `run_on_existing_records` method calls in the test cases to explicitly pass the `transformer_admin` instance, enhancing clarity and ensuring proper context is maintained during testing. - This change improves the accuracy of the tests by aligning with the method's expected parameters.
…and improve mock form usage - Modified the test cases to set `state.tenant` and `state.program` to None, ensuring proper handling of these values during testing. - Enhanced the mock setup for `RunTransformerForm` to explicitly define `ApplyToOptions`, improving clarity and consistency in the tests. - These changes contribute to more robust and maintainable test cases for the `run_on_existing_records` functionality.
- Introduced a new test case to verify that the batch queryset is filtered correctly by the office parameter in the RunTransformerForm. - Utilized mocking to simulate the queryset behavior, ensuring that the filter method is called with the expected office argument. - This addition enhances the test coverage for the RunTransformerForm functionality, contributing to more robust testing practices.
…sing.py - Added a new permission for the "Run Formula on Existing Records" button in CountryTransformerAdmin to ensure proper access control. - Refactored the action for batch processing to use `apply_batch_transformers`, improving clarity and functionality. - Introduced a new helper function `_apply_transformer_only` to streamline the transformation of individual records. - Updated the `apply_batch_transformers` function to handle batch processing for both households and individuals, including logging and error handling. - Enhanced unit tests in test_transformer.py to verify the new action and permission checks, ensuring robust testing of the updated functionality.
- Removed the `_apply_transformer_only` function to streamline the transformation process. - Updated `apply_batch_transformers` to delegate transformation logic to `run_batch_postprocessing`, enhancing clarity and maintainability. - Added new unit tests for `apply_batch_transformers` to ensure proper error handling and validation of transformer IDs. - Improved test coverage for batch processing scenarios, verifying the correct delegation and response structure.
arsen-vs
force-pushed
the
feature/289969-Steficon-formula
branch
from
June 8, 2026 11:15
0e55b8e to
5624673
Compare
- Registered the CountryTransformerAdmin in the TenantAdminSite for improved admin management. - Added a new entry for "Transformers" in the admin site navigation, linking to the CountryTransformerAdmin changelist. - Updated the __all__ list in admin/__init__.py to include CountryTransformerAdmin for proper module exports.
roma-valor
approved these changes
Jun 9, 2026
srugano
reviewed
Jun 11, 2026
- Added a clean method to RunTransformerForm to validate that households cannot be selected for non-master-detail programs, enhancing data integrity. - Updated apply_batch_transformers to delegate transformation logic to a new utility function, improving code clarity and maintainability. - Enhanced unit tests to cover the new validation logic in RunTransformerForm, ensuring robust error handling and user feedback.
- Updated the validation logic in RunTransformerForm to allow household applications only for master-detail programs, improving data integrity. - Modified the unit tests to parameterize the `apply_to` field, ensuring comprehensive coverage for both household and both options in the validation scenario.
srugano
approved these changes
Jun 15, 2026
vitali-yanushchyk-valor
approved these changes
Jun 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RunTransformerForm, to allow users to select a batch and specify the record type for formula application.run_on_existing_records, to handle the execution of formulas directly in the Country Workspace.AB#289969