From 1fd624e3f9228d671f40fc265cd76e2c70b51cac Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Wed, 28 Nov 2012 16:39:43 -0800 Subject: [PATCH] Change csrf imports and database settings for django 1.4 They moved the csrf protection code from django 1.1. I needed to change some imports in both a few modules and the settings file. Additionally the way to specify the database changed, the old 1.1 version is still in there as of this patch. --- htsworkflow/frontend/experiments/experiments.py | 2 +- htsworkflow/frontend/samples/views.py | 4 +--- htsworkflow/settings.py | 15 +++++++++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/htsworkflow/frontend/experiments/experiments.py b/htsworkflow/frontend/experiments/experiments.py index 1ccba52..f24d13d 100644 --- a/htsworkflow/frontend/experiments/experiments.py +++ b/htsworkflow/frontend/experiments/experiments.py @@ -9,7 +9,7 @@ import os import re from django.contrib.auth.decorators import login_required -from django.contrib.csrf.middleware import csrf_exempt +from django.views.decorators.csrf import csrf_exempt from django.core.exceptions import ObjectDoesNotExist from django.core.mail import send_mail, mail_admins from django.http import HttpResponse, Http404 diff --git a/htsworkflow/frontend/samples/views.py b/htsworkflow/frontend/samples/views.py index 7150d08..6108850 100644 --- a/htsworkflow/frontend/samples/views.py +++ b/htsworkflow/frontend/samples/views.py @@ -9,7 +9,7 @@ try: except ImportError, e: import simplejson as json -from django.contrib.csrf.middleware import csrf_exempt +from django.views.decorators.csrf import csrf_exempt from htsworkflow.frontend.auth import require_api_key from htsworkflow.frontend.experiments.models import FlowCell, Lane, LANE_STATUS_MAP from htsworkflow.frontend.samples.changelist import ChangeList @@ -553,5 +553,3 @@ def user_profile(request): context.update(SAMPLES_CONTEXT_DEFAULTS) return render_to_response('registration/profile.html', context, context_instance=RequestContext(request)) - - diff --git a/htsworkflow/settings.py b/htsworkflow/settings.py index 13eca3d..36f2f51 100644 --- a/htsworkflow/settings.py +++ b/htsworkflow/settings.py @@ -143,6 +143,13 @@ if options.has_option(database_section, 'password_file'): elif options.has_option(database_section, 'password'): DATABASE_PASSWORD = options.get(database_section, 'password') +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': DATABASE_NAME, + } +} + # Local time zone for this installation. Choices can be found here: # http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE # although not all variations may be possible on all operating systems. @@ -188,16 +195,16 @@ DEFAULT_API_KEY = 'n7HsXGHIi0vp9j5u4TIRJyqAlXYc4wrH' # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( - 'django.template.loaders.filesystem.load_template_source', - 'django.template.loaders.app_directories.load_template_source', -# 'django.template.loaders.eggs.load_template_source', + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', ) MIDDLEWARE_CLASSES = ( - 'django.contrib.csrf.middleware.CsrfMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.doc.XViewMiddleware', ) -- 2.30.2