예제 #1
0
파일: events.py 프로젝트: huub52/kitsune
        def _make_mail(locale, user, context):
            # Avoid circular import issues
            from kitsune.users.helpers import display_name

            is_asker = asker_id == user.id
            if is_asker:
                subject = _(
                    u'%s posted an answer to your question "%s"'
                    % (display_name(self.answer.creator), self.instance.title)
                )
                text_template = "questions/email/new_answer_to_asker.ltxt"
                html_template = "questions/email/new_answer_to_asker.html"
            else:
                subject = _(u"Re: %s" % self.instance.title)
                text_template = "questions/email/new_answer.ltxt"
                html_template = "questions/email/new_answer.html"

            mail = email_utils.make_mail(
                subject=subject,
                text_template=text_template,
                html_template=html_template,
                context_vars=context,
                from_email="Mozilla Support Forum <*****@*****.**>",
                to_email=user.email,
            )

            return mail
예제 #2
0
파일: events.py 프로젝트: runt18/kitsune
        def _make_mail(locale, user, context):
            # Avoid circular import issues
            from kitsune.users.helpers import display_name

            is_asker = asker_id == user.id
            if is_asker:
                subject = _(u'{0!s} posted an answer to your question "{1!s}"'.format(display_name(self.answer.creator),
                             self.instance.title))
                text_template = 'questions/email/new_answer_to_asker.ltxt'
                html_template = 'questions/email/new_answer_to_asker.html'
            else:
                subject = _(u'Re: {0!s}'.format(self.instance.title))
                text_template = 'questions/email/new_answer.ltxt'
                html_template = 'questions/email/new_answer.html'

            mail = email_utils.make_mail(
                subject=subject,
                text_template=text_template,
                html_template=html_template,
                context_vars=context,
                from_email='Mozilla Support Forum '
                           '<*****@*****.**>',
                to_email=user.email)

            return mail
예제 #3
0
    def _send_mail(locale):
        subject = _(u'[SUMO] You have a new private message from [{sender}]')
        subject = subject.format(sender=inbox_message.sender.username)

        context = {
            'sender':
            inbox_message.sender.username,
            'message':
            inbox_message.message,
            'message_html':
            inbox_message.content_parsed,
            'message_url':
            reverse('messages.read', kwargs={'msgid': inbox_message.id}),
            'unsubscribe_url':
            reverse('users.edit_settings'),
            'host':
            Site.objects.get_current().domain
        }

        mail = make_mail(subject=subject,
                         text_template='messages/email/private_message.ltxt',
                         html_template='messages/email/private_message.html',
                         context_vars=context,
                         from_email=settings.TIDINGS_FROM_ADDRESS,
                         to_email=inbox_message.to.email)

        send_messages([mail])
예제 #4
0
        def _make_mail(locale, user, context):
            # Avoid circular import issues
            from kitsune.users.templatetags.jinja_helpers import display_name

            is_asker = asker_id == user.id
            extra_params = {}
            if is_asker:
                auth_str = get_auth_str(user)
                extra_params['auth'] = auth_str
                subject = _(
                    u'%s posted an answer to your question "%s"' %
                    (display_name(self.answer.creator), self.instance.title))
                text_template = 'questions/email/new_answer_to_asker.ltxt'
                html_template = 'questions/email/new_answer_to_asker.html'
            else:
                subject = _(u'Re: %s' % self.instance.title)
                text_template = 'questions/email/new_answer.ltxt'
                html_template = 'questions/email/new_answer.html'

            for k in ['answer_url', 'helpful_url', 'solution_url']:
                context[k] = add_utm(urlparams(context[k], **extra_params),
                                     'questions-reply')

            mail = email_utils.make_mail(subject=subject,
                                         text_template=text_template,
                                         html_template=html_template,
                                         context_vars=context,
                                         from_email='Mozilla Support Forum '
                                         '<*****@*****.**>',
                                         to_email=user.email)

            return mail
예제 #5
0
    def _send_mail(locale):
        # Avoid circular import issues
        from kitsune.users.helpers import display_name

        subject = _(u'[SUMO] You have a new private message from [{sender}]')
        subject = subject.format(
            sender=display_name(inbox_message.sender))

        msg_url = reverse('messages.read', kwargs={'msgid': inbox_message.id})
        settings_url = reverse('users.edit_settings')

        from kitsune.sumo.helpers import add_utm
        context = {
            'sender': inbox_message.sender,
            'message': inbox_message.message,
            'message_html': inbox_message.content_parsed,
            'message_url': add_utm(msg_url, 'messages-new'),
            'unsubscribe_url': add_utm(settings_url, 'messages-new'),
            'host': Site.objects.get_current().domain}

        mail = make_mail(subject=subject,
                         text_template='messages/email/private_message.ltxt',
                         html_template='messages/email/private_message.html',
                         context_vars=context,
                         from_email=settings.TIDINGS_FROM_ADDRESS,
                         to_email=inbox_message.to.email)

        send_messages([mail])
