Example #1
0
def notify_new_reply_by_email(reply):
    helprequest = reply.helprequest

    recipient = None
    if reply.author != helprequest.requester:
        recipient = helprequest.requester
    elif helprequest.bikeanjo:
        recipient = helprequest.bikeanjo

    if not recipient:
        return

    site = Site.objects.filter(id=settings.SITE_ID).first()
    subject = u'Você recebeu uma nova mensagem de %s!' % reply.author.get_full_name()
    from_email = settings.DEFAULT_FROM_EMAIL
    data = {
        'helprequest': helprequest,
        'recipient': recipient,
        'sender': reply.author,
        'site': site,
    }

    with translation.override(set_language(recipient)):
        template_name = 'emails/new_msg_to_%s.html' % recipient.role
        html = select_template([template_name]).render(data)

        template_name = 'emails/new_msg_to_%s.txt' % recipient.role
        text = select_template([template_name]).render(data)

    msg = EmailMultiAlternatives(subject, text, from_email, [recipient.email])
    msg.attach_alternative(html, "text/html")
    msg.send()
Example #2
0
def notify_requester_about_found_bikeanjo(helprequest):
    site = Site.objects.filter(id=settings.SITE_ID).first()
    from_email = settings.DEFAULT_FROM_EMAIL
    recipient = helprequest.requester

    data = {
        'helprequest': helprequest,
        'recipient': recipient,
        'site': site,
    }

    with translation.override(set_language(recipient)):
        subject = _(
            'Bike Anjo found someone to help you on your request #%(id)d!') % {
                'id': helprequest.id
            }

        template_name = 'emails/found_bikeanjo.html'
        html = select_template([template_name]).render(data)

        template_name = 'emails/found_bikeanjo.txt'
        text = select_template([template_name]).render(data)

        msg = EmailMultiAlternatives(subject, text, from_email,
                                     [recipient.email])
        msg.attach_alternative(html, "text/html")
        msg.send()
Example #3
0
def enqueue_30days_notification_for_closed_requests(helprequest):
    site = Site.objects.filter(id=settings.SITE_ID).first()
    subject = u'Seu pedido #%d foi atendido?' % helprequest.id
    from_email = settings.DEFAULT_FROM_EMAIL
    recipient = helprequest.requester
    tag = '30_days_closed_%d' % helprequest.id

    data = {
        'helprequest': helprequest,
        'recipient': recipient,
        'site': site,
    }

    mail = QueuedMail.objects.filter(tag=tag).first()
    if mail:
        return mail

    with translation.override(set_language(recipient)):
        template_name = 'emails/30days_notification_for_closed_requests.html'
        html = select_template([template_name]).render(data)

        template_name = 'emails/30days_notification_for_closed_requests.txt'
        text = select_template([template_name]).render(data)

    return QueuedMail.objects.create(
        to=recipient,
        date=(now() + timedelta(30)).date(),
        subject=subject,
        html_content=html,
        text_content=text,
        tag=tag
    )
Example #4
0
def enqueue_15days_notification_for_open_requests(helprequest):
    site = Site.objects.filter(id=settings.SITE_ID).first()
    subject = _('Did you answer the request #%d?') % helprequest.id
    from_email = settings.DEFAULT_FROM_EMAIL
    recipient = helprequest.bikeanjo
    tag = '15_days_open_%d' % helprequest.id

    data = {
        'helprequest': helprequest,
        'recipient': recipient,
        'site': site,
    }

    mail = QueuedMail.objects.filter(tag=tag).first()
    if mail:
        return mail

    with translation.override(set_language(recipient)):
        template_name = 'emails/15days_notification_for_open_requests.html'
        html = select_template([template_name]).render(data)

        template_name = 'emails/15days_notification_for_open_requests.txt'
        text = select_template([template_name]).render(data)

    return QueuedMail.objects.create(
        to=recipient,
        date=(now() + timedelta(15)).date(),
        subject=subject,
        html_content=html,
        text_content=text,
        tag=tag
    )
