Permalink
Browse files

fix django 1.9 deprecation warnings, update django version check & re…

…move tests for old django
  • Loading branch information...
1 parent 26c2de1 commit bf8e53b15b957d63cf2b85e679d931093c764e9d @DanCech DanCech committed Nov 23, 2016
@@ -95,8 +95,8 @@
required += 1
-if django and django.VERSION[:2] < (1,4):
- sys.stderr.write("[REQUIRED] You have django version %s installed, but version 1.4 or greater is required\n" % django.get_version())
+if django and django.VERSION[:2] < (1,9):
+ sys.stderr.write("[REQUIRED] You have django version %s installed, but version 1.9 or greater is required\n" % django.get_version())
required += 1
@@ -12,13 +12,12 @@
See the License for the specific language governing permissions and
limitations under the License."""
-from django.conf.urls import patterns, url
+from django.conf.urls import url
from . import views
-urlpatterns = patterns(
- '',
+urlpatterns = [
url('^login/?$', views.loginView, name='account_login'),
url('^logout/?$', views.logoutView, name='account_logout'),
url('^edit/?$', views.editProfile, name='account_edit'),
url('^update/?$', views.updateProfile, name='account_update'),
-)
+]
@@ -16,9 +16,6 @@
# DO NOT MODIFY THIS FILE DIRECTLY - use local_settings.py instead
from os.path import dirname, join, abspath
-TEMPLATE_DIRS = (
- join(dirname( abspath(__file__) ), 'templates'),
-)
#Django settings below, do not touch!
APPEND_SLASH = False
@@ -29,6 +26,29 @@
},
}
+TEMPLATES = [
+ {
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
+ 'DIRS': [
+ join(dirname( abspath(__file__) ), 'templates')
+ ],
+ 'APP_DIRS': True,
+ 'OPTIONS': {
+ 'context_processors': [
+ # Insert your TEMPLATE_CONTEXT_PROCESSORS here or use this
+ # list if you haven't customized them:
+ 'django.contrib.auth.context_processors.auth',
+ 'django.template.context_processors.debug',
+ 'django.template.context_processors.i18n',
+ 'django.template.context_processors.media',
+ 'django.template.context_processors.static',
+ 'django.template.context_processors.tz',
+ 'django.contrib.messages.context_processors.messages',
+ ],
+ },
+ },
+]
+
# Language code for this installation. All choices can be found here:
# http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
# http://blogs.law.harvard.edu/tech/stories/storyReader$15
@@ -12,14 +12,13 @@
See the License for the specific language governing permissions and
limitations under the License."""
-from django.conf.urls import patterns, url
+from django.conf.urls import url
from . import views
-urlpatterns = patterns(
- '',
+urlpatterns = [
url('^header/?$', views.header, name='browser_header'),
url('^search/?$', views.search, name='browser_search'),
url('^mygraph/?$', views.myGraphLookup, name='browser_my_graph'),
url('^usergraph/?$', views.userGraphLookup, name='browser_usergraph'),
url('^$', views.browser, name='browser'),
-)
+]
@@ -12,12 +12,11 @@
See the License for the specific language governing permissions and
limitations under the License."""
-from django.conf.urls import patterns, url
+from django.conf.urls import url
from . import views
-urlpatterns = patterns(
- '',
+urlpatterns = [
url('send_email', views.send_email, name='composer_send_email'),
url('mygraph', views.mygraph, name='composer_mygraph'),
url('', views.composer, name='composer'),
-)
+]
@@ -1,8 +1,7 @@
-from django.conf.urls import patterns, url
+from django.conf.urls import url
from . import views
-urlpatterns = patterns(
- '',
+urlpatterns = [
url('^save/(?P<name>[^/]+)', views.save, name='dashboard_save'),
url('^save_template/(?P<name>[^/]+)/(?P<key>[^/]+)',
views.save_template, name='dashboard_save_template'),
@@ -27,4 +26,4 @@
name='dashboard_template'),
url('^(?P<name>[^/]+)', views.dashboard, name='dashboard'),
url('', views.dashboard, name='dashboard'),
-)
+]
@@ -12,12 +12,11 @@
See the License for the specific language governing permissions and
limitations under the License."""
-from django.conf.urls import patterns, url
+from django.conf.urls import url
from . import views
-urlpatterns = patterns(
- '',
+urlpatterns = [
url('^get_data?$', views.get_data, name='events_get_data'),
url(r'(?P<event_id>\d+)/$', views.detail, name='events_detail'),
url('^$', views.view_events, name='events'),
-)
+]
@@ -12,11 +12,10 @@
See the License for the specific language governing permissions and
limitations under the License."""
-from django.conf.urls import patterns, url
+from django.conf.urls import url
from . import views
-urlpatterns = patterns(
- '',
+urlpatterns = [
url('^index\.json$', views.index_json, name='metrics_index'),
url('^find/?$', views.find_view, name='metrics_find'),
url('^expand/?$', views.expand_view, name='metrics_expand'),
@@ -25,4 +24,4 @@
url('^set-metadata/?$', views.set_metadata_view,
name='metrics_set_metadata'),
url('', views.find_view, name='metrics'),
-)
+]
@@ -12,13 +12,12 @@
See the License for the specific language governing permissions and
limitations under the License."""
-from django.conf.urls import patterns, url
+from django.conf.urls import url
from . import views
-urlpatterns = patterns(
- '',
+urlpatterns = [
url('local/?$', views.renderLocalView, name='render_local'),
url('~(?P<username>[^/]+)/(?P<graphName>[^/]+)/?',
views.renderMyGraphView, name='render_my_graph'),
url('', views.renderView, name='render'),
-)
+]
@@ -11,47 +11,34 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License"""
-import django
-
from django.conf import settings
-from django.conf.urls import patterns, include, url
+from django.conf.urls import include, url
from django.contrib import admin
-
-if django.VERSION < (1, 5): # load the "future" {% url %} tag
- from django.template.loader import add_to_builtins
- add_to_builtins('django.templatetags.future')
-
-if django.VERSION < (1, 7):
- # Django doing autodiscover automatically:
- # https://docs.djangoproject.com/en/dev/releases/1.7/#app-loading-refactor
- admin.autodiscover()
-
-graphite_urls = patterns(
- '',
- ('^admin/', include(admin.site.urls)),
- ('^render/?', include('graphite.render.urls')),
- ('^composer/?', include('graphite.composer.urls')),
- ('^metrics/?', include('graphite.metrics.urls')),
- ('^browser/?', include('graphite.browser.urls')),
- ('^account/', include('graphite.account.urls')),
- ('^dashboard/?', include('graphite.dashboard.urls')),
- ('^whitelist/?', include('graphite.whitelist.urls')),
- ('^version/', include('graphite.version.urls')),
- ('^events/', include('graphite.events.urls')),
- url('^s/(?P<path>.*)',
- 'graphite.url_shortener.views.shorten', name='shorten'),
- url('^S/(?P<link_id>[a-zA-Z0-9]+)/?$',
- 'graphite.url_shortener.views.follow', name='follow'),
- url('^$', 'graphite.browser.views.browser', name='browser'),
-)
+from graphite.url_shortener.views import shorten, follow
+from graphite.browser.views import browser
+
+graphite_urls = [
+ url('^admin/', include(admin.site.urls)),
+ url('^render/?', include('graphite.render.urls')),
+ url('^composer/?', include('graphite.composer.urls')),
+ url('^metrics/?', include('graphite.metrics.urls')),
+ url('^browser/?', include('graphite.browser.urls')),
+ url('^account/', include('graphite.account.urls')),
+ url('^dashboard/?', include('graphite.dashboard.urls')),
+ url('^whitelist/?', include('graphite.whitelist.urls')),
+ url('^version/', include('graphite.version.urls')),
+ url('^events/', include('graphite.events.urls')),
+ url('^s/(?P<path>.*)', shorten, name='shorten'),
+ url('^S/(?P<link_id>[a-zA-Z0-9]+)/?$', follow, name='follow'),
+ url('^$', browser, name='browser'),
+]
url_prefix = ''
if settings.URL_PREFIX.strip('/'):
url_prefix = '{0}/'.format(settings.URL_PREFIX.strip('/'))
-urlpatterns = patterns(
- '',
- (r'^{0}'.format(url_prefix), include(graphite_urls)),
-)
+urlpatterns = [
+ url(r'^{0}'.format(url_prefix), include(graphite_urls)),
+]
handler500 = 'graphite.views.server_error'
@@ -12,10 +12,9 @@
See the License for the specific language governing permissions and
limitations under the License."""
-from django.conf.urls import patterns, url
+from django.conf.urls import url
from . import views
-urlpatterns = patterns(
- '',
+urlpatterns = [
url('', views.index, name='version_index'),
-)
+]
@@ -12,12 +12,11 @@
See the License for the specific language governing permissions and
limitations under the License."""
-from django.conf.urls import patterns, url
+from django.conf.urls import url
from . import views
-urlpatterns = patterns(
- '',
+urlpatterns = [
url('add', views.add, name='whitelist_add'),
url('remove', views.remove, name='whitelist_remove'),
url('', views.show, name='whitelist_show'),
-)
+]

0 comments on commit bf8e53b

Please sign in to comment.