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
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
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])
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
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])
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)
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
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])
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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])
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
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])
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
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
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)
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)
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
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
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)
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)
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
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])
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
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
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
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
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)