예제 #6
0
파일: cron.py 프로젝트: 1234-/kitsune
 def _make_answer_email(locale, to):
     return make_mail(subject=_('Thank you for your contribution to Mozilla Support!'),
                      text_template='community/email/first_answer.ltxt',
                      html_template='community/email/first_answer.html',
                      context_vars=context,
                      from_email=settings.TIDINGS_FROM_ADDRESS,
                      to_email=to.email)
예제 #7
0
        def _make_mail(locale, user, context):
            # Avoid circular import issues
            from kitsune.users.helpers import display_name

            is_asker = asker_id == user.id
            if is_asker:
                subject = _(
                    u'%s posted an answer to your question "%s"' %
                    (display_name(self.answer.creator), self.instance.title))
                text_template = 'questions/email/new_answer_to_asker.ltxt'
                html_template = 'questions/email/new_answer_to_asker.html'
            else:
                subject = _(u'Re: %s' % self.instance.title)
                text_template = 'questions/email/new_answer.ltxt'
                html_template = 'questions/email/new_answer.html'

            mail = email_utils.make_mail(subject=subject,
                                         text_template=text_template,
                                         html_template=html_template,
                                         context_vars=context,
                                         from_email='Mozilla Support Forum '
                                         '<*****@*****.**>',
                                         to_email=user.email)

            return mail
예제 #8
0
    def _send_mail(locale):
        # Avoid circular import issues
        from kitsune.users.templatetags.jinja_helpers import display_name

        subject = _("[SUMO] You have a new private message from [{sender}]")
        subject = subject.format(sender=display_name(inbox_message.sender))

        msg_url = reverse("messages.read", kwargs={"msgid": inbox_message.id})
        settings_url = reverse("users.edit_settings")

        from kitsune.sumo.templatetags.jinja_helpers import add_utm

        context = {
            "sender": inbox_message.sender,
            "message": inbox_message.message,
            "message_html": inbox_message.content_parsed,
            "message_url": add_utm(msg_url, "messages-new"),
            "unsubscribe_url": add_utm(settings_url, "messages-new"),
            "host": Site.objects.get_current().domain,
        }

        mail = make_mail(
            subject=subject,
            text_template="messages/email/private_message.ltxt",
            html_template="messages/email/private_message.html",
            context_vars=context,
            from_email=settings.TIDINGS_FROM_ADDRESS,
            to_email=inbox_message.to.email,
        )

        send_messages([mail])
예제 #9
0
 def _make_answer_email(locale, to):
     return make_mail(subject=_('Thank you for your contribution to Mozilla Support!'),
                      text_template='community/email/first_answer.ltxt',
                      html_template='community/email/first_answer.html',
                      context_vars=context,
                      from_email=settings.TIDINGS_FROM_ADDRESS,
                      to_email=to.email)
예제 #10
0
파일: events.py 프로젝트: zu83/kitsune
        def _make_mail(locale, user, context):
            # Avoid circular import issues
            from kitsune.users.templatetags.jinja_helpers import display_name

            is_asker = asker_id == user.id
            if is_asker:
                subject = _(
                    '%s posted an answer to your question "%s"' %
                    (display_name(self.answer.creator), self.instance.title))
                text_template = "questions/email/new_answer_to_asker.ltxt"
                html_template = "questions/email/new_answer_to_asker.html"
            else:
                subject = _("Re: %s" % self.instance.title)
                text_template = "questions/email/new_answer.ltxt"
                html_template = "questions/email/new_answer.html"

            for k in ["answer_url", "helpful_url", "solution_url"]:
                context[k] = add_utm(urlparams(context[k]), "questions-reply")

            mail = email_utils.make_mail(
                subject=subject,
                text_template=text_template,
                html_template=html_template,
                context_vars=context,
                from_email="Mozilla Support Forum "
                "<*****@*****.**>",
                to_email=user.email,
            )

            return mail
예제 #11
0
            def _make_mail(locale):
                mail = email_utils.make_mail(subject=subject,
                                             text_template=text_template,
                                             html_template=html_template,
                                             context_vars=c,
                                             from_email=from_email,
                                             to_email=user.email)

                return mail
예제 #12
0
파일: tasks.py 프로젝트: AndryulE/kitsune
    def _make_mail(locale, context, email):
        mail = email_utils.make_mail(
            subject=_('You have been awarded a badge!'),  # TODO: make this suck less
            text_template='kbadge/email/award_notification.ltxt',
            html_template='kbadge/email/award_notification.html',
            context_vars=context,
            from_email=settings.DEFAULT_FROM_EMAIL,
            to_email=email)

        return mail
