Working on running all reports/import/export from the web

svn: r18322
This commit is contained in:
Doug Blank 2011-10-15 14:31:09 +00:00
parent 8fd1b37d86
commit e3f5f4e9c9
4 changed files with 28 additions and 17 deletions

View File

@ -18,7 +18,8 @@
</tr>
<td class="ColumnAttribute">Options:</td>
<td class="ColumnValue" id="data">
<input autocomplete="off" name="options" id="get_focus" type="text" size="50" value="{{search}}"></input>
<input autocomplete="off" name="options" id="get_focus" type="text" size="50" value="{{report.options}}"></input><br>
<i>Hint</i>: use Gramps CLI options such as output file format <b>off=pdf</b>, <b>off=ged</b>, or <b>off=gramps</b>
</td>
</tr>
<td class="ColumnValue" id="data">

View File

@ -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()

View File

@ -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:

View File

@ -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