From 5500e8072cd36304c6255a647fda21047b01c372 Mon Sep 17 00:00:00 2001 From: Rick van Hattem Date: Sat, 21 Nov 2020 11:04:33 +0100 Subject: [PATCH 01/10] Update README.rst --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 ------------- From c3f113bc6db47f8288f2d92bce4611d1bf22821e Mon Sep 17 00:00:00 2001 From: Rick van Hattem Date: Fri, 10 Dec 2021 02:02:50 +0100 Subject: [PATCH 02/10] updated tests for django up to 4.0 --- .github/workflows/test.yaml | 25 +++++++++++++++++++++++++ .travis.yml | 22 ---------------------- django_statsd/middleware.py | 17 +++++++++++++---- tests/test_app/urls.py | 4 ++-- tests/urls.py | 4 ++-- tox.ini | 24 ++++++++++++++++-------- 6 files changed, 58 insertions(+), 38 deletions(-) create mode 100644 .github/workflows/test.yaml delete mode 100644 .travis.yml diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..271c07d --- /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, 3.10] + + 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/django_statsd/middleware.py b/django_statsd/middleware.py index d8a7d8e..46065a3 100644 --- a/django_statsd/middleware.py +++ b/django_statsd/middleware.py @@ -34,6 +34,15 @@ MAKE_TAGS_LIKE = False +def is_ajax(request): + ''' + 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): def __init__(self, timer, key): @@ -200,14 +209,14 @@ def process_response(self, request, response): method = 'method' + MAKE_TAGS_LIKE method += request.method.lower().replace('.', '_') - is_ajax = 'is_ajax' + MAKE_TAGS_LIKE - is_ajax += str(request.is_ajax()).lower() + ajax_name = 'is_ajax' + MAKE_TAGS_LIKE + ajax_name += str(is_ajax(request)).lower() if getattr(self, 'view_name', None): - self.stop(method, self.view_name, is_ajax) + self.stop(method, self.view_name, ajax_name) else: method = request.method.lower() - if request.is_ajax(): + if is_ajax(request): method += '_ajax' if getattr(self, 'view_name', None): self.stop(method, self.view_name) diff --git a/tests/test_app/urls.py b/tests/test_app/urls.py index e1f06ae..0e90c90 100644 --- a/tests/test_app/urls.py +++ b/tests/test_app/urls.py @@ -1,6 +1,6 @@ -from django.conf import urls +from django import urls from . import views urlpatterns = [ - urls.url(r'^$', views.index, name='index'), + urls.path(r'', views.index, name='index'), ] diff --git a/tests/urls.py b/tests/urls.py index c1b7ebe..673a62f 100644 --- a/tests/urls.py +++ b/tests/urls.py @@ -1,5 +1,5 @@ -from django.conf import urls +from django import urls urlpatterns = [ - urls.url(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 3c5a6e7..c52938a 100644 --- a/tox.ini +++ b/tox.ini @@ -1,24 +1,32 @@ [tox] envlist = - py{py,27}-django11, - py35-django{11,20}, - py36-django{11,20}, + py36-django{22,32,40}, + py37-django{22,32,40}, + py38-django{22,32,40}, + py39-django{22,32,40}, + py310-django{22,32,40}, flake8, docs skip_missing_interpreters = True usedevelop = True +[gh-actions] + 3.6: py36 + 3.7: py37 + 3.8: py38, mypy + 3.9: py39 + 3.10: py310 + [testenv] deps = - django11: Django<2.0 - django20: Django>=2.0,<2.1 + django22: Django<3 + django32: Django<4 + django40: Django>=4.0,<4.1 -r{toxinidir}/tests/requirements.txt envlist = - py{py,27}-django11, - py35-django{11,20}, - py36-django{11,20}, + py3{6,7,8,9,10}-django{22,32,40} commands = python setup.py test From dd24787bf7ca59e7bb7a2f48b7e3066dac519ce4 Mon Sep 17 00:00:00 2001 From: Rick van Hattem Date: Fri, 10 Dec 2021 02:04:48 +0100 Subject: [PATCH 03/10] disabled jdango 3.10 for now --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 271c07d..6430779 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.6, 3.7, 3.8, 3.9, 3.10] + python-version: [3.6, 3.7, 3.8, 3.9] steps: - uses: actions/checkout@v1 From ad5ddd6a951b26811f133d9d6561d7ec08708e04 Mon Sep 17 00:00:00 2001 From: Rick van Hattem Date: Fri, 10 Dec 2021 02:06:36 +0100 Subject: [PATCH 04/10] fixed github actions? --- tox.ini | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index c52938a..282c791 100644 --- a/tox.ini +++ b/tox.ini @@ -12,9 +12,10 @@ skip_missing_interpreters = True usedevelop = True [gh-actions] +python = 3.6: py36 3.7: py37 - 3.8: py38, mypy + 3.8: py38 3.9: py39 3.10: py310 From d2b336d7834ac17bfb2c2f6fd76c75b6d0e767ae Mon Sep 17 00:00:00 2001 From: Rick van Hattem Date: Fri, 10 Dec 2021 02:08:46 +0100 Subject: [PATCH 05/10] fixed github actions? --- tox.ini | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tox.ini b/tox.ini index 282c791..df348f3 100644 --- a/tox.ini +++ b/tox.ini @@ -1,10 +1,7 @@ [tox] envlist = - py36-django{22,32,40}, - py37-django{22,32,40}, - py38-django{22,32,40}, - py39-django{22,32,40}, - py310-django{22,32,40}, + py36-django{22,32}, + py{37,38,39,310}-django{22,32,40}, flake8, docs From 81de2621d4030a03e6975db7b911935a9b12a65d Mon Sep 17 00:00:00 2001 From: Rick van Hattem Date: Fri, 10 Dec 2021 02:38:01 +0100 Subject: [PATCH 06/10] fixed github actions? --- tox.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index df348f3..4b6f220 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ [tox] envlist = - py36-django{22,32}, - py{37,38,39,310}-django{22,32,40}, + py{36,37}-django{22,32}, + py{38,39,310}-django{22,32,40}, flake8, docs From b667112d742ee78663c8cec9587a80e1105b8482 Mon Sep 17 00:00:00 2001 From: Rick van Hattem Date: Fri, 10 Dec 2021 13:45:34 +0100 Subject: [PATCH 07/10] updated test project to work with new django releases --- tests/settings.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/settings.py b/tests/settings.py index d953402..d7819fd 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -80,10 +80,22 @@ 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. -TEMPLATE_LOADERS = ( - 'django.template.loaders.filesystem.Loader', - 'django.template.loaders.app_directories.Loader', -) +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + MIDDLEWARE = ( 'django_statsd.middleware.StatsdMiddleware', From dc5cf61d456febdea5dfcbf8a6ed5d1eb354a7f6 Mon Sep 17 00:00:00 2001 From: Rick van Hattem Date: Mon, 21 Aug 2023 02:36:39 +0200 Subject: [PATCH 08/10] Added stale action --- .github/workflows/stale.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/stale.yml diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 0000000..3169ca3 --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,20 @@ +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 \ No newline at end of file From 5c2496529b956843627bd1e4b66e2e87bea60c22 Mon Sep 17 00:00:00 2001 From: Rick van Hattem Date: Tue, 29 Aug 2023 03:08:50 +0200 Subject: [PATCH 09/10] updated stale file --- .github/workflows/stale.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 3169ca3..0740d1a 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -12,9 +12,4 @@ jobs: - uses: actions/stale@v8 with: days-before-stale: 30 - exempt-issue-labels: | - in-progress - help-wanted - pinned - security - enhancement \ No newline at end of file + exempt-issue-labels: in-progress,help-wanted,pinned,security,enhancement From 1acce1a027075a9bd17410c7c7dfccaf60c2d998 Mon Sep 17 00:00:00 2001 From: Rick van Hattem Date: Sun, 21 Jul 2024 03:40:26 +0200 Subject: [PATCH 10/10] Incrementing version to v2.7.0 --- django_statsd/__about__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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__ = (