(self, file_type, user=None, queryset=None, asynchronous=False, scheduled=False, email_to:str = None)
Generate this report file
Generate this report file
Generate this report file
def run_report(self, file_type, user=None, queryset=None, asynchronous=False, scheduled=False, email_to:str = None):
        """Generate this report file"""
        if not queryset:
            queryset = self.get_query()

        display_fields = self.get_good_display_fields()

        data_export = DataExportMixin()
        objects_list, message = data_export.report_to_list(
            queryset, display_fields, user, preview=False)
        title = re.sub(r'\W+', '', self.name)[:30]
        header = []
        widths = []
        for field in display_fields:
            header.append(field.name)
            widths.append(field.width)
        if scheduled:
            self.async_report_save(objects_list, title, header, widths, file_type, email_to=email_to)
        elif asynchronous:
            if user is None:
                raise Exception('Cannot run async report without a user')
            self.async_report_save(objects_list, title, header, widths, user, file_type)
        else:
            if file_type == 'csv':
                return data_export.list_to_csv_response(
                    objects_list, title, header, widths)
            else:
                return data_export.list_to_xlsx_response(
                    objects_list, title, header, widths)
def run_report ( self , file_type , user = None , queryset = None , asynchronous = False , scheduled = False , email_to : str = None ) : if not queryset : queryset = self . get_query ( ) display_fields = self . get_good_display_fields ( ) data_export = DataExportMixin ( ) objects_list , message = data_export . report_to_list ( queryset , display_fields , user , preview = False ) title = re . sub ( r'\W+' , '' , self . name ) [ : 30 ] header = [ ] widths = [ ] for field in display_fields : header . append ( field . name ) widths . append ( field . width ) if scheduled : self . async_report_save ( objects_list , title , header , widths , file_type , email_to = email_to ) elif asynchronous : if user is None : raise Exception ( 'Cannot run async report without a user' ) self . async_report_save ( objects_list , title , header , widths , user , file_type ) else : if file_type == 'csv' : return data_export . list_to_csv_response ( objects_list , title , header , widths ) else : return data_export . list_to_xlsx_response ( objects_list , title , header , widths )