Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django 4.2 support #2846

Merged
merged 21 commits into from
Aug 25, 2024
Merged
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
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: monthly
- package-ecosystem: pip
directory: "/"
schedule:
interval: weekly
time: '10:00'
open-pull-requests-limit: 10
10 changes: 5 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -81,24 +81,24 @@ jobs:
run: |
tox
- name: Linting
if: ${{ matrix.python-version==3.10 }}
if: ${{ matrix.python-version==3.12 }}
env:
TOXENV: lint
run: |
tox
- name: Testing documentation
if: ${{ matrix.python-version==3.10 }}
if: ${{ matrix.python-version==3.12 }}
env:
TOXENV: docs
run: |
tox
- name: Run Codecov
if: ${{ matrix.python-version==3.10 }}
if: ${{ matrix.python-version==3.12 }}
env:
TOXENV: lint
run: |
pip install codecov
codecov
- name: Upload coverage to Codecov
if: ${{ matrix.python-version==3.10 }}
if: ${{ matrix.python-version==3.12 }}
uses: codecov/codecov-action@v3
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
default_language_version:
python: python3.12

repos:
- repo: https://github.com/adamchainz/django-upgrade
rev: "1.20.0"
hooks:
- id: django-upgrade
args: [ --target-version, "4.2" ]
9 changes: 9 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- id: django-upgrade
name: django-upgrade
description: Automatically upgrade your Django project code.
entry: django-upgrade
language: python
types: [python]
# for backward compatibility
files: ''
minimum_pre_commit_version: 0.15.0
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ include webapp/graphite/local_settings.py.example
recursive-include distro/ *
recursive-include webapp/graphite/ *.html
recursive-include webapp/content/ *
recursive-include webapp/tests/ *
exclude webapp/graphite/local_settings.py
exclude conf/*.conf
12 changes: 10 additions & 2 deletions check-dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
optional = 0


def versiontuple(v):
return tuple(map(int, (v.split("."))))


# Test for whisper
try:
import whisper
Expand Down Expand Up @@ -92,6 +96,10 @@
sys.stderr.write("[REQUIRED] Unable to import the 'pyparsing' module, "
"do you have pyparsing module installed for python %s?\n" % sys.version_info.major)
required += 1
if versiontuple(pyparsing.__version__) < versiontuple("2.3.0"):
sys.stderr.write("[REQUIRED] You have pyparsing version %s installed, "
"but version 2.3.0 or greater is required\n" % pyparsing.__version__)
required += 1


# Test for django-tagging
Expand All @@ -103,9 +111,9 @@
required += 1


if django and django.VERSION[:2] < (1,8):
if django and django.VERSION[:2] < (4,2):
sys.stderr.write("[REQUIRED] You have django version %s installed, "
"but version 1.8 or greater is required\n" % django.get_version())
"but version 4.2 or greater is required\n" % django.get_version())
required += 1


Expand Down
8 changes: 4 additions & 4 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ been met or not.
Basic Graphite requirements:

* a UNIX-like Operating System
* Python 2.7 or greater (including experimental Python3 support)
* Python 3.8 or greater
* `cairocffi`_
* `Django`_ 1.8 - 2.2 (for Python3 - 1.11 and newer), 1.11.19 or newer is recommended
* `django-tagging`_ 0.4.6 (not `django-taggit` yet)
* `Django`_ 4.2+
* `django-tagging`_ 0.4.6 (not `django-taggit`, unfortunately)
* `pytz`_
* `scandir`_ (for Python older than 3.5)
* `pyparsing` 2.3.0+
* `fontconfig`_ and at least one font package (a system package usually)
* A WSGI server and web server. Popular choices are:

Expand Down
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Requirements for documentation
cairocffi
django-tagging==0.4.6
django-tagging
pytz
git+https://github.com/graphite-project/whisper.git#egg=whisper
git+https://github.com/graphite-project/ceres.git#egg=ceres
Expand Down
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
# deactivate
#

Django>=3.2,<5
python-memcached==1.58
txAMQP==0.8
django-tagging==0.4.6
Django>=4.2,<5
python-memcached>=1.58
txAMQP>=0.8.2,<0.9
django-tagging
gunicorn
pytz
pyparsing>=2.3.0
Expand Down
14 changes: 7 additions & 7 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[gh-actions]
python =
3.7: py37
3.8: py38
3.9: py39
3.10: py310
3.11: py311
3.12: py312

[tox]
envlist =
py{37,38,39,310}-django32-pyparsing3{,-msgpack},
lint, docs
py{38,39,310,311,312},lint, docs

[testenv]
whitelist_externals =
Expand All @@ -31,16 +31,16 @@ deps =
django-tagging
pytz
mock
msgpack-python
git+https://github.com/graphite-project/whisper.git#egg=whisper
git+https://github.com/graphite-project/ceres.git#egg=ceres
pyparsing3: pyparsing>=3.0.6
django32: Django>=3.2,<5
pyparsing>=3.0.6
Django>=4.2,<5
urllib3
redis
rrdtool
mysql: mysqlclient
postgresql: psycopg2
msgpack: msgpack-python
pyhash: pyhash

[testenv:docs]
Expand All @@ -64,7 +64,7 @@ commands =
sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html

[testenv:lint]
basepython = python3.10
basepython = python3.12
changedir = {toxinidir}
deps =
flake8==3.7.9
Expand Down
2 changes: 1 addition & 1 deletion webapp/graphite/account/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
from graphite.account.models import Profile,MyGraph


@admin.register(MyGraph)
class MyGraphAdmin(admin.ModelAdmin):
list_display = ('profile','name')
list_filter = ('profile',)


admin.site.register(Profile)
admin.site.register(MyGraph, MyGraphAdmin)
2 changes: 1 addition & 1 deletion webapp/graphite/account/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
try:
from django.urls import reverse
except ImportError: # Django < 1.10
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.http import HttpResponseRedirect
from django.shortcuts import render
from graphite.user_util import getProfile, isAuthenticated
Expand Down
29 changes: 12 additions & 17 deletions webapp/graphite/dashboard/urls.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
from django.urls import path
from django.urls import re_path
from . import views

urlpatterns = [
re_path(r'^/save/(?P<name>[^/]+)$', views.save, name='dashboard_save'),
re_path(r'^/save_template/(?P<name>[^/]+)/(?P<key>[^/]+)$', views.save_template,
name='dashboard_save_template'),
re_path(r'^/load/(?P<name>[^/]+)$', views.load, name='dashboard_load'),
re_path(r'^/load/(?P<name>[^/]+)/(?P<val>[^/]+)$', views.load_template,
name='dashboard_load_template'),
re_path(r'^/load_template/(?P<name>[^/]+)/(?P<val>[^/]+)$', views.load_template,
name='dashboard_load_template'),
re_path(r'^/delete/(?P<name>[^/]+)$', views.delete, name='dashboard_delete'),
re_path(r'^/create-temporary/?$', views.create_temporary,
name='dashboard_create_temporary'),
re_path(r'^/email$', views.email, name='dashboard_email'),
path('/save/<str:name>', views.save, name='dashboard_save'),
path('/save_template/<str:name>/<str:key>', views.save_template, name='dashboard_save_template'),
path('/load/<str:name>', views.load, name='dashboard_load'),
path('/load/<str:name>/<str:val>', views.load_template, name='dashboard_load_template'),
path('/load_template/<str:name>/<str:val>', views.load_template, name='dashboard_load_template'),
path('/delete/<str:name>', views.delete, name='dashboard_delete'),
re_path(r'^/create-temporary/?$', views.create_temporary, name='dashboard_create_temporary'),
path('/email', views.email, name='dashboard_email'),
re_path(r'^/find/?$', views.find, name='dashboard_find'),
re_path(r'^/delete_template/(?P<name>[^/]+)$', views.delete_template,
name='dashboard_delete_template'),
path('/delete_template/<str:name>', views.delete_template, name='dashboard_delete_template'),
re_path(r'^/find_template/?$', views.find_template, name='dashboard_find_template'),
re_path(r'^/login/?$', views.user_login, name='dashboard_login'),
re_path(r'^/logout/?$', views.user_logout, name='dashboard_logout'),
re_path(r'^/help/?$', views.help, name='dashboard_help'),
re_path(r'^/(?P<name>[^/]+)/(?P<val>[^/]+)$', views.template,
name='dashboard_template'),
re_path(r'^/(?P<name>[^/]+)$', views.dashboard, name='dashboard'),
path('/<str:name>/<str:val>', views.template, name='dashboard_template'),
path('/<str:name>', views.dashboard, name='dashboard'),
re_path(r'^/?$', views.dashboard, name='dashboard'),
]
2 changes: 1 addition & 1 deletion webapp/graphite/events/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def jsonDetail(request, queryParams, event_id):


def detail(request, event_id):
if request.META.get('HTTP_ACCEPT') == 'application/json':
if request.headers.get('accept') == 'application/json':
return jsonDetail(request, event_id)

e = get_object_or_404(Event, pk=event_id)
Expand Down
4 changes: 2 additions & 2 deletions webapp/graphite/metrics/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def set_metadata_view(request):
results[metric] = dict(error="Unexpected error occurred in CarbonLink.set_metadata(%s, %s)" % (metric, key))

elif request.method == 'POST':
if request.META.get('CONTENT_TYPE') == 'application/json':
if request.headers.get('content-type') == 'application/json':
operations = json.loads( request.body )
else:
operations = json.loads( request.POST['operations'] )
Expand Down Expand Up @@ -414,7 +414,7 @@ def json_nodes(nodes):


def json_response_for(request, data, content_type='application/json', jsonp=False, **kwargs):
accept = request.META.get('HTTP_ACCEPT', 'application/json')
accept = request.headers.get('accept', 'application/json')
ensure_ascii = accept == 'application/json'

pretty = bool(request.POST.get('pretty', request.GET.get('pretty')))
Expand Down
2 changes: 1 addition & 1 deletion webapp/graphite/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
try:
from django.urls import reverse_lazy
except ImportError: # Django < 1.10
from django.core.urlresolvers import reverse_lazy
from django.urls import reverse_lazy


GRAPHITE_WEB_APP_SETTINGS_LOADED = False
Expand Down
2 changes: 1 addition & 1 deletion webapp/graphite/url_shortener/views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
try:
from django.urls import reverse
except ImportError: # Django < 1.10
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.shortcuts import get_object_or_404
from django.http import HttpResponse, HttpResponsePermanentRedirect

Expand Down
Loading
Loading