Example #5
0
def notify_that_bikeanjo_cannot_help_anymore(helprequest, bikeanjo):
    site = Site.objects.filter(id=settings.SITE_ID).first()
    from_email = settings.DEFAULT_FROM_EMAIL
    helprequest = helprequest
    recipient = helprequest.requester

    data = {
        'helprequest': helprequest,
        'recipient': recipient,
        'site': site,
    }

    with translation.override(set_language(recipient)):
        subject = _('Your request #%(id)d was cancelled by %(ba)s!') % {
            'id': helprequest.id,
            'ba': bikeanjo.first_name
        }

        template_name = 'emails/request_canceled_by_bikeanjo.html'
        html = select_template([template_name]).render(data)

        template_name = 'emails/request_canceled_by_bikeanjo.txt'
        text = select_template([template_name]).render(data)

        msg = EmailMultiAlternatives(subject, text, from_email,
                                     [recipient.email])
        msg.attach_alternative(html, "text/html")
        msg.send()
Example #6
0
def enqueue_15days_notification_for_open_requests(helprequest):
    site = Site.objects.filter(id=settings.SITE_ID).first()
    subject = _('Did you answer the request #%d?') % helprequest.id
    from_email = settings.DEFAULT_FROM_EMAIL
    recipient = helprequest.bikeanjo
    tag = '15_days_open_%d' % helprequest.id

    data = {
        'helprequest': helprequest,
        'recipient': recipient,
        'site': site,
    }

    mail = QueuedMail.objects.filter(tag=tag).first()
    if mail:
        return mail

    with translation.override(set_language(recipient)):
        template_name = 'emails/15days_notification_for_open_requests.html'
        html = select_template([template_name]).render(data)

        template_name = 'emails/15days_notification_for_open_requests.txt'
        text = select_template([template_name]).render(data)

    return QueuedMail.objects.create(to=recipient,
                                     date=(now() + timedelta(15)).date(),
                                     subject=subject,
                                     html_content=html,
                                     text_content=text,
                                     tag=tag)
Example #7
0
def notify_requester_about_attended_request(helprequest):
    site = Site.objects.filter(id=settings.SITE_ID).first()
    from_email = settings.DEFAULT_FROM_EMAIL
    recipient = helprequest.requester

    data = {
        'helprequest': helprequest,
        'recipient': recipient,
        'site': site,
    }

    with translation.override(set_language(recipient)):
        subject = _(
            'Was you request #%(id)d at Bike Anjo attended by %(ba)s?') % {
                'id': helprequest.id,
                'ba': helprequest.bikeanjo.get_full_name()
            }

        template_name = 'emails/request_attended.html'
        html = select_template([template_name]).render(data)

        template_name = 'emails/request_attended.txt'
        text = select_template([template_name]).render(data)

        msg = EmailMultiAlternatives(subject, text, from_email,
                                     [recipient.email])
        msg.attach_alternative(html, "text/html")
        msg.send()
Example #8
0
def notify_bikeanjo_about_new_request(helprequest):
    site = Site.objects.filter(id=settings.SITE_ID).first()
    from_email = settings.DEFAULT_FROM_EMAIL
    recipient = helprequest.bikeanjo

    data = {
        'helprequest': helprequest,
        'recipient': recipient,
        'site': site,
    }

    with translation.override(set_language(recipient)):
        subject = _('You have a new request for help #%(id)d!') % {
            'id': helprequest.id
        }

        template_name = 'emails/new_request.html'
        html = select_template([template_name]).render(data)

        template_name = 'emails/new_request.txt'
        text = select_template([template_name]).render(data)

        msg = EmailMultiAlternatives(subject, text, from_email,
                                     [recipient.email])
        msg.attach_alternative(html, "text/html")
        msg.send()
Example #9
0
def notify_user_subscribed_in_newsletter(subscriber):
    site = Site.objects.filter(id=settings.SITE_ID).first()
    subject = 'Você se inscreveu para o boletim do Bikeanjo!'
    from_email = settings.DEFAULT_FROM_EMAIL
    recipient = subscriber

    data = {
        'site': site,
        'subscriber': subscriber,
    }

    with translation.override(set_language(recipient)):
        template_name = 'emails/newsletter_subscription.txt'
        text = select_template([template_name]).render(data)

    msg = EmailMultiAlternatives(subject, text, from_email, [recipient.email])
    msg.send()
