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

Honor a custom admin site_header in the listing and details pages. #448

Merged
merged 1 commit into from
Oct 25, 2018

Conversation

tbeadle
Copy link
Contributor

@tbeadle tbeadle commented Oct 18, 2018

Description

Include the admin site's site_header when generating the context for the pages used in django-simple-history.

Related Issue

Fixes #205

Motivation and Context

Previously, the default "Django Administration" header was being displayed.

How Has This Been Tested?

Used a sample project and set admin.site.site_header = 'Something' in urls.py. Verified that the history listing and details pages show that header. Previously, they showed the default.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@codecov-io
Copy link

codecov-io commented Oct 18, 2018

Codecov Report

Merging #448 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #448      +/-   ##
==========================================
+ Coverage   97.35%   97.36%   +<.01%     
==========================================
  Files          15       15              
  Lines         680      682       +2     
  Branches       93       93              
==========================================
+ Hits          662      664       +2     
  Misses          9        9              
  Partials        9        9
Impacted Files Coverage Δ
simple_history/admin.py 97.97% <100%> (+0.04%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 168eecc...cd76a54. Read the comment docs.

@rossmechanic
Copy link
Collaborator

Thanks for this @tbeadle. Did you see my comment in the original issue about using each_context? If you look at updated django ModelAdmin it seems like they all use each_context which also solved the issue. See here: https://github.com/django/django/blob/master/django/contrib/admin/options.py#L1608

@rossmechanic rossmechanic added the DjangoConUS2018 Work resulting from DjangoConUS2018 sprint label Oct 18, 2018
@@ -84,6 +84,7 @@ def history_view(self, request, object_id, extra_context=None):
'admin_user_view': admin_user_view,
'history_list_display': history_list_display,
}
context.update(self.admin_site.each_context(request))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks good, but why not include in the initial context definition? Like https://github.com/django/django/blob/master/django/contrib/admin/options.py#L1608

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That syntax is not supported for python2.7.

barm
barm previously approved these changes Oct 18, 2018
Copy link
Collaborator

@barm barm left a comment

Choose a reason for hiding this comment

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

Looks good to me, @rossmechanic do you want to approve as well?

@barm
Copy link
Collaborator

barm commented Oct 18, 2018

Oops sorry I don't like merge commits but I hit the "Update branch" button in the Github UI to resolve the conflict and it did that

@barm
Copy link
Collaborator

barm commented Oct 18, 2018

When we merge we can just use Github's "Squash and merge" to preserve a clean commit history.

@barm
Copy link
Collaborator

barm commented Oct 18, 2018

Can you add a note to CHANGES.rst as well, following this convention (and with the PR number in parens (gh-448):
2ee12d9#diff-db23dcd814354c954091a9b90dbfd92a

CHANGES.rst Outdated
- Add `'+'` as the `history_type` for each instance in `bulk_history_create` (gh-449)
- Add support for `history_change_reason` for each instance in `bulk_history_create` (gh-449)
- Fix header on history pages when custom site_header is used (gh-448)
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

barm
barm previously approved these changes Oct 18, 2018
@rossmechanic
Copy link
Collaborator

Just need to fix conflict and I'll merge @tbeadle

@rossmechanic
Copy link
Collaborator

Hey @tbeadle. We had some weirdness with codecov and travis, but everything seems to be working now. If you want to resolve the conflicts, I'll merge

@tbeadle tbeadle force-pushed the admin-site-header branch 2 times, most recently from 0ef7a2e to 78541b0 Compare October 23, 2018 13:46
@rossmechanic
Copy link
Collaborator

@tbeadle failing some flake8 style tests. Want to fix those? And then I'll merge

@tbeadle
Copy link
Contributor Author

tbeadle commented Oct 24, 2018

The flake8 failures seem to be due to the new version of flake8 that was released 11 hours ago. I'm guessing it may have something to do with https://gitlab.com/pycqa/flake8/merge_requests/230. The new version doesn't allow for line breaks around a binary operator, which makes formatting those 2 lines pretty ugly or require putting in an ignore pragma.

Copy link
Collaborator

@rossmechanic rossmechanic left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @tbeadle . @barm want to give it a second run through and then I'll merge?

@barm
Copy link
Collaborator

barm commented Oct 25, 2018

Checking now

@@ -51,6 +51,7 @@ Authors
- Ross Rogers
- Steven Klass
- Steeve Chailloux
- Tommy Beadle (@tbeadle)
Copy link
Collaborator

Choose a reason for hiding this comment

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

🍾

@rossmechanic rossmechanic merged commit 05d47dc into jazzband:master Oct 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DjangoConUS2018 Work resulting from DjangoConUS2018 sprint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

admin.site.site_header not respected
4 participants