Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: soynatan/django-easy-audit
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.2rc1
Choose a base ref
...
head repository: soynatan/django-easy-audit
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing with 4,386 additions and 1,121 deletions.
  1. +78 −0 .github/workflows/cd.yml
  2. +86 −0 .github/workflows/ci.yml
  3. +4 −1 .gitignore
  4. +12 −0 .pre-commit-config.yaml
  5. +0 −60 .travis.yml
  6. +4 −0 .vscode/settings.json
  7. +130 −0 CONTRIBUTING.md
  8. +0 −4 MANIFEST.in
  9. +101 −27 README.md
  10. +0 −26 README.rst
  11. +0 −1 easyaudit/__init__.py
  12. +132 −57 easyaudit/admin.py
  13. +78 −54 easyaudit/admin_helpers.py
  14. +9 −3 easyaudit/apps.py
  15. +16 −0 easyaudit/backends.py
  16. +101 −0 easyaudit/crudhistory_admin_mixin.py
  17. BIN easyaudit/locale/de/LC_MESSAGES/django.mo
  18. +220 −0 easyaudit/locale/de/LC_MESSAGES/django.po
  19. BIN easyaudit/locale/fr/LC_MESSAGES/django.mo
  20. +190 −0 easyaudit/locale/fr/LC_MESSAGES/django.po
  21. BIN easyaudit/locale/ru/LC_MESSAGES/django.mo
  22. +191 −0 easyaudit/locale/ru/LC_MESSAGES/django.po
  23. +43 −36 easyaudit/middleware/easyaudit.py
  24. +0 −3 easyaudit/migrations/0001_initial.py
  25. +0 −2 easyaudit/migrations/0002_auto_20170125_0759.py
  26. +0 −2 easyaudit/migrations/0003_auto_20170228_1505.py
  27. +4 −6 easyaudit/migrations/0004_auto_20170620_1354.py
  28. +262 −0 ...audit/migrations/0004_auto_20170620_1354_squashed_0019_alter_crudevent_changed_fields_and_more.py
  29. +0 −2 easyaudit/migrations/0005_auto_20170713_1155.py
  30. +0 −2 easyaudit/migrations/0006_auto_20171018_1242.py
  31. +0 −2 easyaudit/migrations/0007_auto_20180105_0838.py
  32. +0 −2 easyaudit/migrations/0008_auto_20180220_1908.py
  33. +0 −2 easyaudit/migrations/0009_auto_20180314_2225.py
  34. +0 −2 easyaudit/migrations/0011_auto_20181101_1339.py
  35. +0 −2 easyaudit/migrations/0012_auto_20181018_0012.py
  36. +7 −0 easyaudit/migrations/0013_auto_20190723_0126.py
  37. +18 −0 easyaudit/migrations/0014_auto_20200513_0008.py
  38. +117 −0 easyaudit/migrations/0015_auto_20201019_1217.py
  39. +18 −0 easyaudit/migrations/0016_alter_crudevent_event_type.py
  40. +18 −0 easyaudit/migrations/0017_alter_requestevent_datetime.py
  41. +18 −0 easyaudit/migrations/0018_rename_crudevent_object_id_content_type_index.py
  42. +53 −0 easyaudit/migrations/0019_alter_crudevent_changed_fields_and_more.py
  43. +104 −49 easyaudit/models.py
  44. +140 −40 easyaudit/settings.py
  45. +57 −26 easyaudit/signals/auth_signals.py
  46. +125 −0 easyaudit/signals/crud_flows.py
  47. +166 −200 easyaudit/signals/model_signals.py
  48. +58 −24 easyaudit/signals/request_signals.py
  49. +8 −9 easyaudit/templates/admin/easyaudit/change_list.html
  50. +28 −26 easyaudit/templates/admin/easyaudit/purge_confirmation.html
  51. BIN easyaudit/tests/db.sqlite3
  52. +0 −6 easyaudit/tests/test_app/admin.py
  53. +0 −8 easyaudit/tests/test_app/backup_apps.py
  54. +0 −48 easyaudit/tests/test_app/migrations/0001_initial.py
  55. +0 −20 easyaudit/tests/test_app/migrations/0002_auto_20180220_1533.py
  56. +0 −15 easyaudit/tests/test_app/models.py
  57. +0 −140 easyaudit/tests/test_app/tests.py
  58. +0 −9 easyaudit/tests/test_app/urls.py
  59. +0 −13 easyaudit/tests/test_app/views.py
  60. 0 easyaudit/tests/test_project/__init__.py
  61. +0 −125 easyaudit/tests/test_project/settings.py
  62. +36 −12 easyaudit/utils.py
  63. +0 −3 easyaudit/views.py
  64. +1 −1 {easyaudit/tests → }/manage.py
  65. +820 −0 poetry.lock
  66. +2 −0 poetry.toml
  67. +107 −0 pyproject.toml
  68. +0 −43 setup.py
  69. +15 −0 tests/asgi.py
  70. +53 −0 tests/conftest.py
  71. +127 −0 tests/settings.py
  72. 0 {easyaudit → }/tests/test_app/__init__.py
  73. +6 −0 tests/test_app/apps.py
  74. +85 −0 tests/test_app/migrations/0001_initial.py
  75. 0 {easyaudit → }/tests/test_app/migrations/__init__.py
  76. +53 −0 tests/test_app/models.py
  77. +15 −0 tests/test_app/urls.py
  78. +48 −0 tests/test_app/views.py
  79. +412 −0 tests/test_main.py
  80. +8 −5 {easyaudit/tests/test_project → tests}/urls.py
  81. +2 −3 {easyaudit/tests/test_project → tests}/wsgi.py
