Example #1
0
def _send_request_email(context, role, persons, template):
    # if APPROVE_ACCOUNTS_EMAIL and this email to administrator role, use this
    # value instead of emailing individual administrators.
    if role == "administrator" and \
            settings.APPROVE_ACCOUNTS_EMAIL is not None:

        context['receiver'] = None
        context['receiver_text'] = "Administatror"

        to_email = settings.APPROVE_ACCOUNTS_EMAIL
        subject, body = render_email(template, context)

        send_mail(subject, body, settings.ACCOUNTS_EMAIL, [to_email])
        return

    for person in persons:
        if not person.email:
            continue

        context['receiver'] = person
        context['receiver_text'] = person.get_short_name()

        to_email = person.email
        subject, body = render_email(template, context)

        send_mail(subject, body, settings.ACCOUNTS_EMAIL, [to_email])
Example #2
0
def _send_request_email(context, role, persons, template):
    # if APPROVE_ACCOUNTS_EMAIL and this email to administrator role, use this
    # value instead of emailing individual administrators.
    if role == "administrator" and \
            settings.APPROVE_ACCOUNTS_EMAIL is not None:

        context['receiver'] = None
        context['receiver_text'] = "Administrator"

        to_email = settings.APPROVE_ACCOUNTS_EMAIL
        subject, body = render_email(template, context)

        send_mail(subject, body, settings.ACCOUNTS_EMAIL, [to_email])
        return

    for person in persons:
        if not person.email:
            continue

        context['receiver'] = person
        context['receiver_text'] = person.get_short_name()

        to_email = person.email
        subject, body = render_email(template, context)

        send_mail(subject, body, settings.ACCOUNTS_EMAIL, [to_email])
Example #3
0
def send_reset_password_email(person):
    """Sends an email to user allowing them to set their password."""
    context = CONTEXT.copy()
    context.update({
        'url': person.get_password_reset_url(),
        'receiver': person,
    })

    to_email = person.email
    subject, body = render_email('reset_password', context)

    send_mail(subject, body, settings.ACCOUNTS_EMAIL, [to_email])
Example #4
0
def send_confirm_password_email(person):
    """Sends an email to user allowing them to confirm their password."""

    context = CONTEXT.copy()
    context.update({
        'url': '%s/users/%s/login/' % (settings.REGISTRATION_BASE_URL, person.username),
        'receiver': person,
    })

    to_email = person.email
    subject, body = render_email('confirm_password', context)

    send_mail(subject, body, settings.ACCOUNTS_EMAIL, [to_email])
Example #5
0
def send_user_request_email(name, application, request_type, project_name):
    context = CONTEXT.copy()
    context['requester'] = application.applicant
    context['application'] = application
    context['request_type'] = request_type
    context['project_name'] = project_name
    template_name = "user_request_" + name

    if application.applicant and application.applicant.email:

        context['receiver'] = application.applicant
        to_email = application.applicant.email
        subject, body = render_email(template_name, context)

        send_mail(subject, body, settings.ACCOUNTS_EMAIL, [to_email])
Example #6
0
def send_confirm_password_email(person):
    """Sends an email to user allowing them to confirm their password."""
    url = '%s/profile/login/%s/' % (
        settings.REGISTRATION_BASE_URL, person.username)

    context = CONTEXT.copy()
    context.update({
        'url': url,
        'receiver': person,
    })

    to_email = person.email
    subject, body = render_email('confirm_password', context)

    send_mail(subject, body, settings.ACCOUNTS_EMAIL, [to_email])
Example #7
0
def send_user_request_email(name, application, request_type, project_name):
    context = CONTEXT.copy()
    context['requester'] = application.applicant
    context['application'] = application
    context['request_type'] = request_type 
    context['project_name'] = project_name 
    template_name = "user_request_" + name

    if application.applicant and application.applicant.email:

        context['receiver'] = application.applicant
        to_email = application.applicant.email
        subject, body = render_email(template_name, context)

        send_mail(subject, body, settings.ACCOUNTS_EMAIL, [to_email])
Example #8
0
def send_invite_email(application, link, is_secret):
    """ Sends an email inviting someone to create an account"""

    if not application.applicant.email:
        return

    context = CONTEXT.copy()
    context['receiver'] = application.applicant
    context['application'] = application
    context['link'] = link
    context['is_secret'] = is_secret

    to_email = application.applicant.email
    subject, body = render_email('common_invite', context)

    send_mail(subject, body, settings.ACCOUNTS_EMAIL, [to_email])
Example #9
0
def send_approved_email(application, created_person, created_account, link, is_secret):
    """Sends an email informing person application is approved"""
    if not application.applicant.email:
        return

    context = CONTEXT.copy()
    context['receiver'] = application.applicant
    context['application'] = application
    context['created_person'] = created_person
    context['created_account'] = created_account
    context['link'] = link
    context['is_secret'] = is_secret
    subject, body = render_email('common_approved', context)
    to_email = application.applicant.email

    send_mail(subject, body, settings.ACCOUNTS_EMAIL, [to_email])
Example #10
0
def send_invite_email(application, link, is_secret):
    """ Sends an email inviting someone to create an account"""

    if not application.applicant.email:
        return

    context = CONTEXT.copy()
    context['receiver'] = application.applicant
    context['application'] = application
    context['link'] = link
    context['is_secret'] = is_secret

    to_email = application.applicant.email
    subject, body = render_email('common_invite', context)

    send_mail(subject, body, settings.ACCOUNTS_EMAIL, [to_email])
