def report_template_list(self, report_dashboard_id=None, only_is_visible_on_report_dashboard=None): """ Assumes validated scope / permission Seems to make sense to use self here since we are only running this if validated right? only_is_visible_on_report_dashboard is None because we have default list of all reports, but then on dashboard we can set this to True Want to keep these queries separate because they are likely to expand in different directions / have different optimizations for example default reports relatively static and the filtering doesn't really relate to the concerns for the normal custom reports """ custom_reports_list = ReportTemplate.list( session=self.session, scope=self.scope, project=self.project, return_kind="objects", report_dashboard_id=report_dashboard_id, only_is_visible_on_report_dashboard= only_is_visible_on_report_dashboard) default_reports_list = ReportTemplate.list_default_reports( session=self.session, only_is_visible_on_report_dashboard= only_is_visible_on_report_dashboard) return custom_reports_list + default_reports_list
def get_existing_report_template(self, report_template_id): """ Not for saving, case of just getting, don't want to have optinal saving path here since we expect to error if report doesn't exist etc. """ self.report_template = ReportTemplate.get_by_id(session=self.session, id=report_template_id)
def get_from_id_or_new_report_template(self, report_template_id: int, project=None) -> ReportTemplate: """ Pattern where creating a "new" one really just does the ID and the rest if part of update process? """ if report_template_id: report_template = ReportTemplate.get_by_id(session=self.session, id=report_template_id) if report_template is None: self.log['error'][ 'report_template'] = "Invalid report_template ID" return return report_template else: return ReportTemplate.new(member=self.member, project=project)