예제 #13
0
파일: api.py 프로젝트: MikkCZ/kitsune
        def _make_mail(locale):
            mail = email_utils.make_mail(
                subject=subject,
                text_template='users/email/pw_reset.ltxt',
                html_template='users/email/pw_reset.html',
                context_vars=c,
                from_email=None,
                to_email=profile.user.email)

            return mail
예제 #14
0
파일: models.py 프로젝트: PatMart/kitsune
        def _make_mail(locale):
            mail = email_utils.make_mail(
                subject=subject,
                text_template=text_template,
                html_template=html_template,
                context_vars=email_kwargs,
                from_email=settings.DEFAULT_FROM_EMAIL,
                to_email=send_to)

            return mail
예제 #15
0
파일: views.py 프로젝트: Bisheg/kitsune
    def _make_mail(locale):
        mail = email_utils.make_mail(
            subject=_('Welcome to SUMO!'),
            text_template='users/email/contributor.ltxt',
            html_template='users/email/contributor.html',
            context_vars={'username': request.user.username},
            from_email=settings.DEFAULT_FROM_EMAIL,
            to_email=request.user.email)

        return mail
예제 #16
0
파일: utils.py 프로젝트: sky365365/kitsune
    def _make_mail(locale):
        mail = email_utils.make_mail(
            subject=_('Welcome to SUMO!'),
            text_template='users/email/contributor.ltxt',
            html_template='users/email/contributor.html',
            context_vars={'contributor': user},
            from_email=settings.DEFAULT_FROM_EMAIL,
            to_email=user.email)

        return mail
예제 #17
0
        def _make_mail(locale):
            mail = email_utils.make_mail(
                subject=subject,
                text_template=text_template,
                html_template=html_template,
                context_vars=email_kwargs,
                from_email=settings.DEFAULT_FROM_EMAIL,
                to_email=send_to)

            return mail
예제 #18
0
                    def _make_mail(locale):
                        mail = email_utils.make_mail(
                            subject=subject,
                            text_template='users/email/already_activated.ltxt',
                            html_template='users/email/already_activated.html',
                            context_vars=email_kwargs,
                            from_email=settings.DEFAULT_FROM_EMAIL,
                            to_email=user.email)

                        return mail
예제 #19
0
파일: forms.py 프로젝트: akatsoulas/kitsune
            def _make_mail(locale):
                mail = email_utils.make_mail(
                    subject=subject,
                    text_template=text_template,
                    html_template=html_template,
                    context_vars=c,
                    from_email=from_email,
                    to_email=user.email)

                return mail
예제 #20
0
파일: api.py 프로젝트: pirateyporat/kitsune
        def _make_mail(locale):
            mail = email_utils.make_mail(
                subject=subject,
                text_template='users/email/pw_reset.ltxt',
                html_template='users/email/pw_reset.html',
                context_vars=c,
                from_email=None,
                to_email=profile.user.email)

            return mail
예제 #21
0
파일: views.py 프로젝트: Bisheg/kitsune
                    def _make_mail(locale):
                        mail = email_utils.make_mail(
                            subject=subject,
                            text_template='users/email/already_activated.ltxt',
                            html_template='users/email/already_activated.html',
                            context_vars=email_kwargs,
                            from_email=settings.DEFAULT_FROM_EMAIL,
                            to_email=user.email)

                        return mail
예제 #22
0
파일: views.py 프로젝트: rskumar/kitsune
    def _make_mail(locale):
        mail = email_utils.make_mail(
            subject=_("Welcome to SUMO!"),
            text_template="users/email/contributor.ltxt",
            html_template="users/email/contributor.html",
            context_vars={"username": request.user.username},
            from_email=settings.DEFAULT_FROM_EMAIL,
            to_email=request.user.email,
        )

        return mail
예제 #23
0
    def _make_mail(locale):
        mail = email_utils.make_mail(
            subject=_("Welcome to SUMO!"),
            text_template="users/email/contributor.ltxt",
            html_template="users/email/contributor.html",
            context_vars={"contributor": user},
            from_email=settings.DEFAULT_FROM_EMAIL,
            to_email=user.email,
        )

        return mail
예제 #24
0
    def _make_mail(locale, user):
        subject = _('New announcement for {group}').format(group=group.name)

        mail = make_mail(subject=subject,
                         text_template=text_template,
                         html_template=html_template,
                         context_vars=email_kwargs,
                         from_email=settings.TIDINGS_FROM_ADDRESS,
                         to_email=user.email)

        return mail
예제 #25
0
파일: tasks.py 프로젝트: shuhaowu/kitsune
    def _make_mail(locale, context, email):
        mail = email_utils.make_mail(
            subject=_(
                'You have been awarded a badge!'),  # TODO: make this suck less
            text_template='kbadge/email/award_notification.ltxt',
            html_template='kbadge/email/award_notification.html',
            context_vars=context,
            from_email=settings.DEFAULT_FROM_EMAIL,
            to_email=email)

        return mail
