diff --git a/webapp/graphite/account/admin.py b/webapp/graphite/account/admin.py index 98669555a..66d22feb5 100644 --- a/webapp/graphite/account/admin.py +++ b/webapp/graphite/account/admin.py @@ -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) diff --git a/webapp/graphite/account/views.py b/webapp/graphite/account/views.py index 06fe5c6b3..8c5fd662e 100644 --- a/webapp/graphite/account/views.py +++ b/webapp/graphite/account/views.py @@ -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 diff --git a/webapp/graphite/dashboard/urls.py b/webapp/graphite/dashboard/urls.py index f127cd565..363fedb64 100644 --- a/webapp/graphite/dashboard/urls.py +++ b/webapp/graphite/dashboard/urls.py @@ -1,28 +1,29 @@ +from django.urls import path from django.urls import re_path from . import views urlpatterns = [ - re_path(r'^/save/(?P[^/]+)$', views.save, name='dashboard_save'), - re_path(r'^/save_template/(?P[^/]+)/(?P[^/]+)$', views.save_template, + path('/save/', views.save, name='dashboard_save'), + path('/save_template//', views.save_template, name='dashboard_save_template'), - re_path(r'^/load/(?P[^/]+)$', views.load, name='dashboard_load'), - re_path(r'^/load/(?P[^/]+)/(?P[^/]+)$', views.load_template, + path('/load/', views.load, name='dashboard_load'), + path('/load//', views.load_template, name='dashboard_load_template'), - re_path(r'^/load_template/(?P[^/]+)/(?P[^/]+)$', views.load_template, + path('/load_template//', views.load_template, name='dashboard_load_template'), - re_path(r'^/delete/(?P[^/]+)$', views.delete, name='dashboard_delete'), + path('/delete/', 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('/email', views.email, name='dashboard_email'), re_path(r'^/find/?$', views.find, name='dashboard_find'), - re_path(r'^/delete_template/(?P[^/]+)$', views.delete_template, + path('/delete_template/', 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[^/]+)/(?P[^/]+)$', views.template, + path('//', views.template, name='dashboard_template'), - re_path(r'^/(?P[^/]+)$', views.dashboard, name='dashboard'), + path('/', views.dashboard, name='dashboard'), re_path(r'^/?$', views.dashboard, name='dashboard'), ] diff --git a/webapp/graphite/events/views.py b/webapp/graphite/events/views.py index 4a19ffab6..6d42f45b7 100644 --- a/webapp/graphite/events/views.py +++ b/webapp/graphite/events/views.py @@ -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) diff --git a/webapp/graphite/metrics/views.py b/webapp/graphite/metrics/views.py index 1b253fd89..8eb03091e 100644 --- a/webapp/graphite/metrics/views.py +++ b/webapp/graphite/metrics/views.py @@ -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'] ) @@ -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'))) diff --git a/webapp/graphite/settings.py b/webapp/graphite/settings.py index 2cfd9447d..aa7fc247d 100644 --- a/webapp/graphite/settings.py +++ b/webapp/graphite/settings.py @@ -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 diff --git a/webapp/graphite/url_shortener/views.py b/webapp/graphite/url_shortener/views.py index c5a0833d7..bbda14c8d 100644 --- a/webapp/graphite/url_shortener/views.py +++ b/webapp/graphite/url_shortener/views.py @@ -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 diff --git a/webapp/tests/test_browser.py b/webapp/tests/test_browser.py index d621e2909..ba471b573 100644 --- a/webapp/tests/test_browser.py +++ b/webapp/tests/test_browser.py @@ -5,7 +5,7 @@ try: from django.urls import reverse except ImportError: # Django < 1.10 - from django.core.urlresolvers import reverse + from django.urls import reverse from .base import TestCase from django.test.utils import override_settings from graphite.util import json diff --git a/webapp/tests/test_dashboard.py b/webapp/tests/test_dashboard.py index 4b2782f46..bb379b385 100644 --- a/webapp/tests/test_dashboard.py +++ b/webapp/tests/test_dashboard.py @@ -9,7 +9,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 HttpResponse from .base import TestCase from django.test.utils import override_settings diff --git a/webapp/tests/test_events.py b/webapp/tests/test_events.py index 205cbee7e..813adff59 100644 --- a/webapp/tests/test_events.py +++ b/webapp/tests/test_events.py @@ -6,7 +6,7 @@ try: from django.urls import reverse except ImportError: # Django < 1.10 - from django.core.urlresolvers import reverse + from django.urls import reverse from .base import TestCase from django.utils import timezone @@ -203,7 +203,7 @@ def test_get_detail_json_html(self): self.assertEqual(len(events), 1) url = reverse('events_detail', args=[events[0]['id']]) - response = self.client.get(url, {}, HTTP_ACCEPT='application/json') + response = self.client.get(url, {}, headers={"accept": 'application/json'}) self.assertEqual(response.status_code, 200) event = json.loads(response.content) self.assertEqual(event['what'], 'Something happened') @@ -216,7 +216,7 @@ def test_get_detail_json_html(self): def test_get_detail_json_object_does_not_exist(self): url = reverse('events_detail', args=[1]) - response = self.client.get(url, {}, HTTP_ACCEPT='application/json') + response = self.client.get(url, {}, headers={"accept": 'application/json'}) self.assertEqual(response.status_code, 404) event = json.loads(response.content) self.assertEqual(event['error'], 'Event matching query does not exist') diff --git a/webapp/tests/test_functions.py b/webapp/tests/test_functions.py index c57f21647..cc40d54af 100644 --- a/webapp/tests/test_functions.py +++ b/webapp/tests/test_functions.py @@ -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 graphite.errors import NormalizeEmptyResultError, InputParameterError from graphite.functions import _SeriesFunctions, loadFunctions, safe diff --git a/webapp/tests/test_metrics.py b/webapp/tests/test_metrics.py index c7347c689..bb45325bf 100644 --- a/webapp/tests/test_metrics.py +++ b/webapp/tests/test_metrics.py @@ -9,7 +9,7 @@ try: from django.urls import reverse except ImportError: # Django < 1.10 - from django.core.urlresolvers import reverse + from django.urls import reverse from .base import TestCase import whisper diff --git a/webapp/tests/test_render.py b/webapp/tests/test_render.py index 61aff3e73..4d3d04a51 100644 --- a/webapp/tests/test_render.py +++ b/webapp/tests/test_render.py @@ -23,7 +23,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 HttpRequest, QueryDict from .base import TestCase diff --git a/webapp/tests/test_tags.py b/webapp/tests/test_tags.py index 336f12c14..a92260da3 100644 --- a/webapp/tests/test_tags.py +++ b/webapp/tests/test_tags.py @@ -4,7 +4,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.conf import settings from mock import patch, Mock diff --git a/webapp/tests/test_versions.py b/webapp/tests/test_versions.py index ae460d270..9dc3b4d4e 100644 --- a/webapp/tests/test_versions.py +++ b/webapp/tests/test_versions.py @@ -2,7 +2,7 @@ try: from django.urls import reverse except ImportError: # Django < 1.10 - from django.core.urlresolvers import reverse + from django.urls import reverse from .base import TestCase diff --git a/webapp/tests/test_whitelist.py b/webapp/tests/test_whitelist.py index 32a4dcf75..60abd3179 100644 --- a/webapp/tests/test_whitelist.py +++ b/webapp/tests/test_whitelist.py @@ -9,7 +9,7 @@ try: from django.urls import reverse except ImportError: # Django < 1.10 - from django.core.urlresolvers import reverse + from django.urls import reverse from .base import TestCase from graphite.whitelist.views import load_whitelist, save_whitelist diff --git a/webapp/tests/test_xss.py b/webapp/tests/test_xss.py index 7a3a2c9b7..f5ee5d317 100644 --- a/webapp/tests/test_xss.py +++ b/webapp/tests/test_xss.py @@ -4,7 +4,7 @@ try: from django.urls import reverse except ImportError: # Django < 1.10 - from django.core.urlresolvers import reverse + from django.urls import reverse from .base import TestCase