Пример #1
0
 def testGetApplicationNoReplyEmail(self):
   """Tests that a correct no-reply email is returned."""
   if self.default_application_id is None:
     let_current_app_id = 'test-app-run'
     try:
       os.environ['APPLICATION_ID'] = let_current_app_id
       expected = "no-reply@%s.appspotmail.com" % let_current_app_id
       self.assertEqual(system.getApplicationNoReplyEmail(), expected)
     finally:
       del os.environ['APPILICATION_ID']
   else:
     current_app_id = os.environ['APPLICATION_ID']
     expected = "no-reply@%s.appspotmail.com" % current_app_id
     self.assertEqual(system.getApplicationNoReplyEmail(), expected)
Пример #2
0
 def testGetApplicationNoReplyEmail(self):
     """Tests that a correct no-reply email is returned."""
     if self.default_application_id is None:
         let_current_app_id = 'test-app-run'
         try:
             os.environ['APPLICATION_ID'] = let_current_app_id
             expected = "no-reply@%s.appspotmail.com" % let_current_app_id
             self.assertEqual(system.getApplicationNoReplyEmail(), expected)
         finally:
             del os.environ['APPILICATION_ID']
     else:
         current_app_id = os.environ['APPLICATION_ID']
         expected = "no-reply@%s.appspotmail.com" % current_app_id
         self.assertEqual(system.getApplicationNoReplyEmail(), expected)
Пример #3
0
def getDefaultMailSender(site=None):
  """Returns the sender that currently can be used to send emails.

  Args:
    site: Optional site_model.Site entity. If not supplied, it will be retrieved
      from the datastore or created.

  Returns:
    - A tuple containing (sender_name, sender_address)
  """
  if not site:
    site = site_logic.singleton()

  # check if there is a noreply email address set
  no_reply_email = system.getApplicationNoReplyEmail()

  return (site.site_name, no_reply_email)
Пример #4
0
def getDefaultMailSender(site=None):
    """Returns the sender that currently can be used to send emails.

  Args:
    site: Optional site_model.Site entity. If not supplied, it will be retrieved
      from the datastore or created.

  Returns:
    - A tuple containing (sender_name, sender_address)
  """
    if not site:
        site = site_logic.singleton()

    # check if there is a noreply email address set
    no_reply_email = system.getApplicationNoReplyEmail()

    return (site.site_name, no_reply_email)
Пример #5
0
def request_account_deletion(user):
    """Requests deletion of user's account from application administrators
  by sending them an email.

  This is a temporary method, until we have an automated solution.
  """
    account = accounts.getCurrentAccount(normalize=False)
    sender = system.getApplicationNoReplyEmail()

    subject = ADMIN_REQUEST_EMAIL_SUBJEST % {'url_id': user.url_id}
    body = ADMIN_REQUEST_EMAIL_BODY % {
        'name': user.name,
        'email': account.email(),
        'url_id': user.url_id,
    }

    mail.send_mail_to_admins(sender, subject, body)
Пример #6
0
def getMailContext(to, subject, html, sender=None, bcc=None):
    """Constructs a mail context for the specified arguments.
  """
    if not sender:
        sender = system.getApplicationNoReplyEmail()

    context = {
        'subject': subject,
        'html': html,
        'sender': sender,
    }

    if to:
        context['to'] = to

    if bcc:
        context['bcc'] = bcc

    return context
Пример #7
0
def request_account_deletion(user):
  """Requests deletion of user's account from application administrators
  by sending them an email.

  This is a temporary method, until we have an automated solution.
  """
  account = accounts.getCurrentAccount(normalize=False)
  sender = system.getApplicationNoReplyEmail()

  subject = ADMIN_REQUEST_EMAIL_SUBJEST % {
      'url_id': user.url_id
      }
  body = ADMIN_REQUEST_EMAIL_BODY % {
      'name': user.name,
      'email': account.email(),
      'url_id': user.url_id,
      }

  mail.send_mail_to_admins(sender, subject, body)
Пример #8
0
def getMailContext(to, subject, html, sender=None, bcc=None):
  """Constructs a mail context for the specified arguments.
  """
  if not sender:
    sender = system.getApplicationNoReplyEmail()

  context = {
      'subject': subject,
      'html': html,
      'sender': sender,
  }

  if to:
    context['to'] = to

  if bcc:
    context['bcc'] = bcc

  return context