Skip to content
Open
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
64 changes: 64 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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 }}
34 changes: 34 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -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 }}
31 changes: 29 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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 }}/
2 changes: 1 addition & 1 deletion django_better_admin_arrayfield/__init__.py
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion django_better_admin_arrayfield/forms/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
1 change: 0 additions & 1 deletion django_better_admin_arrayfield/forms/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion manage.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
django>=2.0,<2.3
django>=4.2,<4.3
6 changes: 3 additions & 3 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -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
16 changes: 8 additions & 8 deletions requirements_test.txt
Original file line number Diff line number Diff line change
@@ -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
3 changes: 1 addition & 2 deletions sample_project/sample_app/admin.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions sample_project/sample_app/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
Original file line number Diff line number Diff line change
@@ -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


Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.0.5
current_version = 1.0.6
commit = True
tag = True

Expand Down
19 changes: 10 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from setuptools import setup


with open("README.md") as f:
readme = f.read()

Expand All @@ -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",
]
)
4 changes: 2 additions & 2 deletions tests/test_fields.py
Original file line number Diff line number Diff line change
@@ -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():
Expand Down
5 changes: 2 additions & 3 deletions tests/urls.py
Original file line number Diff line number Diff line change
@@ -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"))]
10 changes: 5 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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
Expand Down