Exemple #1
0
 def async_report_save(self, report, objects_list, title, header, widths,
                       user, file_type):
     if file_type == 'csv':
         csv_file = self.list_to_csv_file(objects_list, title, header,
                                          widths)
         title = generate_filename(title, '.csv')
         report.report_file.save(title, ContentFile(csv_file.getvalue()))
     else:
         xlsx_file = self.list_to_xlsx_file(objects_list, title, header,
                                            widths)
         title = generate_filename(title, '.xlsx')
         report.report_file.save(title, ContentFile(xlsx_file.getvalue()))
     report.report_file_creation = datetime.datetime.today()
     report.save()
     if getattr(settings, 'REPORT_BUILDER_EMAIL_NOTIFICATION', False):
         if user.email:
             email_report(report.report_file.url, user)
 def async_report_save(self, report, objects_list,
                       title, header, widths, user, file_type):
     if file_type == 'csv':
         csv_file = self.list_to_csv_file(objects_list, title,
                                          header, widths)
         title = generate_filename(title, '.csv')
         report.report_file.save(title, ContentFile(csv_file.getvalue()))
     else:
         xlsx_file = self.list_to_xlsx_file(objects_list, title,
                                            header, widths)
         title = generate_filename(title, '.xlsx')
         report.report_file.save(title, ContentFile(xlsx_file.getvalue()))
     report.report_file_creation = datetime.datetime.today()
     report.save()
     if getattr(settings, 'REPORT_BUILDER_EMAIL_NOTIFICATION', False):
         if user.email:
             email_report(report.report_file.url, user)
 def async_report_save(self, report, objects_list,
                       title, header, widths, user, file_type):
     if file_type == 'csv':
         csv_file = self.list_to_csv_file(objects_list, title,
                                          header, widths)
         title = generate_filename(title, '.csv')
         report.report_file.save(title, ContentFile(csv_file.getvalue()))
     else:
         xlsx_file = self.list_to_xlsx_file(objects_list, title,
                                            header, widths)
         #title = generate_filename(title, '.xlsx')
         from io import BytesIO
         #wb = load_workbook(filename=BytesIO(input_excel.read()))
         f = open(xlsx_file)
         report.report_file.save(f.name, File(f))
     report.report_file_creation = datetime.datetime.today()
     report.save()
     if getattr(settings, 'REPORT_BUILDER_EMAIL_NOTIFICATION', False):
         if user.email:
             email_report(report.report_file.url, user)