Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v6

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v6
with:
python-version: '3.8'
python-version: '3.14'
architecture: 'x64'

- name: Install dependencies
Expand Down
89 changes: 77 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,33 @@ name: Linter and tests
on: [push, pull_request]

jobs:
build:
build-python:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
django-version: ['2.2', '3.2']
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
django-version: ['5.2', '6.0']
exclude:
- python-version: '3.10'
django-version: '6.0'
- python-version: '3.11'
django-version: '6.0'

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v6

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 codecov
pip install pre-commit codecov

- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Lint with pre-commit
run: pre-commit run --all-files --show-diff-on-failure

- name: Install Django ${{ matrix.django-version }}
run: pip install django==${{ matrix.django-version }}
Expand All @@ -49,4 +50,68 @@ jobs:
coverage xml

- name: Upload coverage to Codecov
if: ${{ !env.ACT }}
uses: codecov/codecov-action@v1

build-django:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- python-version: '3.10'
django-version: '5.2'
- python-version: '3.11'
django-version: '5.2'
- python-version: '3.12'
django-version: '5.2'
- python-version: '3.13'
django-version: '5.2'
- python-version: '3.12'
django-version: '6.0'
- python-version: '3.13'
django-version: '6.0'
- python-version: '3.14'
django-version: '6.0'

steps:
- uses: actions/checkout@v6

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pre-commit codecov

- name: Lint with pre-commit
run: pre-commit run --all-files --show-diff-on-failure

- name: Install Django ${{ matrix.django-version }}
run: pip install django==${{ matrix.django-version }}

- name: Install matching django-userforeignkey dependency
run: |
pip install "django-userforeignkey>=0.6.1"

- name: Install package and dependencies
run: pip install -e . --no-deps

- name: Run tests
run: |
# prepare Django application
ln -s ./tests/test_project/test_project test_project
ln -s ./tests/test_project/manage.py manage.py

# run tests with coverage
coverage run \
--source='./django_changeset' \
--omit='./anexia_monitoring/migrations/*' \
manage.py test
coverage xml

- name: Upload coverage to Codecov
if: ${{ !env.ACT }}
uses: codecov/codecov-action@v1
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ venv/
build/
.idea/
db.sqlite3
.actrc
27 changes: 27 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: check-merge-conflict
- id: end-of-file-fixer
- id: requirements-txt-fixer
- id: trailing-whitespace
args: ["--markdown-linebreak-ext=md"]

- repo: https://github.com/asottile/pyupgrade
rev: v3.21.2
hooks:
- id: pyupgrade
args: ["--py310-plus"]

- repo: https://github.com/asottile/add-trailing-comma
rev: v4.0.0
hooks:
- id: add-trailing-comma

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.4
hooks:
- id: ruff
args: ["--fix"]
- id: ruff-format
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
include LICENSE
include README.rst
recursive-include docs *
recursive-include docs *
38 changes: 16 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
Django ChangeSet
================
# Django ChangeSet

[![Linter and tests](https://github.com/beachmachine/django-changeset/workflows/Linter%20and%20tests/badge.svg)](https://github.com/beachmachine/django-changeset/actions)
[![Codecov](https://img.shields.io/codecov/c/gh/beachmachine/django-changeset)](https://codecov.io/gh/beachmachine/django-changeset)

Django ChangeSet is a simple Django app that will give your models the possibility to track all changes. It depends on
`django_userforeignkey` to determine the current user doing the change(s).

Currently, Django 2.2 and 3.2 are supported and tested via GitHub Actions.
Supported Python versions: 3.10 - 3.14.
Supported Django versions: 5.2 and 6.0.

Detailed documentation is in the docs subdirectory.

Quick start
-----------
## Quick start

1. Use `pip` to install and download django-changeset (and `django-userforeignkey`):

Expand Down Expand Up @@ -43,10 +42,9 @@ MIDDLEWARE = (

**Note**: Make sure to insert the `UserForeignKeyMiddleware` **after** Djangos `AuthenticationMiddleware`.

Example usage
-------------
## Example usage

***Use `RevisionModelMixin` as a mixin class for your models and add the fields you want to track in the meta***
**_Use `RevisionModelMixin` as a mixin class for your models and add the fields you want to track in the meta_**
configuration using `track_fields` and `track_related`. Also add a generic relation to `ChangeSet` using
`changesets = ChangeSetRelation()`:

Expand Down Expand Up @@ -102,19 +100,17 @@ class MyModel(BaseModel, RevisionModelMixin, CreatedModifiedByMixin):
changesets = ChangeSetRelation()
```

Querying ChangeSets via the changesets relation
-----------------------------------------------
## Querying ChangeSets via the changesets relation

By inheriting from the `RevisionModelMixin` and `CreatedModifiedByMixin` mixins, and adding an attribute of type
`ChangeSetRelation` (a `GenericRelation` for the changeset), the following features are added to your model:

- Properties `created_by`, `created_at`, `last_modified_by`, `last_modified_at` are made available for each object
(`CreatedModifiedByMixin`)
- Relation `changesets` is made available, allowing you to run queries like this one:
`MyModel.objects.filter(changesets__changeset_type='I', changesets__user__username='johndoe')`
- Properties `created_by`, `created_at`, `last_modified_by`, `last_modified_at` are made available for each object
(`CreatedModifiedByMixin`)
- Relation `changesets` is made available, allowing you to run queries like this one:
`MyModel.objects.filter(changesets__changeset_type='I', changesets__user__username='johndoe')`

Access ChangeSets and ChangeRecords
-----------------------------------
## Access ChangeSets and ChangeRecords

ToDo

Expand Down Expand Up @@ -143,17 +139,15 @@ for change_set in somemodel.changesets:
print("-----")
```

Maintainers
-----------
## Maintainers

This repository is currently maintained by

- beachmachine
- anx-mpoelzl
- beachmachine
- mikelandzelo173

Pull Requests are welcome.

License
-------
## License

Django ChangeSet uses the BSD-3 Clause License, see LICENSE file.
1 change: 0 additions & 1 deletion django_changeset/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
# -*- coding: utf-8 -*-
Loading