Esempio n. 1
0
def handle_suggestion_comment(request, suggestion, unit, comment, action):
    kwargs = {
        'comment': comment,
        'user': request.user,
    }
    comment_form = UnsecuredCommentForm(suggestion, kwargs)
    if comment_form.is_valid():
        comment_form.save()

        if (action not in ("accepted", "rejected")
                or not settings.POOTLE_EMAIL_FEEDBACK_ENABLED):

            return

        ctx = {
            'suggestion_id': suggestion.id,
            'unit_url': request.build_absolute_uri(unit.get_translate_url()),
            'comment': comment,
        }
        if action == "rejected":
            message = loader.render_to_string(
                'editor/email/suggestion_rejected_with_comment.txt', ctx)
            subject = _(u"Suggestion rejected with comment")
        else:
            message = loader.render_to_string(
                'editor/email/suggestion_accepted_with_comment.txt', ctx)
            subject = _(u"Suggestion accepted with comment")

        send_mail(subject,
                  message,
                  from_email=None,
                  recipient_list=[suggestion.user.email],
                  fail_silently=True)
Esempio n. 2
0
def handle_suggestion_comment(request, suggestion, unit, comment, action):
    kwargs = {
        'comment': comment,
        'user': request.user,
    }
    comment_form = UnsecuredCommentForm(suggestion, kwargs)
    if comment_form.is_valid():
        comment_form.save()

        if (action not in ("accepted", "rejected") or
            not settings.POOTLE_EMAIL_FEEDBACK_ENABLED):

            return

        ctx = {
            'suggestion_id': suggestion.id,
            'unit_url': request.build_absolute_uri(unit.get_translate_url()),
            'comment': comment,
        }
        if action == "rejected":
            message = loader.render_to_string(
                'editor/email/suggestion_rejected_with_comment.txt', ctx)
            subject = _(u"Suggestion rejected with comment")
        else:
            message = loader.render_to_string(
                'editor/email/suggestion_accepted_with_comment.txt', ctx)
            subject = _(u"Suggestion accepted with comment")

        send_mail(subject, message, from_email=None,
                  recipient_list=[suggestion.user.email], fail_silently=True)
Esempio n. 3
0
    def save(self, fail_silently=False):
        """Build and send the email message."""

        kwargs = self.get_message_dict()
        kwargs["headers"] = {"Reply-To": kwargs["from_email"]}
        kwargs["from_email"] = settings.DEFAULT_FROM_EMAIL
        send_mail(fail_silently=fail_silently, **kwargs)
Esempio n. 4
0
def tp_init_failed_async(instance, **kwargs):
    ctx = {"tp": instance}
    message = render_to_string(
        'projects/admin/email/translation_project_creation_failed.txt', ctx)
    subject = _(u"Translation project (%s) creation failed" % instance)
    recipients = get_recipients(instance.project)
    send_mail(subject, message, from_email=None,
              recipient_list=[], fail_silently=True, bcc=recipients)
Esempio n. 5
0
def tp_init_failed_async(instance, **kwargs):
    ctx = {"tp": instance}
    message = render_to_string(
        'projects/admin/email/translation_project_creation_failed.txt', ctx)
    subject = _(u"Translation project (%s) creation failed" % instance)
    recipients = get_recipients(instance.project)
    send_mail(subject, message, from_email=None,
              recipient_list=[], fail_silently=True, bcc=recipients)
Esempio n. 6
0
 def save(self, fail_silently=False):
     """Build and send the email message."""
     reply_to = u'%s <%s>' % (
         self.cleaned_data['name'],
         self.cleaned_data['email'],
     )
     kwargs = self.get_message_dict()
     kwargs["headers"] = {"Reply-To": reply_to}
     send_mail(fail_silently=fail_silently, **kwargs)
Esempio n. 7
0
 def save(self, fail_silently=False):
     """Build and send the email message."""
     reply_to = u'%s <%s>' % (
         self.cleaned_data['name'],
         self.cleaned_data['email'],
     )
     kwargs = self.get_message_dict()
     kwargs["headers"] = {"Reply-To": reply_to}
     send_mail(fail_silently=fail_silently, **kwargs)
Esempio n. 8
0
 def send_mail(self, template, subject, suggester, suggestions, comment):
     send_mail(
         subject,
         self.get_email_message(
             suggestions,
             comment,
             template),
         from_email=None,
         recipient_list=[suggester.email],
         fail_silently=True)
Esempio n. 9
0
def tp_inited_async_handler(**kwargs):
    instance = kwargs["instance"]
    response_url = kwargs["response_url"]
    ctx = {"tp": instance,
           "url": urljoin(response_url, instance.get_absolute_url())}
    message = render_to_string(
        'projects/admin/email/translation_project_created.txt', ctx)
    subject = _(u"Translation project (%s) created" % instance)
    recipients = get_recipients(instance.project)
    send_mail(subject, message, from_email=None,
              recipient_list=[], fail_silently=True, bcc=recipients)
Esempio n. 10
0
def tp_inited_async_handler(**kwargs):
    instance = kwargs["instance"]
    response_url = kwargs["response_url"]
    ctx = {
        "tp": instance,
        "url": urljoin(response_url, instance.get_absolute_url())
    }
    message = render_to_string(
        'projects/admin/email/translation_project_created.txt', ctx)
    subject = _(u"Translation project (%s) created" % instance)
    recipients = get_recipients(instance.project)
    send_mail(subject,
              message,
              from_email=None,
              recipient_list=[],
              fail_silently=True,
              bcc=recipients)
Esempio n. 11
0
 def send_mail(self, template, subject, suggester, suggestions, comment):
     send_mail(subject,
               self.get_email_message(suggestions, comment, template),
               from_email=None,
               recipient_list=[suggester.email],
               fail_silently=True)