Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
- add typing
- add hatch version management
- add github actions
  • Loading branch information
saxix committed Feb 7, 2025
1 parent 14ad0d4 commit 43ccc68
Show file tree
Hide file tree
Showing 20 changed files with 923 additions and 207 deletions.
16 changes: 0 additions & 16 deletions .bumpversion.cfg

This file was deleted.

56 changes: 36 additions & 20 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,47 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ "3.10", "3.11", "3.12" ]
django-version: [ "3.2", "4.2", "5.0" ]
# python-version: [ "3.10", "3.11", "3.12" ]
# django-version: [ "3.2", "4.2", "5.0" ]
python-version: [ "312" ]
django-version: [ "51" ]
env:
PY_VER: ${{ matrix.python-version}}
DJ_VER: ${{ matrix.django-version}}
CELERY_BROKER_URL: redis://redis:6379/0
CELERY_ALWAYS_EAGER: true
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install tox
run: uv tool install --python-preference only-managed --python 3.13 tox --with tox-uv

- name: Install dependencies
run: python -m pip install --upgrade pip .[test] "django==${DJ_VER}.*"

- name: Test with
run: py.test tests/ -v

- uses: codecov/codecov-action@v1
with:
# files: ./coverage1.xml,./coverage2.xml # optional
# flags: unittests # optional
# name: codecov-umbrella # optional
# fail_ci_if_error: true # optional (default = false)
verbose: true # optional (default = false)
- name: Install Python
if: matrix.python-version != '3.13'
run: uv python install --python-preference only-managed ${{ matrix.python-version}}

- name: Setup test suite ${{ env.DJ_VER }}-${{ env.PY_VER }}
run: tox run -vv --notest --skip-missing-interpreters false -e d${{ env.DJ_VER }}-py${{ env.PY_VER }}

- name: Run test suite
run:
COV_CMD=$(if [${{ env.DJ_VER }}-${{ env.PY_VER }}} == 51-312 ]; then echo "--cov=pytest_echo --cov-report=xml"; else echo ; fi)
tox run --skip-pkg-install -e d${{ env.DJ_VER }}-py${{ env.PY_VER }} $COV_CMD
env:
PYTEST_ADDOPTS: "-vv --durations=20"
DIFF_AGAINST: HEAD
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
if: ${{ success() && matrix.python-version == 3.13 }}
with:
env_vars: OS
name: codecov-pytest-order
token: ${{ secrets.CODECOV_TOKEN }}
7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@
*.pyc
*.egg-info
*.sqlite
src/adminactions/version.py
/dist
/build
/docs/build
/MANIFEST
coverage.xml
sonar-project.properties
.scannerwork
Pipfile
Pipfile.lock
poetry.lock
.venv/
pdm.lock
uv.lock
6 changes: 1 addition & 5 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
include README.rst
include README.md
include MANIFEST.in
include AUTHORS.rst
include CHANGES
include LICENSE
include setup.py
include setup.cfg
include tox.ini
include *.py
include Makefile

exclude .bumpversion.cfg
exclude .editorconfig
exclude manage.py
exclude .*
Expand Down
64 changes: 43 additions & 21 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
[build-system]
build-backend = "hatchling.build"
requires = [
"hatch-vcs>=0.4",
"hatchling>=1.25",
]

