From 84ee7c8ff80cfcdfd280450575b4b5253a1f659c Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Wed, 5 Dec 2012 02:34:05 +0000 Subject: [PATCH] Changes for Django 1.4; should now be updated from gramps35 svn: r20766 --- gramps/webapp/dbdjango.py | 2 +- gramps/webapp/grampsdb/views.py | 8 ++++---- gramps/webapp/settings.py | 5 +++++ gramps/webapp/shell.py | 14 +++++++------- gramps/webapp/urls.py | 1 + 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/gramps/webapp/dbdjango.py b/gramps/webapp/dbdjango.py index 8216e9287..2b92ac27f 100644 --- a/gramps/webapp/dbdjango.py +++ b/gramps/webapp/dbdjango.py @@ -50,7 +50,7 @@ from gramps.gen.db import (PERSON_KEY, NOTE_KEY) from gramps.gen.utils.id import create_id from gramps.gen.constfunc import STRTYPE -from webapp.libdjango import DjangoInterface +from gramps.webapp.libdjango import DjangoInterface from django.db import transaction class Cursor(object): diff --git a/gramps/webapp/grampsdb/views.py b/gramps/webapp/grampsdb/views.py index ee2bdc621..aca1dc472 100644 --- a/gramps/webapp/grampsdb/views.py +++ b/gramps/webapp/grampsdb/views.py @@ -63,7 +63,7 @@ from gramps.webapp.utils import _, build_args from gramps.webapp.grampsdb.models import * from gramps.webapp.grampsdb.view import * from gramps.webapp.dbdjango import DbDjango -from gramps.cli.user import User +import gramps.cli.user from gramps.gen.const import VERSION_TUPLE from gramps.gen.utils.svn import get_svn_revision @@ -220,7 +220,7 @@ def process_report_run(request, handle): mimetype = 'application/%s' % args["off"] elif report.report_type == "export": filename = "/tmp/%s-%s.%s" % (str(profile.user.username), str(handle), args["off"]) - export_file(db, filename, User()) # callback + export_file(db, filename, gramps.cli.user.User()) # callback mimetype = 'text/plain' elif report.report_type == "import": filename = download(args["i"], "/tmp/%s-%s.%s" % (str(profile.user.username), @@ -231,14 +231,14 @@ def process_report_run(request, handle): import threading def background(): try: - import_file(db, filename, User()) # callback + import_file(db, filename, gramps.cli.user.User()) # callback except: make_message(request, "import_file failed: " + traceback.format_exc()) threading.Thread(target=background).start() make_message(request, "Your data is now being imported...") return redirect("/report/") else: - success = import_file(db, filename, User()) # callback + success = import_file(db, filename, gramps.cli.user.User()) # callback if not success: make_message(request, "Failed to load imported.") return redirect("/report/") diff --git a/gramps/webapp/settings.py b/gramps/webapp/settings.py index 6c8806588..d3821aae3 100644 --- a/gramps/webapp/settings.py +++ b/gramps/webapp/settings.py @@ -60,6 +60,7 @@ SECRET_KEY = 'zd@%vslj5sqhx94_8)0hsx*rk9tj3^ly$x+^*tq4bggr&uh$ac' TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', # 1.4 + 'django.template.loaders.app_directories.Loader', # 1.4 #'django.template.loaders.filesystem.load_template_source', #'django.template.loaders.app_directories.load_template_source', ) @@ -69,10 +70,12 @@ MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', # 'debug_toolbar.middleware.DebugToolbarMiddleware', ) ROOT_URLCONF = 'gramps.webapp.urls' +STATIC_URL = '/static/' # 1.4 TEMPLATE_DIRS = ( # Use absolute paths, not relative paths. @@ -81,6 +84,7 @@ TEMPLATE_DIRS = ( TEMPLATE_CONTEXT_PROCESSORS = ( "django.contrib.auth.context_processors.auth", # 1.4 + "django.contrib.messages.context_processors.messages", # 1.4 # "django.core.context_processors.auth", # "django.core.context_processors.debug", "django.core.context_processors.i18n", @@ -93,6 +97,7 @@ INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', + 'django.contrib.messages', # 1.4 'django.contrib.sites', 'django.contrib.admin', 'gramps.webapp.grampsdb', diff --git a/gramps/webapp/shell.py b/gramps/webapp/shell.py index d359b4dec..b5f9f39e0 100644 --- a/gramps/webapp/shell.py +++ b/gramps/webapp/shell.py @@ -37,15 +37,15 @@ except RuntimeError: # already configured; ignore pass -from .grampsdb.models import * -from .grampsdb.forms import * -from .dbdjango import DbDjango -from .reports import import_file -from .libdjango import DjangoInterface, totime, todate +from gramps.webapp.grampsdb.models import * +from gramps.webapp.grampsdb.forms import * +from gramps.webapp.dbdjango import DbDjango +from gramps.webapp.reports import import_file +from gramps.webapp.libdjango import DjangoInterface, totime, todate from gramps.gen.datehandler import displayer, parser -from .utils import StyledNoteFormatter, parse_styled_text +from gramps.webapp.utils import StyledNoteFormatter, parse_styled_text from gramps.gen.lib import StyledText -from gramps.cli.user import User +#from gramps.cli.user import User db = DbDjango() dji = DjangoInterface() diff --git a/gramps/webapp/urls.py b/gramps/webapp/urls.py index 6a1559a5d..7d074c510 100644 --- a/gramps/webapp/urls.py +++ b/gramps/webapp/urls.py @@ -36,6 +36,7 @@ import os from gramps.gen.const import IMAGE_DIR, ROOT_DIR from django.conf.urls.defaults import * from django.contrib import admin + admin.autodiscover() from gramps.webapp.grampsdb.views import *