78 changes: 78 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Publish Python 🐍 package 📦 to PyPI

on:
push:
branches:
- master
workflow_dispatch:

jobs:
get-package-version:
name: Get ${{ github.ref_name }} package version
runs-on: ubuntu-latest
outputs:
package-version: ${{ steps.package-version.outputs.package-version }}
version-compairson: ${{ steps.semver.outputs.comparison-result}}
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Get package version
id: package-version
run: echo "package-version=v$(poetry version --short)" >> $GITHUB_OUTPUT

- name: Get release version
id: release-version
uses: pozetroninc/github-action-get-latest-release@master
with:
repository: ${{ github.repository }}

- name: Analyze semver
id: semver
uses: madhead/semver-utils@latest
with:
lenient: false
version: ${{ steps.package-version.outputs.package-version }}
compare-to: ${{ steps.release-version.outputs.release }}

- name: Check pre-release
if: ${{ steps.semver.outputs.prerelease != '' }}
run: |
echo "Checking if version is a pre-release"
echo "::error::Skipping pre-release version: ${{ steps.package-version.outputs.package-version}}"
exit 1
deploy:
name: Deploy Python 🐍 distributions 📦 to PyPI
needs: [get-package-version]
runs-on: ubuntu-latest
if: ${{ needs.get-package-version.outputs.version-compairson != '=' }}

steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v3

- name: Build and publish to PyPI
uses: JRubics/poetry-publish@v1.13
with:
pypi_token: ${{ secrets.PYPI_API_TOKEN }}

