diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a204852..39802c8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,23 +8,19 @@ on: jobs: test: - runs-on: ${{ matrix.os || 'ubuntu-latest' }} + runs-on: ubuntu-latest strategy: matrix: include: - - python: "3.6" - env: py36-django21 - os: ubuntu-20.04 # 3.6 is not available on ubuntu-20.04 - python: "3.8" env: py38-django21 - python: "3.9" env: py39-django21 - - python: "3.6" - env: py36-django32 - os: ubuntu-20.04 # 3.6 is not available on ubuntu-20.04 - python: "3.8" env: py38-django32 + - python: "3.9" + env: py39-django32 - python: "3.10" env: py310-django32 @@ -49,6 +45,20 @@ jobs: - python: "3.11" env: py311-django42 + - python: "3.10" + env: py310-django51 + - python: "3.11" + env: py311-django51 + - python: "3.12" + env: py312-django51 + + - python: "3.10" + env: py310-django52 + - python: "3.11" + env: py311-django52 + - python: "3.12" + env: py312-django52 + steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python }} diff --git a/build.sh b/build.sh index b7ad47e..d2c24ae 100644 --- a/build.sh +++ b/build.sh @@ -4,5 +4,4 @@ pip install build==0.9.0 # build the wheel and install it -WHEEL_NAME=$(python -m build | grep -Po "django_forbid-.*\.whl" | tail -n 1) -pip install dist/$WHEEL_NAME \ No newline at end of file +python -m build && pip install $(ls dist/django_forbid-*.whl) \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 6250003..84348e6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -38,13 +38,16 @@ classifiers = Framework :: Django :: 3.2 Framework :: Django :: 4.1 Framework :: Django :: 4.2 + Framework :: Django :: 5.1 + Framework :: Django :: 5.2 Programming Language :: Python Programming Language :: Python :: 3 - 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 + Programming Language :: Python :: 3.12 License :: OSI Approved :: MIT License [options] @@ -56,7 +59,7 @@ install_requires = geoip2 device_detector include_package_data = yes -python_requires = >=3.6 +python_requires = >=3.7 package_dir = =src zip_safe = no diff --git a/src/django_forbid/middleware.py b/src/django_forbid/middleware.py index 5946874..f9134b8 100644 --- a/src/django_forbid/middleware.py +++ b/src/django_forbid/middleware.py @@ -20,7 +20,8 @@ def __init__(self, get_response): def __call__(self, request): get_response = self.get_response - if self.regex.search(request.META.get("HTTP_ACCEPT")): + http_accept = request.META.get("HTTP_ACCEPT") + if isinstance(http_accept, (bytes, str)) and self.regex.search(http_accept): for skill in __skills__: get_response = skill(get_response) return get_response(request) diff --git a/tox.ini b/tox.ini index 05daa81..b9b096f 100644 --- a/tox.ini +++ b/tox.ini @@ -1,14 +1,15 @@ [tox] envlist = - py{36,38,39}-django21 - py{36,38,310}-django32 + py{37,38,39}-django21 + py{38,39,310}-django32 py{38,39,310}-django40 py{39,310,311}-django{41,42} - py{310,311}-djangomain + py{310,311,312}-django{51,52} [testenv] deps = - djangomain: https://github.com/django/django/tarball/main + django52: django>=5.2 + django51: django<5.2 django42: django<4.3 django41: django<4.2 django40: django<4.1