Ejemplo n.º 1
0
    def report(self):
        """This report is too specialized to use the base class version.

        Take off the buttons and add the banners/titles.

        If the user chooses the "by summary title" method for
        selecting which summary to use for the report, and the
        fragment supplied matches more than one summary document,
        display the form a second time so the user can pick the
        summary.
        """

        # Make sure we have something to look for.
        if not self.terms:
            self.bail("At least one search term is required")

        # If the user wants an Excel workbook, create it.
        if self.format == "excel":
            return self.send_workbook()

        # Otherwise, assemble the options for an HTML report.
        if not hasattr(self, "_report"):
            opts = {
                "banner": "Standard Wording Report",
                "footer": self.footer,
                "subtitle": f"Report produced {date.today()}",
                "no_results": self.no_results,
                "page_opts": {
                    "buttons": [],
                    "session": self.session,
                    "action": None,
                }
            }
            self._report = Reporter(self.title, self.tables, **opts)
        return self._report
Ejemplo n.º 2
0
    def create_sheet(self):
        """Create and send an Excel report for the current SQL query."""

        if self.sql:
            title = self.query or "Ad-hoc Query"
            report = Reporter(title, self.table, wrap=False)
            report.send("excel")
        else:
            self.show_form()
Ejemplo n.º 3
0
    def report(self):
        buttons = []
        for button in self.buttons:
            buttons.append(self.HTMLPage.button(button))
        if not hasattr(self, "_report"):
            opts = dict(
                banner=self.title,
                subtitle=self.subtitle,
                page_opts=dict(
                    buttons=buttons,
                    action=self.script,
                    session=self.session,
                ),
            )
            tables = self.build_tables()
            self._report = Reporter(self.title, tables, **opts)
            self._report.page.add_script("""\
function toggle(show, hide) {
    jQuery(show).show();
    jQuery(hide).hide();
}
jQuery(function() {
    jQuery("#idsort .title-col").click(function() {
        toggle("#titlesort", "#idsort");
    });
    jQuery("#titlesort .id-col").click(function() {
        toggle("#idsort", "#titlesort");
    });
    jQuery("#idsort .title-col").addClass("clickable")
    jQuery("#titlesort .id-col").addClass("clickable")
    jQuery("#idsort").hide();
    jQuery("#titlesort").show();
    console.log('ready');
});""")

        return self._report