- name: Create release ${{ needs.get-package-version.outputs.package-version }}
uses: ncipollo/release-action@v1
with:
commit: ${{ github.ref_name }}
tag: ${{ needs.get-package-version.outputs.package-version }}
generateReleaseNotes: true
artifacts: |
dist/*.whl
dist/*.tar.gz
86 changes: 86 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: CI

on:
push:
branches:
- master
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
ci:
name: CI
runs-on: ubuntu-latest
strategy:
fail-fast: true
max-parallel: 4
matrix:
python-version: [3.8, 3.9, '3.10', 3.11, 3.12]
django-version: [4.2, '5.0', 5.1]
exclude:
# Django 5.0 and 5.1 only support Python 3.10 to 3.12
- python-version: 3.8
django-version: 5.0
- python-version: 3.9
django-version: 5.0
- python-version: 3.8
django-version: 5.1
- python-version: 3.9
django-version: 5.1

steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4

- name: Setup Python ${{ matrix.python-version }}
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Load cached environment
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
id: poetry-install
run: |
poetry install --no-interaction --no-root
poetry run pip install Django==${{ matrix.django-version }}.*
echo "django_version=$(poetry run django-admin --version)" >> $GITHUB_OUTPUT
- name: Run pre-commit
run: poetry run pre-commit run --all-files

- name: Run Tests (Django ${{ steps.poetry-install.outputs.django_version }})
# enforce failing fast: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference
shell: bash
run: |
poetry run pytest \
--junitxml=pytest.xml \
--cov-report=term-missing:skip-covered \
--cov=easyaudit | tee pytest-coverage.txt
- name: Add coverage comment
uses: MishaKav/pytest-coverage-comment@main
continue-on-error: true
with:
pytest-coverage-path: ./pytest-coverage.txt
junitxml-path: ./pytest.xml
report-only-changed-files: true
title: Coverage Report
unique-id-for-comment: ${{ matrix.python-version }}
remove-link-from-badge: true
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -46,7 +46,6 @@ coverage.xml
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
@@ -79,6 +78,7 @@ celerybeat-schedule
.env

# virtualenv
.venv/
venv/
ENV/

@@ -88,3 +88,6 @@ ENV/
# Rope project settings
.ropeproject
.idea

# DB
db.sqlite3
12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.11
hooks:
- id: ruff
- id: ruff-format

- repo: https://github.com/djlint/djLint
rev: v1.34.1
hooks:
- id: djlint-reformat-django
- id: djlint-django
60 changes: 0 additions & 60 deletions .travis.yml

This file was deleted.

4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
130 changes: 130 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Contribution Guide

If you're reading this, you're likely interested in contributing to `django-easy-audit`. Thank you! This project could not continue without contributors like you.

This guide lays the foundational principles and technical documentation for contributing to this project. If you're considering adding to this project, please read this document in its entirety.

### Contributions

If your motivation is centered around a problem you're facing, please create an issue first after a search of the existing issues to ensure you aren't creating a duplicate. Issues are important as they illustrate the need and document the change process in this package.

Documentation contributions are arguably more important than writing code, so if you've found missing documentation or want to expand upon/clarify existing docs to help your fellow users, we welcome your work!

Do note that contributions that clearly fall outside the scope of this project will be declined. Please give careful thought to the nature of your idea before doing any work.

### Responsibilities

- Ensure cross-platform compatibility for every change that's accepted. Windows, Mac, Debian & Ubuntu Linux.
- Ensure that any new code you write is covered by tests.
- Create issues for any changes and enhancements. Discuss things transparently and get community feedback.
- Keep changes as small as possible to ease the burden of code review.
- Be welcoming to newcomers and encourage diverse new contributors from all backgrounds. See the [Python Community Code of Conduct](https://www.python.org/psf/codeofconduct/).

## Your First Contribution

Never contributed to open-source before? Unsure of where to begin contributing to `django-easy-audit`? You can start by looking through these resources:

- [Make a Pull Request](http://makeapullrequest.com/)
- [First Timers Only](http://www.firsttimersonly.com/)
- [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github)

If you're still unsure, feel free to ask for help! Everyone starts as a beginner.

## Making changes

For something that is bigger than a one or two line fix:

1. Create your own fork of the code.
2. Make the changes in your fork.
3. Create a pull request from your fork against the main branch.

Small contributions such as fixing spelling errors, where the content is small enough to not be considered intellectual property, can be submitted as a patch without forking.

As a rule of thumb, changes are obvious fixes if they do not introduce any new functionality or creative thinking. As long as the change does not affect functionality, some likely examples include the following:

- Spelling / grammar fixes
- Typo correction, white space and formatting changes
- Comment clean up
- Bug fixes that change default return values or error codes stored in constants
- Adding logging messages or debugging output
- Changes to ‘metadata’ files like .gitignore, build scripts, etc.
- Moving source files from one directory or package to another

## Reporting bugs

### Security vulnerabilities

If you find a security vulnerability, **DO NOT** open an issue. Email [natancalzolari@gmail.com](mailto:natancalzolari@gmail.com) instead so as to not expose the vulnerability to the public.

In order to determine whether you are dealing with a security issue, ask yourself these two questions:

- Can I access something that's not mine, or something I shouldn't have access to?
- Can I disable something for other people?

If the answer to either of those two questions are _yes_, then you're probably dealing with a security issue. Note that even if you answer _no_ to both questions, you may still be dealing with a security issue, so if you're unsure just send an email.

### Bugs

When filing an issue, make sure to answer these five questions:

1. What version of Python and Django are you using?
```
python --version
django-admin --version
```
2. What operating system and processor architecture are you using?
3. What did you do?
4. What did you expect to see?
5. What did you see instead?

### Features or enhancements

If you find yourself wishing for a feature that doesn't exist in `django-easy-audit`, you are probably not alone. There are bound to be others out there with similar needs. Many of the features that `django-easy-audit` has today have been added because our users saw the need. Open an issue on our issues list on GitHub which describes the feature you would like to see, why you need it, and how it should work.

## Setting up a development environment

This project uses the following tools.

- [Poetry](https://python-poetry.org/) for management of packaging, dependencies, and virtual environments
- [pytest](https://docs.pytest.org/) for writing tests
- [ruff](https://astral.sh/ruff) for Python source linting and formatting
- [djLint](https://www.djlint.com/) for HTML linting and formatting
- [pre-commit](https://pre-commit.com/) for Git hooks

### Installing dependencies

1. Install Python. You should use the lowest version of Python that this project supports to ensure your code changes don't include features that are only available in the latest Python version. This specifier can be found in [pyproject.toml](pyproject.toml) under `tool.poetry.dependencies.python`. The official installers can be found here: [Download Python](https://www.python.org/downloads/)
2. [Install Poetry](https://python-poetry.org/docs/#installing-with-the-official-installer). We recommend you use the official installer:

```
curl -sSL https://install.python-poetry.org | python3 -
```

Verify the installation by running `poetry --version`.

3. Navigate to the repository root and [install this package](https://python-poetry.org/docs/cli/#install) and its dependencies:

```
poetry install
```

This project is configured to create a virtual environment inside the project root (`./.venv`). The following commands may change depending on how you choose to [use the Poetry virtual environment](https://python-poetry.org/docs/basic-usage/#using-your-virtual-environment). The easiest way to do this is to simply run the `poetry shell` command to activate the environment.

4. Install pre-commit into your git hooks:

```
pre-commit install
```

### Verifying your setup

To verify that your setup is working, run the following commands:

```
pytest
ruff .
djlint .
pre-commit run --all-files
```

If any of the above processes fail, please reach out to the project maintainers for support!
Loading