예제 #26
0
        def _make_mail(locale, user, context):
            subject = _(u'Solution found to Firefox Help question')

            mail = email_utils.make_mail(
                subject=subject,
                text_template='questions/email/solution.ltxt',
                html_template='questions/email/solution.html',
                context_vars=context,
                from_email=settings.TIDINGS_FROM_ADDRESS,
                to_email=user.email)

            return mail
예제 #27
0
파일: views.py 프로젝트: chupahanks/kitsune
    def _make_mail(locale):
        mail = email_utils.make_mail(
            # L10n: Thank you so much for your translation work! You're
            # L10n: the best!
            subject=_('Welcome to SUMO!'),
            text_template='users/email/contributor.ltxt',
            html_template='users/email/contributor.html',
            context_vars={'contributor': request.user},
            from_email=settings.DEFAULT_FROM_EMAIL,
            to_email=request.user.email)

        return mail
예제 #28
0
파일: cron.py 프로젝트: Dinodog/kitsune
    def _send_mail(locale, user, context):
        subject = _('[Reviews Pending: %s] SUMO needs your help!' % locale)

        mail = email_utils.make_mail(
            subject=subject,
            text_template='wiki/email/ready_for_review_weekly_digest.ltxt',
            html_template='wiki/email/ready_for_review_weekly_digest.html',
            context_vars=context,
            from_email=settings.TIDINGS_FROM_ADDRESS,
            to_email=user.email)

        email_utils.send_messages([mail])
예제 #29
0
    def _send_mail(locale, user, context):
        subject = _('[Reviews Pending: %s] SUMO needs your help!' % locale)

        mail = email_utils.make_mail(
            subject=subject,
            text_template='wiki/email/ready_for_review_weekly_digest.ltxt',
            html_template='wiki/email/ready_for_review_weekly_digest.html',
            context_vars=context,
            from_email=settings.TIDINGS_FROM_ADDRESS,
            to_email=user.email)

        email_utils.send_messages([mail])
예제 #30
0
    def _make_mail(locale):
        mail = email_utils.make_mail(
            # L10n: Thank you so much for your translation work! You're
            # L10n: the best!
            subject=_('Welcome to SUMO!'),
            text_template='users/email/contributor.ltxt',
            html_template='users/email/contributor.html',
            context_vars={'contributor': request.user},
            from_email=settings.DEFAULT_FROM_EMAIL,
            to_email=request.user.email)

        return mail
예제 #31
0
    def _make_mail(locale, user):
        subject = _('New announcement for {group}').format(
            group=group.name)

        mail = make_mail(subject=subject,
                         text_template=text_template,
                         html_template=html_template,
                         context_vars=email_kwargs,
                         from_email=settings.TIDINGS_FROM_ADDRESS,
                         to_email=user.email)

        return mail
예제 #32
0
파일: events.py 프로젝트: psbots/kitsune
        def _make_mail(locale, user, context):
            subject = _(u'Solution found to Firefox Help question')

            mail = email_utils.make_mail(
                subject=subject,
                text_template='questions/email/solution.ltxt',
                html_template='questions/email/solution.html',
                context_vars=context,
                from_email=settings.TIDINGS_FROM_ADDRESS,
                to_email=user.email)

            return mail
예제 #33
0
        def _send_mail(locale, user, context):
            subject = _('Your username on %s') % site_name

            mail = email_utils.make_mail(
                subject=subject,
                text_template=text_template,
                html_template=html_template,
                context_vars=context,
                from_email=settings.TIDINGS_FROM_ADDRESS,
                to_email=user.email)

            email_utils.send_messages([mail])
예제 #34
0
    def _make_mail(locale, context, email):
        subject = _(u"You were awarded the '{title}' badge!").format(
            title=pgettext('DB: badger.Badge.title', award.badge.title))

        mail = email_utils.make_mail(
            subject=subject,
            text_template='kbadge/email/award_notification.ltxt',
            html_template='kbadge/email/award_notification.html',
            context_vars=context,
            from_email=settings.DEFAULT_FROM_EMAIL,
            to_email=email)

        return mail
