From e3f5f4e9c9986b216a7cbb6c62977536175f332b Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Sat, 15 Oct 2011 14:31:09 +0000 Subject: [PATCH] Working on running all reports/import/export from the web svn: r18322 --- src/data/templates/view_report_detail.html | 3 ++- src/web/dbdjango.py | 14 ++++++------- src/web/grampsdb/views.py | 23 ++++++++++++++-------- src/web/init.py | 5 +++++ 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/data/templates/view_report_detail.html b/src/data/templates/view_report_detail.html index 3abe21d7d..bebfbc390 100644 --- a/src/data/templates/view_report_detail.html +++ b/src/data/templates/view_report_detail.html @@ -18,7 +18,8 @@ Options: - +
+Hint: use Gramps CLI options such as output file format off=pdf, off=ged, or off=gramps diff --git a/src/web/dbdjango.py b/src/web/dbdjango.py index 230feea94..c05770be4 100644 --- a/src/web/dbdjango.py +++ b/src/web/dbdjango.py @@ -21,14 +21,6 @@ """ Implements a Db interface """ -## Major issues to fix: - -## 1) import from GEDCOM is not associating proper gramps handles between objects -## suspect that something not working correct in adding with transactions -## BUG: People event_ref are no longer pointing to correct event, even -## previously-working export to django from gramps gtk -## 2) did export from gramps gtk break with the changes for importing gedcom? - #------------------------------------------------------------------------ # # Gramps Modules @@ -736,6 +728,12 @@ class DbDjango(DbWriteBase, DbReadBase): def get_number_of_people(self): return self.dji.Person.count() + def get_number_of_events(self): + return self.dji.Event.count() + + def get_number_of_places(self): + return self.dji.Place.count() + def get_number_of_tags(self): return 0 # self.dji.Tag.count() diff --git a/src/web/grampsdb/views.py b/src/web/grampsdb/views.py index b00e02beb..b41964014 100644 --- a/src/web/grampsdb/views.py +++ b/src/web/grampsdb/views.py @@ -256,20 +256,27 @@ def process_action(request, view, handle, action): profile = request.user.get_profile() report = Report.objects.get(handle=handle) if action == "run": - args = {} + args = {"off": "pdf"} # basic defaults + # override from given defaults in table: + if report.options: + for pair in str(report.options).split(" "): + if "=" in pair: + key, value = pair.split("=", 1) + args[key] = value + # override from options on webpage: if request.GET.has_key("options"): - options = request.GET.get("options") + options = str(request.GET.get("options")) if options: - for pair in options.split("%3D"): + for pair in options.split("%3D"): # from webpage if "=" in pair: key, value = pair.split("=", 1) - args[str(key)] = str(value) + args[key] = value if report.report_type == "textreport": - filename = "/tmp/%s-%s.pdf" % (str(profile.user.username), str(handle)) - run_report(db, handle, off="pdf", of=filename, **args) - mimetype = 'application/pdf' + filename = "/tmp/%s-%s.%s" % (str(profile.user.username), str(handle), args["off"]) + run_report(db, handle, of=filename, **args) + mimetype = 'application/%s' % args["off"] elif report.report_type == "export": - filename = "/tmp/%s-%s.ged" % (str(profile.user.username), str(handle)) + filename = "/tmp/%s-%s.%s" % (str(profile.user.username), str(handle), args["off"]) export_file(db, filename, lambda n: n) # callback mimetype = 'text/plain' else: diff --git a/src/web/init.py b/src/web/init.py index b4f968f9f..7e7def4a7 100644 --- a/src/web/init.py +++ b/src/web/init.py @@ -111,6 +111,11 @@ for table, entries in [("grampsdb.config", ("report_type", '"textreport"')), (("name", '"GEDCOM Export"'), ("handle", '"gedcom_export"'), + ("options", '"off=ged"'), + ("report_type", '"export"')), + (("name", '"Gramps XML Export"'), + ("handle", '"ex_gpkg"'), + ("options", '"off=gramps"'), ("report_type", '"export"')), ])]: entry_count = 0