Example #11
0
def send_reset_password_email(person):
    """Sends an email to user allowing them to set their password."""
    uid = urlsafe_base64_encode(force_bytes(person.pk))
    token = default_token_generator.make_token(person)
    url = '%s/persons/reset/%s/%s/' % (
        settings.REGISTRATION_BASE_URL, uid, token)

    context = CONTEXT.copy()
    context.update({
        'url': url,
        'receiver': person,
    })

    to_email = person.email
    subject, body = render_email('reset_password', context)

    send_mail(subject, body, settings.ACCOUNTS_EMAIL, [to_email])
Example #12
0
def send_reset_password_email(person):
    """Sends an email to user allowing them to set their password."""
    uid = urlsafe_base64_encode(force_bytes(person.pk)).decode("ascii")
    token = default_token_generator.make_token(person)
    url = '%s/persons/reset/%s/%s/' % (
        settings.REGISTRATION_BASE_URL, uid, token)

    context = CONTEXT.copy()
    context.update({
        'url': url,
        'receiver': person,
    })

    to_email = person.email
    subject, body = render_email('reset_password', context)

    send_mail(subject, body, settings.ACCOUNTS_EMAIL, [to_email])
Example #13
0
def send_approved_email(application, created_person, created_account, link,
                        is_secret):
    """Sends an email informing person application is approved"""
    if not application.applicant.email:
        return

    context = CONTEXT.copy()
    context['receiver'] = application.applicant
    context['application'] = application
    context['created_person'] = created_person
    context['created_account'] = created_account
    context['link'] = link
    context['is_secret'] = is_secret
    subject, body = render_email('common_approved', context)
    to_email = application.applicant.email

    send_mail(subject, body, settings.ACCOUNTS_EMAIL, [to_email])
Example #14
0
def send_bounced_warning(person):
    """Sends an email to each project leader for person
    informing them that person's email has bounced"""
    context = CONTEXT.copy()
    context['person'] = person

    for project in person.project_set.all():
        if project.is_active:
            context['project'] = project
            for leader in project.leaders.all():
                context['receiver'] = leader

                to_email = leader.email
                subject = render_to_string('people/emails/bounced_email_subject.txt', context)
                body = render_to_string('people/emails/bounced_email_body.txt', context)
                send_mail(subject.replace('\n', ''), body, settings.ACCOUNTS_EMAIL, [to_email])
                log(None, leader, 2, 'Sent email about bounced emails from %s' % person)
Example #15
0
def send_request_email(authorised_text, authorised_persons, application):
    """Sends an email to admin asking to approve user application"""
    context = CONTEXT.copy()
    context['requester'] = application.applicant
    context['link'] = '%s/applications/%d/' % (settings.REGISTRATION_BASE_URL, application.pk)
    context['application'] = application
    context['authorised_text'] = authorised_text

    for person in authorised_persons:
        if not person.email:
            continue

        context['receiver'] = person

        to_email = person.email
        subject, body = render_email('common_request', context)

        send_mail(subject, body, settings.ACCOUNTS_EMAIL, [to_email])
Example #16
0
def send_request_email(authorised_text, authorised_persons, application, link, is_secret):
    """Sends an email to admin asking to approve user application"""
    context = CONTEXT.copy()
    context["requester"] = application.applicant
    context["link"] = link
    context["is_secret"] = is_secret
    context["application"] = application
    context["authorised_text"] = authorised_text

    for person in authorised_persons:
        if not person.email:
            continue

        context["receiver"] = person

        to_email = person.email
        subject, body = render_email("common_request", context)

        send_mail(subject, body, settings.ACCOUNTS_EMAIL, [to_email])
Example #17
0
def send_bounced_warning(person, leader_list):
    """Sends an email to each project leader for person
    informing them that person's email has bounced"""
    context = CONTEXT.copy()
    context['person'] = person

    for lp in leader_list:
        leader = lp['leader']

        context['project'] = lp['project']
        context['receiver'] = leader

        to_email = leader.email
        subject = render_to_string(
            'karaage/people/emails/bounced_email_subject.txt', context)
        body = render_to_string('karaage/people/emails/bounced_email_body.txt',
                                context)
        send_mail(subject.replace('\n', ''), body, settings.ACCOUNTS_EMAIL,
                  [to_email])
        log.change(leader, 'Sent email about bounced emails from %s' % person)
Example #18
0
def send_request_email(authorised_text, authorised_persons, application, link,
                       is_secret):
    """Sends an email to admin asking to approve user application"""
    context = CONTEXT.copy()
    context['requester'] = application.applicant
    context['link'] = link
    context['is_secret'] = is_secret
    context['application'] = application
    context['authorised_text'] = authorised_text

    for person in authorised_persons:
        if not person.email:
            continue

        context['receiver'] = person

        to_email = person.email
        subject, body = render_email('common_request', context)

        send_mail(subject, body, settings.ACCOUNTS_EMAIL, [to_email])
Example #19
0
def send_bounced_warning(person, leader_list):
    """Sends an email to each project leader for person
    informing them that person's email has bounced"""
    context = CONTEXT.copy()
    context['person'] = person

    for lp in leader_list:
        leader = lp['leader']

        context['project'] = lp['project']
        context['receiver'] = leader

        to_email = leader.email
        subject = render_to_string(
            'karaage/people/emails/bounced_email_subject.txt', context)
        body = render_to_string(
            'karaage/people/emails/bounced_email_body.txt', context)
        send_mail(
            subject.replace('\n', ''), body,
            settings.ACCOUNTS_EMAIL, [to_email])
        log.change(
            leader,
            'Sent email about bounced emails from %s' % person)