コード例 #1
0
 def final_notify(self):
     if self.final_notification_sent:
         return
     self.refresh_documents()
     for code, info in self.info_by_code.items():
         str(self.final_notification_email[code])
     if len(self.additional_people_to_notify):
         str(self.final_notification_email_to_others)
     for code, info in self.info_by_code.items():
         send_email(to=info['signer'],
                    template=self.final_notification_email[code],
                    attachments=self.list_of_documents())
     for person in self.additional_people_to_notify:
         send_email(to=person,
                    template=self.final_notification_email_to_others,
                    attachments=self.list_of_documents())
     self.final_notification_sent = True
     if interface() == 'worker':
         background_response()
コード例 #2
0
 def initial_notify(self):
     if self.initial_notification_sent:
         return
     self.rationalize()
     for code, info in self.info_by_code.items():
         if not info['signed']:
             str(self.initial_notification_email[code])
     if len(self.additional_people_to_notify):
         str(self.final_notification_email_to_others)
     for code, info in self.info_by_code.items():
         if not info['signed']:
             send_email(to=info['signer'],
                        template=self.initial_notification_email[code])
     for person in self.additional_people_to_notify:
         send_email(to=person,
                    template=self.final_notification_email_to_others)
     self.initial_notification_sent = True
     if interface() == 'worker':
         background_response()
コード例 #3
0
 def out_for_signature(self):
     if self.initial_notification_triggered or self.initial_notification_sent:
         return
     self.rationalize()
     for code, info in self.info_by_code.items():
         if not info['signed']:
             send_email(to=info['signer'],
                        template=self.initial_notification_email[code],
                        dry_run=True)
         send_email(to=info['signer'],
                    template=self.final_notification_email[code],
                    dry_run=True)
     for person in self.additional_people_to_notify:
         send_email(to=person,
                    template=self.final_notification_email_to_others,
                    dry_run=True)
     background_action(self.attr_name('background_initial_notification'))
     self.initial_notification_triggered = True
コード例 #4
0
def send_attachments(name="",
                     court_name="",
                     court_emails=dict(),
                     files=[],
                     submission_id="") -> bool:
    """
  Sends one or nore non-sensitive applications and submission info to the email of the court, court_name

  The email includes the user's name, submission id, and a list of non-sensitive forms. 
  If there are any sensitive forms in the files list, they will not be sent. 
  Instead, the recipient will be instructed to access the submission on our own site.

  Args:
    name (str): the name of the submitter
    court_name (str): the name of the court that should be receiving this email
    court_emails (dict): a dictionary mapping court names to emails
    files (List[DAFile]): a list of DAFiles (possibly sensitive) to be sent
    submission_id (str): the unique id for this submission

  Raises:
    ValueError if court_name is not in the court_emails dict

  Returns (bool):
    True if the email was sent successfully, false otherwise
  """
    if court_name not in court_emails:
        # in our system, this should never happen, but will leave in for debugging
        raise ValueError(f"Court {court_name} does not exist")

    attachments = [
        file for file in files
        if not defined("file.sensitive") or not file.sensitive
    ]
    court_email = court_emails[court_name]

    filenames = [file.filename for file in attachments]
    filenames_str = "\n".join(filenames)
    submission_url = url_for_submission(id=submission_id)

    if len(attachments) != len(files):
        if len(attachments) == 0:
            body = dedent(f"""
      Dear {court_name}:

      {name} has submitted {len(files)} online. However, these file(s) have sensitive information, and will not be sent over email.
      
      Please access these forms with the following submission id: {submission_url}.
      """)

            attachments = None
        else:
            body = dedent(f"""
      Dear {court_name}:
      
      You are receiving {len(attachments)} files from {name}:
      {filenames_str}

      However, there are also {len(files) - len(attachments)} forms which are sensitive that will not be sent over email.

      Please access these forms with the following submission id: {submission_url}.
      """)
    else:
        body = dedent(f"""
    Dear {court_name}:

    You are receiving {len(attachments)} files from {name}:
    {filenames_str}

    The reference ID for these forms is {submission_url}.
    """)

    return send_email(to=court_email,
                      subject=f"Online form submission {submission_id}",
                      body=body,
                      attachments=attachments)