예제 #35
0
        def _make_mail(locale, user, watches):
            if is_ready and ReadyRevisionEvent.event_type in (
                    w.event_type for w in watches):
                c = context_dict(revision, ready_for_l10n=True)
                # TODO: Expose all watches
                c["watch"] = watches[0]

                url = reverse("wiki.translate",
                              args=[document.slug],
                              locale=locale)
                c["l10n_url"] = add_utm(url, "wiki-ready-l10n")

                subject = _("{title} has a revision ready for localization")
                text_template = "wiki/email/ready_for_l10n.ltxt"
                html_template = "wiki/email/ready_for_l10n.html"

            else:
                c = context_dict(revision, revision_approved=True)
                approved_url = reverse("wiki.document",
                                       locale=document.locale,
                                       args=[document.slug])

                c["document_url"] = add_utm(approved_url, "wiki-approved")
                # TODO: Expose all watches.
                c["watch"] = watches[0]
                c["reviewer"] = revision.reviewer

                subject = _(
                    "{title} ({locale}) has a new approved revision ({reviewer})"
                )
                text_template = "wiki/email/approved.ltxt"
                html_template = "wiki/email/approved.html"

            subject = subject.format(
                title=document.title,
                reviewer=revision.reviewer.username,
                locale=document.locale,
            )

            mail = email_utils.make_mail(
                subject=subject,
                text_template=text_template,
                html_template=html_template,
                context_vars=c,
                from_email=settings.TIDINGS_FROM_ADDRESS,
                to_email=user.email,
            )

            return mail
예제 #36
0
    def _make_mail(locale, user):
        if revision.is_approved:
            subject = _(u'Your revision has been approved: {title}')
        else:
            subject = _(u'Your revision has been reviewed: {title}')
        subject = subject.format(title=document.title)

        mail = email_utils.make_mail(subject=subject,
                                     text_template='wiki/email/reviewed.ltxt',
                                     html_template='wiki/email/reviewed.html',
                                     context_vars=c,
                                     from_email=settings.TIDINGS_FROM_ADDRESS,
                                     to_email=user.email)

        msgs.append(mail)
예제 #37
0
파일: tasks.py 프로젝트: 1234-/kitsune
    def _make_mail(locale, user):
        if revision.is_approved:
            subject = _(u'Your revision has been approved: {title}')
        else:
            subject = _(u'Your revision has been reviewed: {title}')
        subject = subject.format(title=document.title)

        mail = email_utils.make_mail(
            subject=subject,
            text_template='wiki/email/reviewed.ltxt',
            html_template='wiki/email/reviewed.html',
            context_vars=c,
            from_email=settings.TIDINGS_FROM_ADDRESS,
            to_email=user.email)

        msgs.append(mail)
예제 #38
0
        def _make_mail(locale):
            subject = _('Please confirm your email address')
            context = {
                'activation_url': cls._activation_url(watch),
                'domain': Site.objects.get_current().domain,
                'watch_description': cls.description_of_watch(watch)}

            mail = email_utils.make_mail(
                subject=subject,
                text_template='questions/email/activate_watch.ltxt',
                html_template='questions/email/activate_watch.html',
                context_vars=context,
                from_email=settings.TIDINGS_FROM_ADDRESS,
                to_email=email)

            return mail
예제 #39
0
        def _make_mail(locale):
            subject = _('Please confirm your email address')
            context = {
                'activation_url': cls._activation_url(watch),
                'domain': Site.objects.get_current().domain,
                'watch_description': cls.description_of_watch(watch)}

            mail = email_utils.make_mail(
                subject=subject,
                text_template='questions/email/activate_watch.ltxt',
                html_template='questions/email/activate_watch.html',
                context_vars=context,
                from_email=settings.TIDINGS_FROM_ADDRESS,
                to_email=email)

            return mail
예제 #40
0
파일: events.py 프로젝트: rsajdok/kitsune
        def _make_mail(locale, user, watches):
            if (is_ready and
                    ReadyRevisionEvent.event_type in
                    (w.event_type for w in watches)):
                c = context_dict(revision, ready_for_l10n=True)
                # TODO: Expose all watches
                c['watch'] = watches[0]

                url = django_reverse(
                    'wiki.select_locale', args=[document.slug])
                c['l10n_url'] = add_utm(url, 'wiki-ready-l10n')

                subject = _(u'{title} has a revision ready for '
                            'localization')
                text_template = 'wiki/email/ready_for_l10n.ltxt'
                html_template = 'wiki/email/ready_for_l10n.html'

            else:
                c = context_dict(revision, revision_approved=True)
                approved_url = reverse('wiki.document',
                                       locale=document.locale,
                                       args=[document.slug])

                c['document_url'] = add_utm(approved_url, 'wiki-approved')
                # TODO: Expose all watches.
                c['watch'] = watches[0]
                c['reviewer'] = revision.reviewer

                subject = _(u'{title} ({locale}) has a new approved '
                            'revision ({reviewer})')
                text_template = 'wiki/email/approved.ltxt'
                html_template = 'wiki/email/approved.html'

            subject = subject.format(
                title=document.title,
                reviewer=revision.reviewer.username,
                locale=document.locale)

            mail = email_utils.make_mail(
                subject=subject,
                text_template=text_template,
                html_template=html_template,
                context_vars=c,
                from_email=settings.TIDINGS_FROM_ADDRESS,
                to_email=user.email)

            return mail
