mirror of
https://github.com/jazzband/django-auditlog.git
synced 2026-05-05 22:24:44 +00:00
Merge tox & CI changes from upstream master
This commit is contained in:
commit
03920f2874
20 changed files with 23 additions and 40 deletions
8
.github/workflows/release.yml
vendored
8
.github/workflows/release.yml
vendored
|
|
@ -11,22 +11,22 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
uses: actions/setup-python@v3
|
||||
with:
|
||||
python-version: 3.8
|
||||
|
||||
- name: Get pip cache dir
|
||||
id: pip-cache
|
||||
run: |
|
||||
echo "::set-output name=dir::$(pip cache dir)"
|
||||
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Cache
|
||||
uses: actions/cache@v2
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ steps.pip-cache.outputs.dir }}
|
||||
key: release-${{ hashFiles('**/setup.py') }}
|
||||
|
|
|
|||
10
.github/workflows/test.yml
vendored
10
.github/workflows/test.yml
vendored
|
|
@ -27,20 +27,20 @@ jobs:
|
|||
--health-retries 5
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v2
|
||||
uses: actions/setup-python@v3
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- name: Get pip cache dir
|
||||
id: pip-cache
|
||||
run: |
|
||||
echo "::set-output name=dir::$(pip cache dir)"
|
||||
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Cache
|
||||
uses: actions/cache@v2
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ steps.pip-cache.outputs.dir }}
|
||||
key:
|
||||
|
|
@ -64,6 +64,6 @@ jobs:
|
|||
TEST_DB_PORT: ${{ job.services.postgres.ports[5432] }}
|
||||
|
||||
- name: Upload coverage
|
||||
uses: codecov/codecov-action@v1
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
name: Python ${{ matrix.python-version }}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
repos:
|
||||
- repo: https://github.com/psf/black
|
||||
rev: 22.12.0
|
||||
rev: 23.3.0
|
||||
hooks:
|
||||
- id: black
|
||||
language_version: python3.8
|
||||
|
|
@ -14,16 +14,16 @@ repos:
|
|||
- id: flake8
|
||||
args: ["--max-line-length", "110"]
|
||||
- repo: https://github.com/PyCQA/isort
|
||||
rev: v5.11.3
|
||||
rev: 5.12.0
|
||||
hooks:
|
||||
- id: isort
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v3.3.1
|
||||
rev: v3.8.0
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
args: [--py37-plus]
|
||||
- repo: https://github.com/adamchainz/django-upgrade
|
||||
rev: 1.12.0
|
||||
rev: 1.14.0
|
||||
hooks:
|
||||
- id: django-upgrade
|
||||
args: [--target-version, "3.2"]
|
||||
|
|
|
|||
|
|
@ -2,9 +2,8 @@ from django.apps import apps
|
|||
from django.contrib.admin import SimpleListFilter
|
||||
from django.contrib.admin.filters import DateFieldListFilter
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.contrib.postgres.fields import JSONField
|
||||
from django.db import connection
|
||||
from django.db.models import Value
|
||||
from django.db.models import JSONField, Value
|
||||
from django.db.models.functions import Cast, Concat
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
|
@ -33,8 +32,7 @@ class ResourceTypeFilter(SimpleListFilter):
|
|||
|
||||
def lookups(self, request, model_admin):
|
||||
tracked_model_names = [
|
||||
"{}.{}".format(m._meta.app_label, m._meta.model_name)
|
||||
for m in auditlog.get_models()
|
||||
f"{m._meta.app_label}.{m._meta.model_name}" for m in auditlog.get_models()
|
||||
]
|
||||
model_name_concat = Concat("app_label", Value("."), "model")
|
||||
content_types = ContentType.objects.annotate(
|
||||
|
|
@ -82,7 +80,7 @@ class FieldFilter(SimpleListFilter):
|
|||
if self.value() is None:
|
||||
return queryset
|
||||
return queryset.annotate(changes_json=Cast("changes", JSONField())).filter(
|
||||
**{"changes_json__{}__isnull".format(self.value()): False}
|
||||
**{f"changes_json__{self.value()}__isnull": False}
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
("contenttypes", "0001_initial"),
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("auditlog", "0001_initial"),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("auditlog", "0002_auto_support_long_primary_keys"),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("auditlog", "0003_logentry_remote_addr"),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("auditlog", "0004_logentry_detailed_object_repr"),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("auditlog", "0005_logentry_additional_data_verbose_name"),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("auditlog", "0006_object_pk_index"),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("auditlog", "0007_object_pk_type"),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("auditlog", "0008_timestamp_index"),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("auditlog", "0009_timestamp_id_index"),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("auditlog", "0010_action_index"),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("auditlog", "0011_alter_logentry_additional_data"),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -166,14 +166,14 @@ class LogEntryAdminMixin:
|
|||
ahead_behind = "ahead of" if offset_seconds < 0 else "behind"
|
||||
offset_seconds = abs(offset_seconds)
|
||||
hours, minutes = divmod(int(offset_seconds / 60), 60)
|
||||
hours = "{} hour{}".format(hours, pluralize(hours))
|
||||
minutes = " {} minute{}".format(minutes, pluralize(minutes)) if minutes else ""
|
||||
hours = f"{hours} hour{pluralize(hours)}"
|
||||
minutes = f" {minutes} minute{pluralize(minutes)}" if minutes else ""
|
||||
warning_message = (
|
||||
"Note: The timestamps are in UTC, which is {}{} {} server time".format(
|
||||
hours, minutes, ahead_behind
|
||||
)
|
||||
)
|
||||
return '<span class="timezonewarning">{}</span>'.format(warning_message)
|
||||
return f'<span class="timezonewarning">{warning_message}</span>'
|
||||
|
||||
def field_verbose_name(self, obj, field_name: str):
|
||||
model = obj.content_type.model_class()
|
||||
|
|
|
|||
|
|
@ -92,7 +92,6 @@ def log_access(sender, instance, **kwargs):
|
|||
Direct use is discouraged, connect your model through :py:func:`auditlog.registry.register` instead.
|
||||
"""
|
||||
if instance.pk is not None:
|
||||
|
||||
LogEntry.objects.log_create(
|
||||
instance,
|
||||
action=LogEntry.Action.ACCESS,
|
||||
|
|
|
|||
2
setup.py
2
setup.py
|
|
@ -43,8 +43,8 @@ setup(
|
|||
"Programming Language :: Python :: 3.11",
|
||||
"Framework :: Django",
|
||||
"Framework :: Django :: 3.2",
|
||||
"Framework :: Django :: 4.0",
|
||||
"Framework :: Django :: 4.1",
|
||||
"Framework :: Django :: 4.2",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
],
|
||||
)
|
||||
|
|
|
|||
6
tox.ini
6
tox.ini
|
|
@ -1,8 +1,8 @@
|
|||
[tox]
|
||||
envlist =
|
||||
{py37,py38,py39,py310}-django32
|
||||
{py38,py39,py310}-django40
|
||||
{py38,py39,py310,py311}-django{41,main}
|
||||
{py38,py39,py310,py311}-django{41,42}
|
||||
{py310,py311}-djangomain
|
||||
py37-docs
|
||||
py38-lint
|
||||
|
||||
|
|
@ -14,8 +14,8 @@ commands =
|
|||
coverage xml
|
||||
deps =
|
||||
django32: Django>=3.2,<3.3
|
||||
django40: Django>=4.0,<4.1
|
||||
django41: Django>=4.1,<4.2
|
||||
django42: Django>=4.2,<4.3
|
||||
djangomain: https://github.com/django/django/archive/main.tar.gz
|
||||
# Test requirements
|
||||
coverage
|
||||
|
|
|
|||
Loading…
Reference in a new issue