Example #10
0
def notify_bikeanjo_about_new_request(helprequest):
    site = Site.objects.filter(id=settings.SITE_ID).first()
    subject = 'Você recebeu um pedido #%d de ajuda!' % helprequest.id
    from_email = settings.DEFAULT_FROM_EMAIL
    recipient = helprequest.bikeanjo

    data = {
        'helprequest': helprequest,
        'recipient': recipient,
        'site': site,
    }

    with translation.override(set_language(recipient)):
        template_name = 'emails/new_request.html'
        html = select_template([template_name]).render(data)

        template_name = 'emails/new_request.txt'
        text = select_template([template_name]).render(data)

    msg = EmailMultiAlternatives(subject, text, from_email, [recipient.email])
    msg.attach_alternative(html, "text/html")
    msg.send()
Example #11
0
def notify_requester_about_found_bikeanjo(helprequest):
    site = Site.objects.filter(id=settings.SITE_ID).first()
    subject = 'O Bike Anjo achou alguém para te ajudar com o pedido #%d!' % helprequest.id
    from_email = settings.DEFAULT_FROM_EMAIL
    recipient = helprequest.requester

    data = {
        'helprequest': helprequest,
        'recipient': recipient,
        'site': site,
    }

    with translation.override(set_language(recipient)):
        template_name = 'emails/found_bikeanjo.html'
        html = select_template([template_name]).render(data)

        template_name = 'emails/found_bikeanjo.txt'
        text = select_template([template_name]).render(data)

    msg = EmailMultiAlternatives(subject, text, from_email, [recipient.email])
    msg.attach_alternative(html, "text/html")
    msg.send()
Example #12
0
def notify_that_bikeanjo_canceled_request_by_inactivity(helprequest, bikeanjo):
    site = Site.objects.filter(id=settings.SITE_ID).first()
    subject = u'Seu pedido #%d foi cancelado por %s!' % (helprequest.id, bikeanjo.first_name)
    from_email = settings.DEFAULT_FROM_EMAIL
    recipient = helprequest.requester

    data = {
        'helprequest': helprequest,
        'recipient': recipient,
        'site': site,
    }

    with translation.override(set_language(recipient)):
        template_name = 'emails/request_canceled_by_inactivity.html'
        html = select_template([template_name]).render(data)

        template_name = 'emails/request_canceled_by_inactivity.txt'
        text = select_template([template_name]).render(data)

    msg = EmailMultiAlternatives(subject, text, from_email, [recipient.email])
    msg.attach_alternative(html, "text/html")
    msg.send()
Example #13
0
def notify_requester_about_attended_request(helprequest):
    site = Site.objects.filter(id=settings.SITE_ID).first()
    subject = u'Seu pedido #%d de Bike Anjo foi atendido por %s?' % (helprequest.id, helprequest.bikeanjo.get_full_name())
    from_email = settings.DEFAULT_FROM_EMAIL
    recipient = helprequest.requester

    data = {
        'helprequest': helprequest,
        'recipient': recipient,
        'site': site,
    }

    with translation.override(set_language(recipient)):
        template_name = 'emails/request_attended.html'
        html = select_template([template_name]).render(data)

        template_name = 'emails/request_attended.txt'
        text = select_template([template_name]).render(data)

    msg = EmailMultiAlternatives(subject, text, from_email, [recipient.email])
    msg.attach_alternative(html, "text/html")
    msg.send()
Example #14
0
def notify_cant_find_bikeanjo(helprequest):
    site = Site.objects.filter(id=settings.SITE_ID).first()
    subject = 'Ainda não achamos seu bike anjo, mas queremos te ajudar!'
    from_email = settings.DEFAULT_FROM_EMAIL
    recipient = helprequest.requester

    data = {
        'helprequest': helprequest,
        'recipient': recipient,
        'site': site,
    }

    with translation.override(set_language(recipient)):
        template_name = 'emails/cant_find_bikeanjo.html'
        html = select_template([template_name]).render(data)

        template_name = 'emails/cant_find_bikeanjo.txt'
        text = select_template([template_name]).render(data)

    msg = EmailMultiAlternatives(subject, text, from_email, [recipient.email])
    msg.attach_alternative(html, "text/html")
    msg.send()
