diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 0000000..0740d1a --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,15 @@ +name: Close stale issues and pull requests + +on: + workflow_dispatch: + schedule: + - cron: '0 0 * * *' # Run every day at midnight + +jobs: + stale: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v8 + with: + days-before-stale: 30 + exempt-issue-labels: in-progress,help-wanted,pinned,security,enhancement diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..6430779 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,25 @@ +name: Test + +on: + - push + - pull_request + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.6, 3.7, 3.8, 3.9] + + steps: + - uses: actions/checkout@v1 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install tox tox-gh-actions + - name: Test with tox + run: tox diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e934991..0000000 --- a/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -sudo: false -cache: pip -language: python -python: 3.6 -dist: xenial - -env: - - TOX_ENV=pypy-django11 - - TOX_ENV=py27-django11 - - TOX_ENV=py35-django11 - - TOX_ENV=py35-django20 - - TOX_ENV=py36-django11 - - TOX_ENV=py36-django20 - - TOX_ENV=flake8 - - TOX_ENV=docs - -install: - - pip install tox - -script: - tox -e $TOX_ENV - diff --git a/README.rst b/README.rst index ed2e44f..8c0d4f6 100644 --- a/README.rst +++ b/README.rst @@ -35,9 +35,9 @@ To install, add the following to your ``settings.py``: 1. ``django_statsd`` to the ``INSTALLED_APPS`` setting. 2. ``django_statsd.middleware.StatsdMiddleware`` to the **top** of your - ``MIDDLEWARE_CLASSES`` + ``MIDDLEWARE`` 3. ``django_statsd.middleware.StatsdMiddlewareTimer`` to the **bottom** of your - ``MIDDLEWARE_CLASSES`` + ``MIDDLEWARE`` Configuration ------------- diff --git a/django_statsd/__about__.py b/django_statsd/__about__.py index 40d4875..195aa23 100644 --- a/django_statsd/__about__.py +++ b/django_statsd/__about__.py @@ -1,5 +1,5 @@ __package_name__ = 'django-statsd' -__version__ = '2.6.0' +__version__ = '2.7.0' __author__ = 'Rick van Hattem' __author_email__ = 'Rick.van.Hattem@Fawo.nl' __description__ = ( diff --git a/django_statsd/middleware.py b/django_statsd/middleware.py index 0c5c2cf..340c0e0 100644 --- a/django_statsd/middleware.py +++ b/django_statsd/middleware.py @@ -33,7 +33,12 @@ def is_ajax(request): - return request.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest' + ''' + Recreating the old Django is_ajax function. Note that this is not + guaranteed to be correct as it depends on jQuery style ajax + requests + ''' + return request.headers.get('x-requested-with') == 'XMLHttpRequest' class WithTimer(object): diff --git a/tests/settings.py b/tests/settings.py index 93ff6ee..d7819fd 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -79,6 +79,7 @@ # Make this unique, and don't share it with anybody. SECRET_KEY = '4f79$e&*4cfhk&k%uo*z0cjx&nvvayk-6wxkgf-apni5=q@!mz' +# List of callables that know how to import templates from various sources. TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', diff --git a/tests/test_app/urls.py b/tests/test_app/urls.py index a57f0d4..0e90c90 100644 --- a/tests/test_app/urls.py +++ b/tests/test_app/urls.py @@ -1,7 +1,6 @@ from django import urls - from . import views urlpatterns = [ - urls.re_path(r'^$', views.index, name='index'), + urls.path(r'', views.index, name='index'), ] diff --git a/tests/urls.py b/tests/urls.py index a17633c..673a62f 100644 --- a/tests/urls.py +++ b/tests/urls.py @@ -1,5 +1,5 @@ from django import urls urlpatterns = [ - urls.re_path(r'^test_app/$', urls.include('tests.test_app.urls')), + urls.path('test_app/', urls.include('tests.test_app.urls')), ] diff --git a/tox.ini b/tox.ini index 14275ed..4107adb 100644 --- a/tox.ini +++ b/tox.ini @@ -7,6 +7,14 @@ envlist = skip_missing_interpreters = True usedevelop = True +[gh-actions] +python = + 3.6: py36 + 3.7: py37 + 3.8: py38 + 3.9: py39 + 3.10: py310 + [testenv] deps = setuptools @@ -14,6 +22,9 @@ deps = django50: Django>=5.0,<5.1 # Added currently supported versions -r{toxinidir}/tests/requirements.txt +envlist = + py3{8,9,10,11,12,13,14}-django{4.2,5.0}, + commands = python setup.py test