예제 #41
0
파일: events.py 프로젝트: 1234-/kitsune
        def _make_mail(locale, user, watches):
            if (is_ready and
                    ReadyRevisionEvent.event_type in
                    (w.event_type for w in watches)):
                c = context_dict(revision, ready_for_l10n=True)
                # TODO: Expose all watches
                c['watch'] = watches[0]

                url = django_reverse(
                    'wiki.select_locale', args=[document.slug])
                c['l10n_url'] = add_utm(url, 'wiki-ready-l10n')

                subject = _(u'{title} has a revision ready for '
                            'localization')
                text_template = 'wiki/email/ready_for_l10n.ltxt'
                html_template = 'wiki/email/ready_for_l10n.html'

            else:
                c = context_dict(revision, revision_approved=True)
                approved_url = reverse('wiki.document',
                                       locale=document.locale,
                                       args=[document.slug])

                c['document_url'] = add_utm(approved_url, 'wiki-approved')
                # TODO: Expose all watches.
                c['watch'] = watches[0]
                c['reviewer'] = revision.reviewer

                subject = _(u'{title} ({locale}) has a new approved '
                            'revision ({reviewer})')
                text_template = 'wiki/email/approved.ltxt'
                html_template = 'wiki/email/approved.html'

            subject = subject.format(
                title=document.title,
                reviewer=revision.reviewer.username,
                locale=document.locale)

            mail = email_utils.make_mail(
                subject=subject,
                text_template=text_template,
                html_template=html_template,
                context_vars=c,
                from_email=settings.TIDINGS_FROM_ADDRESS,
                to_email=user.email)

            return mail
예제 #42
0
파일: tasks.py 프로젝트: tobbi/kitsune
    def _make_mail(locale, user):
        if revision.is_approved:
            subject = _(u"A revision you contributed to has " "been approved: {title}")
        else:
            subject = _(u"A revision you contributed to has " "been reviewed: {title}")
        subject = subject.format(title=document.title)

        mail = email_utils.make_mail(
            subject=subject,
            text_template=text_template,
            html_template=html_template,
            context_vars=c,
            from_email=settings.TIDINGS_FROM_ADDRESS,
            to_email=user.email,
        )

        msgs.append(mail)
예제 #43
0
    def _make_mail(locale, user):
        if revision.is_approved:
            subject = _(u'A revision you contributed to has '
                        'been approved: {title}')
        else:
            subject = _(u'A revision you contributed to has '
                        'been reviewed: {title}')
        subject = subject.format(title=document.title)

        mail = email_utils.make_mail(subject=subject,
                                     text_template=text_template,
                                     html_template=html_template,
                                     context_vars=c,
                                     from_email=settings.TIDINGS_FROM_ADDRESS,
                                     to_email=user.email)

        msgs.append(mail)
예제 #44
0
파일: events.py 프로젝트: huub52/kitsune
        def _make_mail(locale):
            subject = _("Please confirm your email address")
            context = {
                "activation_url": cls._activation_url(watch),
                "domain": Site.objects.get_current().domain,
                "watch_description": cls.description_of_watch(watch),
            }

            mail = email_utils.make_mail(
                subject=subject,
                text_template="questions/email/activate_watch.ltxt",
                html_template="questions/email/activate_watch.html",
                context_vars=context,
                from_email=settings.TIDINGS_FROM_ADDRESS,
                to_email=email,
            )

            return mail
예제 #45
0
파일: events.py 프로젝트: zu83/kitsune
        def _make_mail(locale):
            subject = _("Please confirm your email address")
            context = {
                "activation_url": cls._activation_url(watch),
                "domain": Site.objects.get_current().domain,
                "watch_description": cls.description_of_watch(watch),
            }

            mail = email_utils.make_mail(
                subject=subject,
                text_template="questions/email/activate_watch.ltxt",
                html_template="questions/email/activate_watch.html",
                context_vars=context,
                from_email=settings.TIDINGS_FROM_ADDRESS,
                to_email=email,
            )

            return mail
예제 #46
0
파일: tasks.py 프로젝트: GabiThume/kitsune
    def _send_mail(locale):
        subject = _(u'[SUMO] You have a new private message from [{sender}]')
        subject = subject.format(sender=inbox_message.sender.username)

        context = {
            'sender': inbox_message.sender.username,
            'message': inbox_message.message,
            'message_html': inbox_message.content_parsed,
            'message_url': reverse('messages.read',
                                   kwargs={'msgid': inbox_message.id}),
            'unsubscribe_url': reverse('users.edit_settings'),
            'host': Site.objects.get_current().domain}

        mail = make_mail(subject=subject,
                         text_template='messages/email/private_message.ltxt',
                         html_template='messages/email/private_message.html',
                         context_vars=context,
                         from_email=settings.TIDINGS_FROM_ADDRESS,
                         to_email=inbox_message.to.email)

        send_messages([mail])
