Example #1
0
 def _saveReportFile(self, reports_log, reportDoc):
     """
         Save report xml file
     """
     # gen reports_content
     reports_content = reportDoc.toxml().encode("utf-8")
     # insert into db
     ReportHistory.insert(self.env, reports_log, reports_content, int(time.time()))
Example #2
0
 def _saveReportFile(self, reports_log, reportDoc):
     """
         Save report xml file
     """
     # gen reports_content
     reports_content = reportDoc.toxml().encode("utf-8")
     # insert into db
     ReportHistory.insert(self.env, reports_log, reports_content,
                          int(time.time()))
Example #3
0
    def _getHistoryReports(self, req, historyId):
        """ get history reports """
        reports_content = ReportHistory.fetchById(self.env, historyId)

        # parse reports xml
        reports = self._parseReports(reports_content)

        return reports
Example #4
0
    def _getHistoryReports(self, req, historyId):
        """ get history reports """
        reports_content = ReportHistory.fetchById(self.env, historyId)

        # parse reports xml
        reports = self._parseReports(reports_content)

        return reports
Example #5
0
    def _loadHistory(self, req, loadHistoryId):
        """ load reports history """
        reports_content = ReportHistory.fetchById(self.env, loadHistoryId)

        # parse reports xml
        reports = self._parseReports(reports_content)

        # clean up reports
        self._cleanUpReports()

        # insert reports
        for report in reports:
            self._insertReport(report)
Example #6
0
    def _loadHistory(self, req, loadHistoryId):
        """ load reports history """
        reports_content = ReportHistory.fetchById(self.env, loadHistoryId)

        # parse reports xml
        reports = self._parseReports(reports_content)

        # clean up reports
        self._cleanUpReports()

        # insert reports
        for report in reports:
            self._insertReport(report)
Example #7
0
 def _delHistory(self, req, delHistoryId):
     """ del reports history """
     ReportHistory.delete(self.env, delHistoryId)
Example #8
0
    def render_admin_panel(self, req, cat, page, path_info):
        req.perm.assert_permission('REPORT_ADMIN')

        data = {}

        loadHistoryId = ""
        delHistoryId = ""
        editHistoryId = ""
        for key in req.args.keys():
            if key.startswith("load_"):
                loadHistoryId = key[len("load_"):]
                break

        for key in req.args.keys():
            if key.startswith("del_"):
                delHistoryId = key[len("del_"):]
                break

        for key in req.args.keys():
            if key.startswith("edit_"):
                editHistoryId = key[len("edit_"):]
                break

        # load
        if loadHistoryId:
            self._loadHistory(req, loadHistoryId)
            # redirect to report page
            req.redirect(req.href.report())

        # del
        elif delHistoryId:
            self._delHistory(req, delHistoryId)

        # edit
        elif editHistoryId:

            data['editHistoryId'] = editHistoryId
            data['reports_log'] = ReportHistory.getLogById(
                self.env, editHistoryId)

            reports = self._getHistoryReports(req, editHistoryId)
            report_list = []
            for id, title, description, query in reports:
                report_entry = {}
                report_entry["id"] = id
                report_entry["title"] = title
                report_entry["description"] = description
                report_entry["query"] = query
                report_entry["href"] = req.abs_href.admin(
                    cat, page, {"report_id": id})
                report_list.append(report_entry)

            data['report_list'] = report_list

            return 'editreports.html', data

        # Save
        elif req.args.get('savereport'):
            self._saveHistory(req)

        # apply edit history
        elif req.args.get('applyedit'):
            self._applyHistoryModify(req)

        # apply edit history
        elif req.args.get('cancel'):
            pass

        # prepare template page
        report_history = []
        for id, save_time, reports_log, reports_content in ReportHistory.getReportsHistory(
                self.env):
            history = {}
            history["id"] = id
            history["save_time"] = time.strftime(
                "%Y-%m-%d %H:%M:%S", time.localtime(int(save_time)))
            history["reports_log"] = reports_log
            report_history.append(history)

        report_history.reverse()
        data['report_history'] = report_history

        return 'admin_report.html', data
Example #9
0
 def _delHistory(self, req, delHistoryId):
     """ del reports history """
     ReportHistory.delete(self.env, delHistoryId)
Example #10
0
    def process_admin_request(self, req, cat, page, path_info):
        req.perm.assert_permission('REPORT_ADMIN')

        loadHistoryId = ""
        delHistoryId = ""
        editHistoryId = ""
        for key in req.args.keys():
            if key.startswith("load_"):
                loadHistoryId = key[len("load_"):]
                break

        for key in req.args.keys():
            if key.startswith("del_"):
                delHistoryId = key[len("del_"):]
                break

        for key in req.args.keys():
            if key.startswith("edit_"):
                editHistoryId = key[len("edit_"):]
                break

        # load
        if loadHistoryId:
            self._loadHistory(req, loadHistoryId)
            # redirect to report page
            req.redirect(req.href.report())

        # del
        elif delHistoryId:
            self._delHistory(req, delHistoryId)

        # edit
        elif editHistoryId:

            req.hdf['editHistoryId'] = editHistoryId
            req.hdf['reports_log'] = ReportHistory.getLogById(self.env, editHistoryId)

            reports = self._getHistoryReports(req, editHistoryId)
            report_list = []
            for id, title, description, query in reports:
                report_entry = {}
                report_entry["id"] = id
                report_entry["title"] = title
                report_entry["description"] = description
                report_entry["query"] = query
                report_entry["href"] = req.abs_href.admin(cat, page, {"report_id":id})
                report_list.append(report_entry)
            
            req.hdf['report_list'] = report_list

            return 'editreports.cs', None

        # Save
        elif req.args.get('savereport'):
            self._saveHistory(req)

        # apply edit history
        elif req.args.get('applyedit'):
            self._applyHistoryModify(req)

        # apply edit history
        elif req.args.get('cancel'):
            pass


        # prepare template page
        report_history = []
        for id, save_time, reports_log, reports_content in ReportHistory.getReportsHistory(self.env):
            history = {}
            history["id"] = id
            history["save_time"] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(save_time)))
            history["reports_log"] = reports_log
            report_history.append(history)
        
        report_history.reverse()
        req.hdf['report_history'] = report_history

        return 'admin_report.cs', None