Skip to content
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

feat: organization field tracker #4138

Merged
merged 1 commit into from
Oct 10, 2023
Merged

feat: organization field tracker #4138

merged 1 commit into from
Oct 10, 2023

Conversation

AfaqShuaib09
Copy link
Contributor

@AfaqShuaib09 AfaqShuaib09 commented Oct 2, 2023

PROD-3582

This PR adds data modified timestamp field for Organization model

@AfaqShuaib09 AfaqShuaib09 changed the title feat: organization field tracker (initial commit) feat: organization field tracker Oct 2, 2023
@@ -301,7 +307,7 @@ class Organization(ManageHistoryMixin, CachedMixin, TimeStampedModel):
def has_changed(self):
if not self.pk:
return False
return self.has_model_changed()
return self.has_model_changed(external_keys=[self.partner], excluded_fields=['data_modified_timestamp'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: you wont need external keys here. This will only be effective if the partner is updated in the same session as Organization. Both Org and Partners are handled differently in admin. This is just adding an unnecessary computation. For Partner changes to update timestamp on Organization, we would need a pre_Save signal on Partner save, which is not needed at this point as Partner object rarely changes.

Comment on lines 1791 to 1800
def test_data_modified_timestamp_model_related_field_change(self):
"""
Verify data modified timestamp changes on related field changes in Organization Model
"""
org = factories.OrganizationFactory(partner=PartnerFactory(name='test partner', short_code='test_ptr'))
data_modified_timestamp = org.data_modified_timestamp
org.partner.short_code = 't_code'
org.save()
assert data_modified_timestamp < org.data_modified_timestamp

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you address the external keys comment above, this test will fail. In this test, the partner is accessed from org object and is applicable for external_keys check. But in actual use-case, the org handling is happening via Admin.

@AfaqShuaib09 AfaqShuaib09 force-pushed the afaq/prod-3582 branch 2 times, most recently from 91f1b79 to 7c01d50 Compare October 5, 2023 13:38
@AfaqShuaib09 AfaqShuaib09 merged commit eca596e into master Oct 10, 2023
25 checks passed
@AfaqShuaib09 AfaqShuaib09 deleted the afaq/prod-3582 branch October 10, 2023 09:17
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