예제 #47
0
파일: events.py 프로젝트: songfj/kitsune
        def _make_mail(locale, user, context):
            is_asker = asker_id == user.id
            if is_asker:
                subject = _(u'%s posted an answer to your question "%s"' %
                            (self.answer.creator.username,
                             self.instance.title))
                text_template = 'questions/email/new_answer_to_asker.ltxt'
                html_template = 'questions/email/new_answer_to_asker.html'
            else:
                subject = _(u'Re: %s' % self.instance.title)
                text_template = 'questions/email/new_answer.ltxt'
                html_template = 'questions/email/new_answer.html'

            mail = email_utils.make_mail(
                subject=subject,
                text_template=text_template,
                html_template=html_template,
                context_vars=context,
                from_email='Mozilla Support Forum <*****@*****.**>',
                to_email=user.email)

            return mail
예제 #48
0
파일: events.py 프로젝트: AndryulE/kitsune
        def _make_mail(locale, user, context):
            is_asker = asker_id == user.id
            if is_asker:
                subject = _(u'%s posted an answer to your question "%s"' %
                            (self.answer.creator.username, self.instance.title))
                text_template = 'questions/email/new_answer_to_asker.ltxt'
                html_template = 'questions/email/new_answer_to_asker.html'
            else:
                subject = _(u'%s commented on a Firefox question '
                            "you're watching" % self.answer.creator.username)
                text_template = 'questions/email/new_answer.ltxt'
                html_template = 'questions/email/new_answer.html'

            mail = email_utils.make_mail(
                subject=subject,
                text_template=text_template,
                html_template=html_template,
                context_vars=context,
                from_email=settings.TIDINGS_FROM_ADDRESS,
                to_email=user.email)

            return mail
예제 #49
0
        def _make_mail(locale, user, context):
            is_asker = asker_id == user.id
            if is_asker:
                subject = _(u'%s posted an answer to your question "%s"' %
                            (self.answer.creator.username,
                             self.instance.title))
                text_template = 'questions/email/new_answer_to_asker.ltxt'
                html_template = 'questions/email/new_answer_to_asker.html'
            else:
                subject = _(u'Re: %s' % self.instance.title)
                text_template = 'questions/email/new_answer.ltxt'
                html_template = 'questions/email/new_answer.html'

            mail = email_utils.make_mail(
                subject=subject,
                text_template=text_template,
                html_template=html_template,
                context_vars=context,
                from_email='Mozilla Support Forum <*****@*****.**>',
                to_email=user.email)

            return mail
예제 #50
0
파일: events.py 프로젝트: runt18/kitsune
        def _make_mail(locale, user, watches):
            if is_ready and ReadyRevisionEvent.event_type in (w.event_type for w in watches):
                c = context_dict(revision, ready_for_l10n=True)
                # TODO: Expose all watches
                c["watch"] = watches[0]

                url = django_reverse("wiki.select_locale", args=[document.slug])
                c["l10n_url"] = add_utm(url, "wiki-ready-l10n")

                subject = _(u"{title} has a revision ready for " "localization")
                text_template = "wiki/email/ready_for_l10n.ltxt"
                html_template = "wiki/email/ready_for_l10n.html"

            else:
                c = context_dict(revision, revision_approved=True)
                approved_url = reverse("wiki.document", locale=document.locale, args=[document.slug])

                c["document_url"] = add_utm(approved_url, "wiki-approved")
                # TODO: Expose all watches.
                c["watch"] = watches[0]
                c["reviewer"] = revision.reviewer

                subject = _(u"{title} ({locale}) has a new approved " "revision ({reviewer})")
                text_template = "wiki/email/approved.ltxt"
                html_template = "wiki/email/approved.html"

            subject = subject.format(title=document.title, reviewer=revision.reviewer.username, locale=document.locale)

            mail = email_utils.make_mail(
                subject=subject,
                text_template=text_template,
                html_template=html_template,
                context_vars=c,
                from_email=settings.TIDINGS_FROM_ADDRESS,
                to_email=user.email,
            )

            return mail
예제 #51
0
파일: events.py 프로젝트: psbots/kitsune
        def _make_mail(locale, user, context):
            is_asker = asker_id == user.id
            if is_asker:
                subject = _(
                    u'%s posted an answer to your question "%s"' %
                    (self.answer.creator.username, self.instance.title))
                text_template = 'questions/email/new_answer_to_asker.ltxt'
                html_template = 'questions/email/new_answer_to_asker.html'
            else:
                subject = _(u'%s commented on a Firefox question '
                            "you're watching" % self.answer.creator.username)
                text_template = 'questions/email/new_answer.ltxt'
                html_template = 'questions/email/new_answer.html'

            mail = email_utils.make_mail(
                subject=subject,
                text_template=text_template,
                html_template=html_template,
                context_vars=context,
                from_email=settings.TIDINGS_FROM_ADDRESS,
                to_email=user.email)

            return mail
