import/export updates; all appear to work on web

svn: r19569
This commit is contained in:
Doug Blank 2012-05-18 02:45:36 +00:00
parent 21abdd5f7f
commit b8109ba431

View File

@ -48,6 +48,7 @@ from webapp.grampsdb.models import *
from webapp.grampsdb.forms import * from webapp.grampsdb.forms import *
from webapp.dbdjango import DbDjango from webapp.dbdjango import DbDjango
from webapp.libdjango import DjangoInterface from webapp.libdjango import DjangoInterface
import cli.user
dji = DjangoInterface() dji = DjangoInterface()
@ -339,7 +340,7 @@ def process_action(request, view, handle, action):
mimetype = 'application/%s' % args["off"] mimetype = 'application/%s' % args["off"]
elif report.report_type == "export": elif report.report_type == "export":
filename = "/tmp/%s-%s.%s" % (str(profile.user.username), str(handle), args["off"]) filename = "/tmp/%s-%s.%s" % (str(profile.user.username), str(handle), args["off"])
export_file(db, filename, lambda n: n) # callback export_file(db, filename, cli.user.User()) # callback
mimetype = 'text/plain' mimetype = 'text/plain'
elif report.report_type == "import": elif report.report_type == "import":
filename = download(args["i"], "/tmp/%s-%s.%s" % (str(profile.user.username), filename = download(args["i"], "/tmp/%s-%s.%s" % (str(profile.user.username),
@ -350,7 +351,7 @@ def process_action(request, view, handle, action):
import threading import threading
def background(): def background():
try: try:
import_file(db, filename, lambda n: n) # callback import_file(db, filename, gui.user.User()) # callback
except: except:
message = "import_file failed: " + traceback.format_exc() message = "import_file failed: " + traceback.format_exc()
request.user.message_set.create(message = message) request.user.message_set.create(message = message)
@ -359,7 +360,7 @@ def process_action(request, view, handle, action):
request.user.message_set.create(message = message) request.user.message_set.create(message = message)
return redirect("/report/") return redirect("/report/")
else: else:
success = import_file(db, filename, lambda n: n) # callback success = import_file(db, filename, gui.user.User()) # callback
if not success: if not success:
message = "Failed to load imported." message = "Failed to load imported."
request.user.message_set.create(message = message) request.user.message_set.create(message = message)