feat(projectHistoryLogs): create project history logs when related objects change TASK-944 #5223
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.
📣 Summary
Create project history logs for changes to associated media files, rest services, and imported data.
📖 Description
Log changes whenever someone:
👀 Preview steps
localhost/api/v2/audit-logs/?q=log_type:project-history AND metadata__asset_uid:<asset_uid>
action: delete-media
action: register-service
and the following inmetadata.hook
:action: register-service
and the following inmetadata.hook
:q1
andq2
action: connect-project
and the following inmetadata.paired_data
:q1
from the imported questions and hitAccept
action: modify-imported-fields
and the following inmetadata.paired_data
:action: disconnect-project
and the following inmetadata.paired_data
:💭 Notes
Updates the AuditLoggedViewSet code to allow fields to be put in the
initial_data
and/orupdated_data
dictionaries under a different label if desired. If logged_fields has a tuple (k,v) instead of a field, the relevant dictionary will store{'k': object.v}
rather than{v: object.v}
.Updates the HookViewSet, AssetFileViewSet, and PairedDataViewsets to inherit from the AuditLoggedViewSet base class, adding the necessary fields from each to the
logged_fields
as well as the object id of the related asset.Add a method in ProjectHistoryLog for dealing with requests that come from these kinds of related-object view sets, where it just takes everything in the
updated_data
orinitial_data
dictionary (except theobject_id
, which it uses as its ownobject_id
) and puts it in the metadata under a given label.Also refactors the overall
create_from_request
delegation method to use a dictionary of<view_name> : method
rather than a whole bunch of if-elses.Unrelated to other things, changes calls to the deprecated method
assertEquals
toassertEqual
to get rid of warnings.BTW @noliveleger in order to make PRs less confusing I'll keep going the way I've been doing it then do an alphabetizing PR at the very end.