예제 #52
0
def send_welcome_emails():
    """Send a welcome email to first time contributors.

    Anyone who has made a contribution more than 24 hours ago and has not
    already gotten a welcome email should get a welcome email.
    """

    wait_period = datetime.now() - timedelta(hours=24)
    messages = []
    context = {
        'host': Site.objects.get_current().domain,
    }

    # Answers

    answer_filter = Q(created__lte=wait_period)
    answer_filter &= ~Q(question__creator=F('creator'))
    answer_filter &= Q(creator__profile__first_answer_email_sent=False)

    answer_recipient_ids = set(
        Answer.objects
        .filter(answer_filter)
        .values_list('creator', flat=True))

    @safe_translation
    def _make_answer_email(locale, to):
        return make_mail(subject=_('Thank you for your contribution to Mozilla Support!'),
                         text_template='community/email/first_answer.ltxt',
                         html_template='community/email/first_answer.html',
                         context_vars=context,
                         from_email=settings.TIDINGS_FROM_ADDRESS,
                         to_email=to.email)

    for user in User.objects.filter(id__in=answer_recipient_ids):
        messages.append(_make_answer_email(user.profile.locale, user))

    # Localization

    l10n_filter = Q(created__lte=wait_period)
    l10n_filter &= ~Q(document__locale=settings.WIKI_DEFAULT_LANGUAGE)
    l10n_filter &= Q(creator__profile__first_l10n_email_sent=False)

    l10n_recipient_ids = set(
        Revision.objects
        .filter(l10n_filter)
        .values_list('creator', flat=True))

    # This doesn't need localized, and so don't need the `safe_translation` helper.
    for user in User.objects.filter(id__in=l10n_recipient_ids):
        messages.append(make_mail(
            subject='Thank you for your contribution to Mozilla Support!',
            text_template='community/email/first_l10n.ltxt',
            html_template='community/email/first_l10n.html',
            context_vars=context,
            from_email=settings.TIDINGS_FROM_ADDRESS,
            to_email=user.email))

    # Release the Kraken!
    send_messages(messages)

    Profile.objects.filter(user__id__in=answer_recipient_ids).update(first_answer_email_sent=True)
    Profile.objects.filter(user__id__in=l10n_recipient_ids).update(first_l10n_email_sent=True)
예제 #53
0
파일: cron.py 프로젝트: 1234-/kitsune
def send_welcome_emails():
    """Send a welcome email to first time contributors.

    Anyone who has made a contribution more than 24 hours ago and has not
    already gotten a welcome email should get a welcome email.
    """

    wait_period = datetime.now() - timedelta(hours=24)
    messages = []
    context = {
        'host': Site.objects.get_current().domain,
    }

    # Answers

    answer_filter = Q(created__lte=wait_period)
    answer_filter &= ~Q(question__creator=F('creator'))
    answer_filter &= Q(creator__profile__first_answer_email_sent=False)

    answer_recipient_ids = set(
        Answer.objects
        .filter(answer_filter)
        .values_list('creator', flat=True))

    @safe_translation
    def _make_answer_email(locale, to):
        return make_mail(subject=_('Thank you for your contribution to Mozilla Support!'),
                         text_template='community/email/first_answer.ltxt',
                         html_template='community/email/first_answer.html',
                         context_vars=context,
                         from_email=settings.TIDINGS_FROM_ADDRESS,
                         to_email=to.email)

    for user in User.objects.filter(id__in=answer_recipient_ids):
        messages.append(_make_answer_email(user.profile.locale, user))

    # Localization

    l10n_filter = Q(created__lte=wait_period)
    l10n_filter &= ~Q(document__locale=settings.WIKI_DEFAULT_LANGUAGE)
    l10n_filter &= Q(creator__profile__first_l10n_email_sent=False)

    l10n_recipient_ids = set(
        Revision.objects
        .filter(l10n_filter)
        .values_list('creator', flat=True))

    # This doesn't need localized, and so don't need the `safe_translation` helper.
    for user in User.objects.filter(id__in=l10n_recipient_ids):
        messages.append(make_mail(
            subject='Thank you for your contribution to Mozilla Support!',
            text_template='community/email/first_l10n.ltxt',
            html_template='community/email/first_l10n.html',
            context_vars=context,
            from_email=settings.TIDINGS_FROM_ADDRESS,
            to_email=user.email))

    # Release the Kraken!
    send_messages(messages)

    Profile.objects.filter(user__id__in=answer_recipient_ids).update(first_answer_email_sent=True)
    Profile.objects.filter(user__id__in=l10n_recipient_ids).update(first_l10n_email_sent=True)