Example #15
0
def notify_requester_about_found_bikeanjo(helprequest):
    site = Site.objects.filter(id=settings.SITE_ID).first()
    from_email = settings.DEFAULT_FROM_EMAIL
    recipient = helprequest.requester

    data = {
        'helprequest': helprequest,
        'recipient': recipient,
        'site': site,
    }

    with translation.override(set_language(recipient)):
        subject = _('Bike Anjo found someone to help you on your request #%(id)d!') % {'id': helprequest.id}

        template_name = 'emails/found_bikeanjo.html'
        html = select_template([template_name]).render(data)

        template_name = 'emails/found_bikeanjo.txt'
        text = select_template([template_name]).render(data)

        msg = EmailMultiAlternatives(subject, text, from_email, [recipient.email])
        msg.attach_alternative(html, "text/html")
        msg.send()
Example #16
0
def notify_cant_find_bikeanjo(helprequest):
    site = Site.objects.filter(id=settings.SITE_ID).first()
    from_email = settings.DEFAULT_FROM_EMAIL
    recipient = helprequest.requester

    data = {
        'helprequest': helprequest,
        'recipient': recipient,
        'site': site,
    }

    with translation.override(set_language(recipient)):
        subject = _('We can\'t find a bike anjo yet, but we want to help you!')

        template_name = 'emails/cant_find_bikeanjo.html'
        html = select_template([template_name]).render(data)

        template_name = 'emails/cant_find_bikeanjo.txt'
        text = select_template([template_name]).render(data)

        msg = EmailMultiAlternatives(subject, text, from_email,
                                     [recipient.email])
        msg.attach_alternative(html, "text/html")
        msg.send()
Example #17
0
def notify_new_reply_by_email(reply):
    helprequest = reply.helprequest

    recipient = None
    if reply.author != helprequest.requester:
        recipient = helprequest.requester
    elif helprequest.bikeanjo:
        recipient = helprequest.bikeanjo

    if not recipient:
        return

    site = Site.objects.filter(id=settings.SITE_ID).first()
    from_email = settings.DEFAULT_FROM_EMAIL
    data = {
        'helprequest': helprequest,
        'recipient': recipient,
        'sender': reply.author,
        'site': site,
    }

    with translation.override(set_language(recipient)):
        subject = _('You have a new message from %(user)s!') % {
            'user': reply.author.get_full_name()
        }

        template_name = 'emails/new_msg_to_%s.html' % recipient.role
        html = select_template([template_name]).render(data)

        template_name = 'emails/new_msg_to_%s.txt' % recipient.role
        text = select_template([template_name]).render(data)

        msg = EmailMultiAlternatives(subject, text, from_email,
                                     [recipient.email])
        msg.attach_alternative(html, "text/html")
        msg.send()
Example #18
0
def notify_that_bikeanjo_cannot_help_anymore(helprequest, bikeanjo):
    site = Site.objects.filter(id=settings.SITE_ID).first()
    from_email = settings.DEFAULT_FROM_EMAIL
    helprequest = helprequest
    recipient = helprequest.requester

    data = {
        'helprequest': helprequest,
        'recipient': recipient,
        'site': site,
    }

    with translation.override(set_language(recipient)):
        subject = _('Your request #%(id)d was cancelled by %(ba)s!') % {'id': helprequest.id, 'ba': bikeanjo.first_name}

        template_name = 'emails/request_canceled_by_bikeanjo.html'
        html = select_template([template_name]).render(data)

        template_name = 'emails/request_canceled_by_bikeanjo.txt'
        text = select_template([template_name]).render(data)

        msg = EmailMultiAlternatives(subject, text, from_email, [recipient.email])
        msg.attach_alternative(html, "text/html")
        msg.send()