[project]
name = "django-adminactions"
version = "2.3.0"
description = "Collections of useful actions to use with django.contrib.admin.ModelAdmin"
readme = "README.md"
license = { text = "MIT" }
license.file = "LICENSE"
maintainers = [
{ name = "Stefano Apostolico", email = "[email protected]" },
]
authors = [
{ name = "sax", email = "[email protected]" },
]
requires-python = ">=3.11.0"
requires-python = ">=3.9"
classifiers = [
"Environment :: Web Environment",
"Framework :: Django",
Expand All @@ -17,11 +26,16 @@ classifiers = [
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]

dynamic = [
"version",
]
dependencies = [
"pytz",
"xlrd>=0.9.2",
Expand All @@ -34,23 +48,22 @@ urls.Homepage = "https://github.com/saxix/django-adminactions"

[dependency-groups]
dev = [
"black>=25.1",
"celery>=5.4",
"check-manifest>=0.50",
"django-admin-extra-urls>=4.1.1",
"django-dynamic-fixture>=4.0.1",
"django-environ>=0.12",
"django-webtest>1.9.6",
"mock>=1.0.1",
"modernize>=0.8",
"mypy>=1.15",
"pillow>=11.1",
"psycopg2>=2.9.10",
"pytest>=8.3.4",
"pytest-cache>=1",
"pytest-cov>=6",
"pytest-django>=4.9",
"pytest-echo>=1.8.1",
"celery",
"check-manifest",
"django-admin-extra-urls",
"django-dynamic-fixture",
"django-environ",
"django-webtest",
"mock",
"modernize",
"mypy",
"pillow",
"psycopg2",
"pytest",
"pytest-cache",
"pytest-cov",
"pytest-django",
"pytest-echo",
"readme>=0.7.1",
"redis>=5.2.1",
"ruff>=0.9.4",
Expand All @@ -59,9 +72,18 @@ dev = [
"tox>=4.2",
]

[tool.hatch]
build.hooks.vcs.version-file = "src/adminactions/version.py"
version.source = "vcs"

[tool.ruff]
target-version = "py311"
line-length = 120
exclude = [
"docs",
"manage.py",
"tests",
]
format.preview = true
format.docstring-code-line-length = 100
format.docstring-code-format = true
Expand Down Expand Up @@ -100,7 +122,6 @@ lint.ignore = [
"SLF",
"TRY",
"UP",

]
lint.per-file-ignores."docs/conf.py" = [
"A001", #
Expand All @@ -113,6 +134,7 @@ lint.per-file-ignores."tests/**/*.py" = [
"FBT", # don"t care about booleans as positional arguments in tests
"INP001", # no implicit namespace
"PLR2004", # Magic value used in comparison, consider replacing with a constant variable
"PT",
"S101", # asserts allowed in tests...
"S603", # `subprocess` call: check for execution of untrusted input
]
Expand Down
6 changes: 3 additions & 3 deletions src/adminactions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
VERSION = __version__ = "2.3.0"
NAME = "django-adminactions"
default_app_config = "adminactions.apps.Config"
# VERSION = __version__ = "2.3.0"
# NAME = "django-adminactions"
# default_app_config = "adminactions.apps.Config"
15 changes: 12 additions & 3 deletions src/adminactions/compat.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
from __future__ import annotations

from typing import TYPE_CHECKING

import django.db.transaction as t

if TYPE_CHECKING:
from types import TracebackType


class NoCommit(t.Atomic):
def __exit__(self, exc_type, exc_value, traceback):
super().__exit__(Exception, Exception(), None)
def __exit__(
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None
) -> None:
super().__exit__(Exception, Exception(), traceback)


def nocommit(using=None, savepoint=True, durable=False):
def nocommit(using: str | None = None, savepoint: bool = True, durable: bool = False) -> NoCommit:
return NoCommit(using, savepoint, durable)


Expand Down
8 changes: 6 additions & 2 deletions src/adminactions/templates/adminactions/bulk_update.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
{% extends "admin/change_form.html" %} {% load actions admin_modify i18n massupdate static %} {% block extrahead %}{{ block.super }}
<meta name="opts.label" content="{{ opts.label }}" />
{% endblock extrahead %} {% block breadcrumbs %}{% if not is_popup %}
{% endblock extrahead %}

{% block breadcrumbs %}{% if not is_popup %}
<div class="breadcrumbs">
<a href="../../">{% translate "Home" %}</a> &rsaquo;
<a href="../">{{ app_label|capfirst|escape }}</a> &rsaquo;
<a href=".">{{ opts.verbose_name_plural|capfirst }}</a> &rsaquo; {{ action_short_description|capfirst }}
</div>
{% endif %}{% endblock breadcrumbs %} {% block content %} {% if form.subject.errors %}
{% endif %}{% endblock breadcrumbs %}

{% block content %} {% if form.subject.errors %}
<ol>
{% for error in form.subject.errors %}
<li><strong>{{ error|escape }}</strong></li>
Expand Down
10 changes: 7 additions & 3 deletions src/adminactions/templates/adminactions/bulk_update_results.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
{% extends "admin/change_form.html" %} {% load actions admin_modify i18n massupdate static %} {% block extrahead %}{{ block.super }}
<meta name="opts.label" content="{{ opts.label }}" />
{{ media }}{% endblock extrahead %} {% block breadcrumbs %}{% if not is_popup %}
{{ media }}{% endblock extrahead %}

{% block breadcrumbs %}{% if not is_popup %}
<div class="breadcrumbs">
<a href="../../">{% translate "Home" %}</a> &rsaquo;
<a href="../">{{ opts.app_label|capfirst|escape }}</a> &rsaquo;
<a href=".">{{ opts.verbose_name_plural|capfirst }}</a> &rsaquo;
{{action_short_description|capfirst }} &rsaquo; Simulate
{{ action_short_description|capfirst }} &rsaquo; Simulate
</div>
{% endif %}{% endblock breadcrumbs %} {% block content %}
{% endif %}{% endblock breadcrumbs %}

{% block content %}
<h1>Bulk Update results {% if dry_run %}(simulated) {% endif %}</h1>
<table class="bulk-update-results">
<thead>
Expand Down
16 changes: 10 additions & 6 deletions src/adminactions/templates/adminactions/byrows_update.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,20 @@
type="text/javascript"
src="{% static 'admin/js/jquery.init.js' %}"
></script>
{% endblock extrahead %} {% block breadcrumbs %}{% if not is_popup %}
{% endblock extrahead %}

{% block breadcrumbs %}{% if not is_popup %}
<div class="breadcrumbs">
<a href="../../">{% translate "Home" %}</a> &rsaquo;
<a href="../">{{ app_label|capfirst|escape }}</a> &rsaquo;
<a href=".">{{ opts.verbose_name_plural|capfirst }}</a> &rsaquo;
{{action_short_description|capfirst }}
{{ action_short_description|capfirst }}
</div>
{% endif %}{% endblock breadcrumbs %} {% block content %} {% if formset.errors %}
{% endif %}{% endblock breadcrumbs %}

{% block content %} {% if formset.errors %}
<p class="errornote">
{% if formset.errors|length == 1 %}{% translate "Please correct the error below." %}{% else %}{% translate "Please correct the errors below." %}{%endif %}
{% if formset.errors|length == 1 %}{% translate "Please correct the error below." %}{% else %}{% translate "Please correct the errors below." %}{% endif %}
</p>
{{ adminform.form.non_field_errors }} {% endif %}
<form action="" method="post" id="update-form">
Expand All @@ -52,15 +56,15 @@
<tr class="row {% cycle 'row1' 'row2' %}">
{% for field in form.visible_fields %}
<td>
{% if forloop.first %} {% for hidden in form.hidden_fields %} {{hidden}} {% endfor %} {% endif %} {{ field.errors.as_ul }} {{ field}}
{% if forloop.first %} {% for hidden in form.hidden_fields %} {{ hidden }} {% endfor %} {% endif %} {{ field.errors.as_ul }} {{ field }}
</td>
{% endfor %}
</tr>
{% endfor %}
</table>
</div>
{{ formset.management_form }} {% for hidden in actionform.hidden_fields %}
{{hidden }} {% endfor %}
{{ hidden }} {% endfor %}
<input type="submit" name="apply" value="{% translate 'Update records' %}" />
</form>
{% endblock content %}
10 changes: 7 additions & 3 deletions src/adminactions/templates/adminactions/charts.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,18 @@
src="{% static 'adminactions/js/jqplot/plugins/jqplot.categoryAxisRenderer.min.js' %}"
></script>

{% endblock extrahead %} {% block breadcrumbs %}{% if not is_popup %}
{% endblock extrahead %}

{% block breadcrumbs %}{% if not is_popup %}
<div class="breadcrumbs">
<a href="../../">{% translate "Home" %}</a> &rsaquo;
<a href="../">{{ app_label|capfirst|escape }}</a> &rsaquo;
<a href=".">{{ opts.verbose_name_plural|capfirst }}</a> &rsaquo;
{{action_short_description|capfirst }}
{{ action_short_description|capfirst }}
</div>
{% endif %} {% endblock breadcrumbs %} {% block content %}
{% endif %} {% endblock breadcrumbs %}

{% block content %}
<div class="left">
<form action="." method="post" id="charts-form">
-{% csrf_token %}=
Expand Down
14 changes: 10 additions & 4 deletions src/adminactions/templates/adminactions/duplicates.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
{% extends "admin/change_form.html" %}{% load actions admin_modify i18n static%}
{% block extrahead %}{{ block.super }}{{ form.media }}{% endblock %} {% block breadcrumbs %}{% if not is_popup %}
{% extends "admin/change_form.html" %}{% load actions admin_modify i18n static %}
{% block extrahead %}{{ block.super }}{{ form.media }}{% endblock %}

{% block breadcrumbs %}{% if not is_popup %}
<div class="breadcrumbs">
<a href="../../">{% translate "Home" %}</a> &rsaquo;
<a href="../">{{ app_label|capfirst|escape }}</a> &rsaquo;
<a href=".">{{ opts.verbose_name_plural|capfirst }}</a> &rsaquo;
{{action_short_description|capfirst }}
{{ action_short_description|capfirst }}
</div>
{% endif %} {% endblock %} {% block coltype %}{% endblock %} {% block content %}
{% endif %} {% endblock breadcrumbs %}

{% block coltype %}{% endblock %}

{% block content %}
<div class="duplicates">
<div class="left">
{% if form %}
Expand Down
Loading

0 comments on commit 43ccc68

Please sign in to comment.