-
Notifications
You must be signed in to change notification settings - Fork 171
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
Conversation
67a0878
to
de45811
Compare
@@ -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']) |
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.
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.
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 | ||
|
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.
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.
91f1b79
to
7c01d50
Compare
7c01d50
to
a2ab468
Compare
e4b803e
to
dd3da23
Compare
PROD-3582
This PR adds data modified timestamp field for Organization model