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

Added publication show logs link in change view #89

Merged
merged 6 commits into from
Oct 23, 2024

Conversation

bart-maykin
Copy link
Contributor

Partially Fixes #16

Copy link

codecov bot commented Oct 22, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/woo_publications/logging/admin_tools.py 83.33% 0 Missing and 1 partial ⚠️
Files with missing lines Coverage Δ
src/woo_publications/logging/admin_tools.py 98.14% <83.33%> (-1.86%) ⬇️

bart-maykin and others added 5 commits October 23, 2024 12:29
This approach is the best of both worlds:

* the admin mixin prepares the template context for the change view
* the 'change_form_object_tools.html' template override can be global,
  provided we check for the necessary context from the mixin - that
  way we only have a very minimal snippet of template code that needs
  to be overridden
* we don't need provide app/model specific template overrides, nor do
  we need to specify a custom template to use for the change_view
@@ -58,10 +58,15 @@ def log_deletion(self, request, object, object_repr):

return super().log_deletion(request, object, object_repr) # type: ignore reportAttributeAccessIssue

def change_view(self, request, object_id, form_url="", extra_context=None):
def change_view(self, request, object_id, form_url="", extra_context={}):
Copy link
Contributor

Choose a reason for hiding this comment

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

mutable defaults are an anti-pattern! See https://www.pythonmorsels.com/mutable-default-arguments/

TimelineLog.objects.create(extra_data={})
TimelineLog.objects.create(extra_data=[])

with self.subTest("publications has 'show logs' button and filters correctly"):
Copy link
Contributor

Choose a reason for hiding this comment

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

This is again a test that belongs in the publications app rather than in the logging app - the giveway is that you're importing factories/models from another django app.

However, we can rephrase this test a little bit to make it more "generic" in nature, I will push a commit for that.

@sergei-maertens sergei-maertens force-pushed the feature/16-log-link-from-admin branch from af3c6d6 to 891a828 Compare October 23, 2024 11:02
@sergei-maertens sergei-maertens merged commit 2d39e95 into main Oct 23, 2024
17 of 18 checks passed
@sergei-maertens sergei-maertens deleted the feature/16-log-link-from-admin branch October 23, 2024 11:47
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.

ODRC: Set up foundation for logging/audit trails
2 participants