diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..9697182 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,64 @@ +name: Tests and PyPI publishing + +on: + push: + branches: + - main + tags: + - '*' + pull_request: + workflow_dispatch: + +jobs: + tests: + name: Run tests Python ${{ matrix.python }}, Django ${{ matrix.django }}) + runs-on: ubuntu-latest + strategy: + matrix: + python: ['3.8', '3.9', '3.10', '3.11'] + django: ['3.2', '4.1', '4.2'] + exclude: + - python: '3.11' + django: '3.2' + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + + - name: Install dependencies + run: pip install tox tox-gh-actions pip install -r requirements.txt + + - name: Run tests + run: tox + env: + PYTHON_VERSION: ${{ matrix.python }} + DJANGO: ${{ matrix.django }} + + - name: Publish coverage report + uses: codecov/codecov-action@v3 + + publish: + name: Publish package to PyPI + runs-on: ubuntu-latest + needs: + - tests + + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Build sdist and wheel + run: | + pip install pip setuptools wheel --upgrade + python setup.py sdist bdist_wheel + - name: Publish a Python distribution to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml new file mode 100644 index 0000000..f8aa87e --- /dev/null +++ b/.github/workflows/code-quality.yml @@ -0,0 +1,34 @@ +name: Linting and code quality + +on: + push: + branches: + - main + tags: + paths: + - '**.py' + - .github/workflows/code_quality.yml + pull_request: + paths: + - '**.py' + - .github/workflows/code_quality.yml + workflow_dispatch: + +jobs: + linting: + name: Code-quality checks + runs-on: ubuntu-latest + strategy: + matrix: + toxenv: + - isort + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + - name: Install dependencies + run: pip install tox + - run: tox + env: + TOXENV: ${{ matrix.toxenv }} \ No newline at end of file diff --git a/README.md b/README.md index a393460..4b649f2 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,8 @@ Better ArrayField widget for admin -Supported Python versions: 3.5, 3.6, 3.7 -Supported Django versions: 1.11, 2.0, 2.1, 2.2 +Supported Python versions: |python-versions| +Supported Django versions: |django-versions| It changes comma separated widget to list based in admin panel. @@ -87,3 +87,30 @@ Tools used in rendering this - [Cookiecutter](https://github.com/audreyr/cookiecutter) - [cookiecutter-djangopackage](https://github.com/pydanny/cookiecutter-djangopackage) + + +.. |build-status| image:: https://github.com/maykinmedia/{{ project_name }}/workflows/Run%20CI/badge.svg + :alt: Build status + :target: https://github.com/maykinmedia/{{ project_name }}/actions?query=workflow%3A%22Run+CI%22 + +.. |code-quality| image:: https://github.com/maykinmedia/{{ project_name }}/workflows/Code%20quality%20checks/badge.svg + :alt: Code quality checks + :target: https://github.com/maykinmedia/{{ project_name }}/actions?query=workflow%3A%22Code+quality+checks%22 + +.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg + :target: https://github.com/psf/black + +.. |coverage| image:: https://codecov.io/gh/maykinmedia/{{ project_name }}/branch/master/graph/badge.svg + :target: https://codecov.io/gh/maykinmedia/{{ project_name }} + :alt: Coverage status + +.. |docs| image:: https://readthedocs.org/projects/{{ project_name }}/badge/?version=latest + :target: https://{{ project_name }}.readthedocs.io/en/latest/?badge=latest + :alt: Documentation Status + +.. |python-versions| image:: https://img.shields.io/pypi/pyversions/{{ project_name }}.svg + +.. |django-versions| image:: https://img.shields.io/pypi/djversions/{{ project_name }}.svg + +.. |pypi-version| image:: https://img.shields.io/pypi/v/{{ project_name }}.svg + :target: https://pypi.org/project/{{ project_name }}/ diff --git a/django_better_admin_arrayfield/__init__.py b/django_better_admin_arrayfield/__init__.py index 64e5418..0a738e0 100644 --- a/django_better_admin_arrayfield/__init__.py +++ b/django_better_admin_arrayfield/__init__.py @@ -1,3 +1,3 @@ from pkg_resources import get_distribution -__version__ = get_distribution('maykin-django-better-admin-arrayfield').version +__version__ = get_distribution("maykin-django-better-admin-arrayfield").version diff --git a/django_better_admin_arrayfield/forms/fields.py b/django_better_admin_arrayfield/forms/fields.py index 8fbf421..d3074c8 100644 --- a/django_better_admin_arrayfield/forms/fields.py +++ b/django_better_admin_arrayfield/forms/fields.py @@ -2,11 +2,11 @@ from django import forms from django.contrib.postgres.utils import prefix_validation_error + from django_better_admin_arrayfield.forms.widgets import DynamicArrayWidget class DynamicArrayField(forms.Field): - default_error_messages = {"item_invalid": "Item %(nth)s in the array did not validate: "} def __init__(self, base_field, **kwargs): diff --git a/django_better_admin_arrayfield/forms/widgets.py b/django_better_admin_arrayfield/forms/widgets.py index ad0b459..7dfa080 100644 --- a/django_better_admin_arrayfield/forms/widgets.py +++ b/django_better_admin_arrayfield/forms/widgets.py @@ -2,7 +2,6 @@ class DynamicArrayWidget(forms.TextInput): - template_name = "django_better_admin_arrayfield/forms/widgets/dynamic_array.html" def get_context(self, name, value, attrs): diff --git a/manage.py b/manage.py index 8c5be8a..404ea64 100644 --- a/manage.py +++ b/manage.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from __future__ import unicode_literals, absolute_import +from __future__ import absolute_import, unicode_literals import os import sys diff --git a/requirements.txt b/requirements.txt index 6c5f666..c734c59 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -django>=2.0,<2.3 +django>=4.2,<4.3 diff --git a/requirements_dev.txt b/requirements_dev.txt index 00772a5..361edff 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,3 +1,3 @@ -bumpversion==0.5.3 -wheel==0.30.0 -pre-commit==1.14.4 +bumpversion==0.6.0 +wheel==0.40.0 +pre-commit==3.3.3 diff --git a/requirements_test.txt b/requirements_test.txt index d9af71d..136ba36 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,8 +1,8 @@ -coverage==4.4.1 -flake8>=2.1.0 -tox>=1.7.0 -codecov>=2.0.0 -pytest==4.3.0 -pytest-django==3.4.7 -pytest-cov==2.6.1 -pytest-mock==1.10.1 +coverage==7.2.7 +flake8>=6.0.0 +tox>=4.6.3 +codecov>=2.1.13 +pytest==7.4.0 +pytest-django==4.5.2 +pytest-cov==4.1.0 +pytest-mock==3.11.1 diff --git a/sample_project/sample_app/admin.py b/sample_project/sample_app/admin.py index c1cfa16..8e05845 100644 --- a/sample_project/sample_app/admin.py +++ b/sample_project/sample_app/admin.py @@ -1,9 +1,8 @@ from django.contrib import admin +from sample_app.models import ArrayModel from django_better_admin_arrayfield.admin.mixins import DynamicArrayMixin -from sample_app.models import ArrayModel - class ArrayModelAdmin(admin.ModelAdmin, DynamicArrayMixin): pass diff --git a/sample_project/sample_app/migrations/0001_initial.py b/sample_project/sample_app/migrations/0001_initial.py index 53b4de1..5534c32 100644 --- a/sample_project/sample_app/migrations/0001_initial.py +++ b/sample_project/sample_app/migrations/0001_initial.py @@ -1,6 +1,7 @@ # Generated by Django 2.2.5 on 2019-09-29 18:03 from django.db import migrations, models + import django_better_admin_arrayfield.models.fields diff --git a/sample_project/sample_app/migrations/0002_auto_20190929_1805.py b/sample_project/sample_app/migrations/0002_auto_20190929_1805.py index baa81e7..d3a15cc 100644 --- a/sample_project/sample_app/migrations/0002_auto_20190929_1805.py +++ b/sample_project/sample_app/migrations/0002_auto_20190929_1805.py @@ -1,6 +1,7 @@ # Generated by Django 2.2.5 on 2019-09-29 18:05 from django.db import migrations, models + import django_better_admin_arrayfield.models.fields diff --git a/setup.cfg b/setup.cfg index 7dd7d1d..304944f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.0.5 +current_version = 1.0.6 commit = True tag = True diff --git a/setup.py b/setup.py index 0eb0220..3a060d8 100755 --- a/setup.py +++ b/setup.py @@ -2,7 +2,6 @@ from setuptools import setup - with open("README.md") as f: readme = f.read() @@ -20,21 +19,23 @@ url="https://github.com/maykinmedia/django-better-admin-arrayfield", packages=["django_better_admin_arrayfield"], include_package_data=True, - install_requires=[], license="MIT", zip_safe=False, keywords="django-better-admin-arrayfield", classifiers=[ "Development Status :: 5 - Production/Stable", - "Framework :: Django :: 2.0", - "Framework :: Django :: 2.1", - "Framework :: Django :: 2.2", + "Framework :: Django :: 3.2", + "Framework :: Django :: 4.1", + "Framework :: Django :: 4.2", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", ], + install_requires=[ + "Django>=3.2", + ] ) diff --git a/tests/test_fields.py b/tests/test_fields.py index 6987692..acd9dfe 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -1,8 +1,8 @@ import pytest +from django.forms import ValidationError +from django.forms.fields import CharField from django_better_admin_arrayfield.forms.fields import DynamicArrayField -from django.forms.fields import CharField -from django.forms import ValidationError def test_field_not_required(): diff --git a/tests/urls.py b/tests/urls.py index 3baeef3..3cd36e5 100644 --- a/tests/urls.py +++ b/tests/urls.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals, absolute_import - -from django.conf.urls import url, include +from __future__ import absolute_import, unicode_literals +from django.conf.urls import include, url urlpatterns = [url(r"^", include("django_better_admin_arrayfield.urls", namespace="django_better_admin_arrayfield"))] diff --git a/tox.ini b/tox.ini index 2132836..aa06feb 100644 --- a/tox.ini +++ b/tox.ini @@ -1,14 +1,14 @@ [tox] envlist = - django{111,2,21,22}-{py35,py36,py37}, + py{38,39,310}-django{32,41,42} + py311-django{41,42} flake8 [testenv] deps = - django111: Django<2.0 - django2: Django<2.1 - django21: Django<2.2 - django22: Django<3.0 + django32: Django~=3.2.0 + django41: Django~=4.1.0 + django42: Django~=4.2.0 -r{toxinidir}/requirements_test.txt setenv = PYTHONPATH = {toxinidir}:{toxinidir}/django_better_admin_arrayfield