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

Passing multiple template names to the templating engine. Django will… #920

Open
wants to merge 49 commits into
base: master
Choose a base branch
from

Conversation

benf710
Copy link

@benf710 benf710 commented Nov 23, 2021

Description

This passes the Django default admin template override paths to the views in order so that a user can override the django admin templates used in this project.

Related Issue

This resolves #919.

Motivation and Context

How Has This Been Tested?

Tested with a Django app to override the object_history.html template per the Django documentation

Screenshots (if appropriate):

Types of changes

This change does not introduce any breaking changes in any version of Django >= 1.10. It allows the end user implementing this library to implement custom templates in their own project per Django documentation: https://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-admin-templates

Checklist:

  • I have run the pre-commit run command to format and lint.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • [ x ] I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have added my name and/or github handle to AUTHORS.rst
  • I have added my change to CHANGES.rst
  • All new and existing tests passed.

benf710 and others added 2 commits November 22, 2021 20:17
… try them in order until one of them resolves and will use that one.
@jeking3
Copy link
Contributor

jeking3 commented Jan 28, 2022

@benf710 maybe rebasing this on master will help?

Copy link
Contributor

@jeking3 jeking3 left a comment

Choose a reason for hiding this comment

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

CI broke with the changes.

@@ -20,9 +20,6 @@


class SimpleHistoryAdmin(admin.ModelAdmin):
object_history_template = "simple_history/object_history.html"
object_history_form_template = "simple_history/object_history_form.html"
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on CI, something depends on this (could just be tests - didn't look).

benf710 and others added 25 commits March 27, 2022 15:49
… try them in order until one of them resolves and will use that one.
updates:
- [github.com/psf/black: 21.11b1 → 21.12b0](psf/black@21.11b1...21.12b0)
Bumps [black](https://github.com/psf/black) from 21.11b1 to 21.12b0.
- [Release notes](https://github.com/psf/black/releases)
- [Changelog](https://github.com/psf/black/blob/main/CHANGES.md)
- [Commits](https://github.com/psf/black/commits)

---
updated-dependencies:
- dependency-name: black
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
updates:
- [github.com/pre-commit/pre-commit-hooks: v4.0.1 → v4.1.0](pre-commit/pre-commit-hooks@v4.0.1...v4.1.0)
Bumps [sphinx](https://github.com/sphinx-doc/sphinx) from 4.3.1 to 4.3.2.
- [Release notes](https://github.com/sphinx-doc/sphinx/releases)
- [Changelog](https://github.com/sphinx-doc/sphinx/blob/4.x/CHANGES)
- [Commits](sphinx-doc/sphinx@v4.3.1...v4.3.2)

---
updated-dependencies:
- dependency-name: sphinx
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [tox](https://github.com/tox-dev/tox) from 3.24.4 to 3.24.5.
- [Release notes](https://github.com/tox-dev/tox/releases)
- [Changelog](https://github.com/tox-dev/tox/blob/master/docs/changelog.rst)
- [Commits](tox-dev/tox@3.24.4...3.24.5)

---
updated-dependencies:
- dependency-name: tox
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [psycopg2-binary](https://github.com/psycopg/psycopg2) from 2.9.2 to 2.9.3.
- [Release notes](https://github.com/psycopg/psycopg2/releases)
- [Changelog](https://github.com/psycopg/psycopg2/blob/master/NEWS)
- [Commits](https://github.com/psycopg/psycopg2/commits)

---
updated-dependencies:
- dependency-name: psycopg2-binary
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [tox-gh-actions](https://github.com/ymyzk/tox-gh-actions) from 2.8.1 to 2.9.1.
- [Release notes](https://github.com/ymyzk/tox-gh-actions/releases)
- [Commits](ymyzk/tox-gh-actions@v2.8.1...v2.9.1)

---
updated-dependencies:
- dependency-name: tox-gh-actions
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [sphinx](https://github.com/sphinx-doc/sphinx) from 4.3.2 to 4.4.0.
- [Release notes](https://github.com/sphinx-doc/sphinx/releases)
- [Changelog](https://github.com/sphinx-doc/sphinx/blob/4.x/CHANGES)
- [Commits](sphinx-doc/sphinx@v4.3.2...v4.4.0)

---
updated-dependencies:
- dependency-name: sphinx
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
This changes `as_of` to return a QuerySet instead of a list of instances
so that further filtering can be applied to the history.
Bumps [coverage](https://github.com/nedbat/coveragepy) from 6.2 to 6.3.
- [Release notes](https://github.com/nedbat/coveragepy/releases)
- [Changelog](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst)
- [Commits](nedbat/coveragepy@6.2...6.3)

---
updated-dependencies:
- dependency-name: coverage
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [coverage](https://github.com/nedbat/coveragepy) from 6.3 to 6.3.1.
- [Release notes](https://github.com/nedbat/coveragepy/releases)
- [Changelog](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst)
- [Commits](nedbat/coveragepy@6.3...6.3.1)

---
updated-dependencies:
- dependency-name: coverage
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
hramezani and others added 21 commits March 31, 2022 21:26
Bumps [black](https://github.com/psf/black) from 21.12b0 to 22.1.0.
- [Release notes](https://github.com/psf/black/releases)
- [Changelog](https://github.com/psf/black/blob/main/CHANGES.md)
- [Commits](https://github.com/psf/black/commits/22.1.0)

---
updated-dependencies:
- dependency-name: black
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
updates:
- [github.com/PyCQA/bandit: 1.7.1 → 1.7.2](PyCQA/bandit@1.7.1...1.7.2)
- [github.com/psf/black: 21.12b0 → 22.1.0](psf/black@21.12b0...22.1.0)
Bumps [coverage](https://github.com/nedbat/coveragepy) from 6.3.1 to 6.3.2.
- [Release notes](https://github.com/nedbat/coveragepy/releases)
- [Changelog](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst)
- [Commits](nedbat/coveragepy@6.3.1...6.3.2)

---
updated-dependencies:
- dependency-name: coverage
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
updates:
- [github.com/PyCQA/bandit: 1.7.2 → 1.7.4](PyCQA/bandit@1.7.2...1.7.4)
* implemented a register setting that allows you to drop db_index on history models, tests are also added
* updated text files as required by contributing
* ran make format

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Jim King <[email protected]>
Shortcoming of previous architecture:
Recording reason for change was only through manually setting to each object or through bulk_history_create.
So recording API request as reason automatically was hard to implement with this architecture.

Solution:
Getting change reason is now done through `HistoricalRecords` method `get_change_reason_for_object`.
And thus this method can be overriden in subclass to define custom behavior.
…tom-admin-templates

# Conflicts:
#	.github/workflows/test.yml
#	.pre-commit-config.yaml
#	CHANGES.rst
#	README.rst
#	docs/historical_model.rst
#	docs/index.rst
#	docs/querying_history.rst
#	requirements/coverage.txt
#	requirements/docs.txt
#	requirements/lint.txt
#	requirements/postgres.txt
#	requirements/tox.txt
#	setup.py
#	simple_history/admin.py
#	simple_history/models.py
#	simple_history/tests/tests/test_models.py
#	tox.ini
Sync fork master branch
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.

Allow Overriding admin templates
7 participants