code: def ajax_recalculate_size(self):
          
          reports = self.get_reports()
          attachments = self.get_attachments()
          total_size = self.get_total_size(reports, attachments)
  
          return {
              "files": len(reports) + len(attachments),
              "size": "%.2f" % total_size,
              "limit": self.max_email_size,
              "limit_exceeded": total_size > self.max_email_size,
          }
docs: Recalculate the total size of the selected attachments