Better support for report options; added missing tag db functions;
svn: r20075
This commit is contained in:
parent
4168033f83
commit
6ebcc8624e
@ -21,7 +21,10 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<td class="ColumnAttribute">Options:</td>
|
<td class="ColumnAttribute">Options:</td>
|
||||||
<td class="ColumnValue" id="data">
|
<td class="ColumnValue" id="data">
|
||||||
<input autocomplete="off" name="options" id="get_focus" type="text" size="50" value="{% if report.options %}{{report.options}}{% else %}{% endif %}"></input><br>
|
<textarea autocomplete="off" name="options" id="get_focus" cols="70" rows="20">
|
||||||
|
{% if report.options %}{{report.options}}{% else %}{% endif %}
|
||||||
|
</textarea>
|
||||||
|
<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>
|
<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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -32,6 +35,12 @@
|
|||||||
</td>
|
</td>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="ColumnAttribute">Help:</td>
|
||||||
|
<td class="ColumnValue" id="data">
|
||||||
|
{{help|safe}}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
@ -492,6 +492,12 @@ class DbDjango(DbWriteBase, DbReadBase):
|
|||||||
obj = gen.lib.Researcher()
|
obj = gen.lib.Researcher()
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
def get_tag_handles(self, sort_handles=False):
|
||||||
|
if sort_handles:
|
||||||
|
return [item.handle for item in self.dji.Tag.all().order_by("handle")]
|
||||||
|
else:
|
||||||
|
return [item.handle for item in self.dji.Tag.all()]
|
||||||
|
|
||||||
def get_person_handles(self, sort_handles=False):
|
def get_person_handles(self, sort_handles=False):
|
||||||
if sort_handles:
|
if sort_handles:
|
||||||
return [item.handle for item in self.dji.Person.all().order_by("handle")]
|
return [item.handle for item in self.dji.Person.all().order_by("handle")]
|
||||||
@ -593,6 +599,15 @@ class DbDjango(DbWriteBase, DbReadBase):
|
|||||||
return None
|
return None
|
||||||
return self.make_person(person)
|
return self.make_person(person)
|
||||||
|
|
||||||
|
def get_tag_from_handle(self, handle):
|
||||||
|
if handle in self.import_cache:
|
||||||
|
return self.import_cache[handle]
|
||||||
|
try:
|
||||||
|
tag = self.dji.Tag.get(handle=handle)
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
return self.make_tag(tag)
|
||||||
|
|
||||||
def make_repository(self, repository):
|
def make_repository(self, repository):
|
||||||
if self.use_db_cache and repository.cache:
|
if self.use_db_cache and repository.cache:
|
||||||
data = cPickle.loads(base64.decodestring(repository.cache))
|
data = cPickle.loads(base64.decodestring(repository.cache))
|
||||||
|
@ -195,15 +195,17 @@ def process_report_run(request, handle):
|
|||||||
if report.options:
|
if report.options:
|
||||||
for pair in str(report.options).split(" "):
|
for pair in str(report.options).split(" "):
|
||||||
if "=" in pair:
|
if "=" in pair:
|
||||||
key, value = pair.split("=", 1)
|
key, value = [x.strip() for x in pair.split("=", 1)]
|
||||||
|
if key and value:
|
||||||
args[key] = value
|
args[key] = value
|
||||||
# override from options on webpage:
|
# override from options on webpage:
|
||||||
if request.GET.has_key("options"):
|
if request.GET.has_key("options"):
|
||||||
options = str(request.GET.get("options"))
|
options = str(request.GET.get("options"))
|
||||||
if options:
|
if options:
|
||||||
for pair in options.split(" "): # from webpage
|
for pair in options.split("\n"): # from webpage
|
||||||
if "=" in pair:
|
if "=" in pair:
|
||||||
key, value = pair.split("=", 1)
|
key, value = [x.strip() for x in pair.split("=", 1)]
|
||||||
|
if key and value:
|
||||||
args[key] = value
|
args[key] = value
|
||||||
#############################################################################
|
#############################################################################
|
||||||
if report.report_type == "report":
|
if report.report_type == "report":
|
||||||
@ -437,6 +439,7 @@ def action(request, view, handle, act, add_to=None):
|
|||||||
View a particular object given /object/handle (implied view),
|
View a particular object given /object/handle (implied view),
|
||||||
/object/handle/action, or /object/add.
|
/object/handle/action, or /object/add.
|
||||||
"""
|
"""
|
||||||
|
from webapp.reports import get_plugin_options
|
||||||
# redirect:
|
# redirect:
|
||||||
rd = None
|
rd = None
|
||||||
obj = None
|
obj = None
|
||||||
@ -529,11 +532,34 @@ def action(request, view, handle, act, add_to=None):
|
|||||||
view_template = 'view_tag_detail.html'
|
view_template = 'view_tag_detail.html'
|
||||||
rd = process_tag(request, context, handle, act, add_to)
|
rd = process_tag(request, context, handle, act, add_to)
|
||||||
elif view == "report":
|
elif view == "report":
|
||||||
if act not in ["add", "create", "share", "save-share"]:
|
if act not in ["add", "create"]:
|
||||||
try:
|
try:
|
||||||
obj = Report.objects.get(handle=handle)
|
obj = Report.objects.get(handle=handle)
|
||||||
except:
|
except:
|
||||||
raise Http404(_("Requested %s does not exist.") % view)
|
raise Http404(_("Requested %s does not exist.") % view)
|
||||||
|
override = {}
|
||||||
|
if obj.options:
|
||||||
|
for pair in obj.options.split(" "):
|
||||||
|
key, value = pair.split("=")
|
||||||
|
override[key] = value
|
||||||
|
db = DbDjango()
|
||||||
|
opt_default, opt_help = get_plugin_options(db, obj.handle)
|
||||||
|
retval = ""
|
||||||
|
for key in sorted(opt_default.keys()):
|
||||||
|
if key in override:
|
||||||
|
retval += "%s=%s\n" % (key, override[key])
|
||||||
|
del override[key]
|
||||||
|
else:
|
||||||
|
retval += "%s=%s\n" % (key, repr(opt_default[key]))
|
||||||
|
# Any leftover overrides:
|
||||||
|
for key in sorted(override.keys()):
|
||||||
|
retval += "%s=%s\n" % (key, override[key])
|
||||||
|
obj.options = retval
|
||||||
|
retval = "<ol>"
|
||||||
|
for key in sorted(opt_help.keys()):
|
||||||
|
retval += "<li><b>%s</b>: %s</li>\n" % (key, opt_help[key][1])
|
||||||
|
retval += "</ol>"
|
||||||
|
context["help"] = retval
|
||||||
view_template = 'view_report_detail.html'
|
view_template = 'view_report_detail.html'
|
||||||
rd = process_report(request, context, handle, act)
|
rd = process_report(request, context, handle, act)
|
||||||
else:
|
else:
|
||||||
|
@ -41,6 +41,24 @@ import os
|
|||||||
# db = dbdjango.DbDjango()
|
# db = dbdjango.DbDjango()
|
||||||
# run_report(db, "ancestor_report", off="txt", of="ar.txt", pid="I0363")
|
# run_report(db, "ancestor_report", off="txt", of="ar.txt", pid="I0363")
|
||||||
|
|
||||||
|
def get_plugin_options(db, pid):
|
||||||
|
"""
|
||||||
|
Get the default options and help for this plugin.
|
||||||
|
"""
|
||||||
|
dbstate = DbState()
|
||||||
|
climanager = CLIManager(dbstate, False) # do not load db_loader
|
||||||
|
climanager.do_reg_plugins(dbstate, None)
|
||||||
|
pmgr = BasePluginManager.get_instance()
|
||||||
|
pdata = pmgr.get_plugin(pid)
|
||||||
|
if hasattr(pdata, "optionclass") and pdata.optionclass:
|
||||||
|
mod = pmgr.load_plugin(pdata)
|
||||||
|
optionclass = eval("mod." + pdata.optionclass)
|
||||||
|
optioninstance = optionclass("Name", db)
|
||||||
|
optioninstance.load_previous_values()
|
||||||
|
return optioninstance.options_dict, optioninstance.options_help
|
||||||
|
else:
|
||||||
|
return {}, {}
|
||||||
|
|
||||||
def import_file(db, filename, user):
|
def import_file(db, filename, user):
|
||||||
"""
|
"""
|
||||||
Import a file (such as a GEDCOM file) into the given db.
|
Import a file (such as a GEDCOM file) into the given db.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user