def _mails(self, users_and_watches): revision = self.revision document = revision.document log.debug('Sending ready for review email for revision (id=%s)' % revision.id) subject = _lazy(u'{title} is ready for review ({creator})') url = reverse('wiki.review_revision', locale=document.locale, args=[document.slug, revision.id]) context = context_dict(revision) context['revision_url'] = add_utm(url, 'wiki-ready-review') context['locale'] = document.locale context['title'] = document.title context['creator'] = revision.creator context['comment'] = revision.comment users = [] for u, w in users_and_watches: if document.allows(u, 'review_revision'): users.append((u, w)) return email_utils.emails_with_users_and_watches( subject=subject, text_template='wiki/email/ready_for_review.ltxt', html_template='wiki/email/ready_for_review.html', context_vars=context, users_and_watches=users, default_locale=document.locale)
def _mails(self, users_and_watches): revision = self.revision document = revision.document log.debug('Sending edited notification email for document (id=%s)' % document.id) subject = _lazy(u'{title} was edited by {creator}') url = reverse('wiki.document_revisions', locale=document.locale, args=[document.slug]) context = context_dict(revision) context['revisions_url'] = url context['locale'] = document.locale context['title'] = document.title context['creator'] = revision.creator context['comment'] = revision.comment return email_utils.emails_with_users_and_watches( subject=subject, text_template='wiki/email/edited.ltxt', html_template='wiki/email/edited.html', context_vars=context, users_and_watches=users_and_watches, default_locale=document.locale)
def _mails(self, users_and_watches): revision = self.revision document = revision.document log.debug("Sending ready for review email for revision (id=%s)" % revision.id) subject = _lazy(u"{title} is ready for review ({creator})") url = reverse( "wiki.review_revision", locale=document.locale, args=[document.slug, revision.id], ) context = context_dict(revision) context["revision_url"] = add_utm(url, "wiki-ready-review") context["locale"] = document.locale context["title"] = document.title context["creator"] = revision.creator context["comment"] = revision.comment users = [] for u, w in users_and_watches: if document.allows(u, "review_revision"): users.append((u, w)) return email_utils.emails_with_users_and_watches( subject=subject, text_template="wiki/email/ready_for_review.ltxt", html_template="wiki/email/ready_for_review.html", context_vars=context, users_and_watches=users, default_locale=document.locale, )
def _mails(self, users_and_watches): revision = self.revision document = revision.document log.debug( "Sending edited notification email for document (id=%s)" % document.id ) subject = _lazy(u"{title} was edited by {creator}") url = reverse( "wiki.document_revisions", locale=document.locale, args=[document.slug] ) context = context_dict(revision) context["revisions_url"] = add_utm(url, "wiki-edit") context["locale"] = document.locale context["title"] = document.title context["creator"] = revision.creator context["comment"] = revision.comment return email_utils.emails_with_users_and_watches( subject=subject, text_template="wiki/email/edited.ltxt", html_template="wiki/email/edited.html", context_vars=context, users_and_watches=users_and_watches, default_locale=document.locale, )
def _mails(self, users_and_watches): c = {'post': self.post.content, 'post_html': self.post.content_parsed, 'author': self.post.author.username, 'host': Site.objects.get_current().domain, 'thread': self.post.thread.title, 'forum': self.post.thread.forum.name, 'post_url': self.post.thread.get_absolute_url()} return emails_with_users_and_watches( subject=_lazy(u'{forum} - {thread}'), text_template='forums/email/new_thread.ltxt', html_template='forums/email/new_thread.html', context_vars=c, users_and_watches=users_and_watches)
def _mails(self, users_and_watches): post_url = add_utm(self.reply.get_absolute_url(), 'forums-post') c = {'post': self.reply.content, 'post_html': self.reply.content_parsed, 'author': self.reply.author, 'host': Site.objects.get_current().domain, 'thread': self.reply.thread.title, 'forum': self.reply.thread.forum.name, 'post_url': post_url} return emails_with_users_and_watches( subject=_lazy(u'Re: {forum} - {thread}'), text_template='forums/email/new_post.ltxt', html_template='forums/email/new_post.html', context_vars=c, users_and_watches=users_and_watches)
def new_thread_mails(post, users_and_watches): """Return an interable of EmailMessages to send when a new thread is created.""" c = {'post': post.content, 'post_html': post.content_parsed, 'author': post.creator.username, 'host': Site.objects.get_current().domain, 'thread': post.thread.title, 'forum': post.thread.document.title, 'post_url': post.thread.get_absolute_url()} return emails_with_users_and_watches( subject=_lazy(u'{forum} - {thread}'), text_template='kbforums/email/new_thread.ltxt', html_template='kbforums/email/new_thread.html', context_vars=c, users_and_watches=users_and_watches)
def _mails(self, users_and_watches): post_url = add_utm(self.reply.get_absolute_url(), 'forums-post') c = { 'post': self.reply.content, 'post_html': self.reply.content_parsed, 'author': self.reply.author, 'host': Site.objects.get_current().domain, 'thread': self.reply.thread.title, 'forum': self.reply.thread.forum.name, 'post_url': post_url } return emails_with_users_and_watches( subject=_lazy('Re: {forum} - {thread}'), text_template='forums/email/new_post.ltxt', html_template='forums/email/new_post.html', context_vars=c, users_and_watches=users_and_watches)
def new_post_mails(reply, users_and_watches): """Return an interable of EmailMessages to send when a new post is created.""" c = { 'post': reply.content, 'post_html': reply.content_parsed, 'author': reply.creator.username, 'host': Site.objects.get_current().domain, 'thread': reply.thread.title, 'forum': reply.thread.document.title, 'post_url': reply.get_absolute_url() } return emails_with_users_and_watches( subject=_lazy(u'Re: {forum} - {thread}'), text_template='kbforums/email/new_post.ltxt', html_template='kbforums/email/new_post.html', context_vars=c, users_and_watches=users_and_watches)
def new_post_mails(reply, users_and_watches): """Return an interable of EmailMessages to send when a new post is created.""" post_url = add_utm(reply.get_absolute_url(), 'kbforums-post') c = {'post': reply.content, 'post_html': reply.content_parsed, 'author': reply.creator, 'host': Site.objects.get_current().domain, 'thread': reply.thread.title, 'forum': reply.thread.document.title, 'post_url': post_url} return emails_with_users_and_watches( subject=_lazy(u'Re: {forum} - {thread}'), text_template='kbforums/email/new_post.ltxt', html_template='kbforums/email/new_post.html', context_vars=c, users_and_watches=users_and_watches)
def new_thread_mails(post, users_and_watches): """Return an interable of EmailMessages to send when a new thread is created.""" post_url = add_utm(post.thread.get_absolute_url(), 'kbforums-thread') c = {'post': post.content, 'post_html': post.content_parsed, 'author': post.creator, 'host': Site.objects.get_current().domain, 'thread': post.thread.title, 'forum': post.thread.document.title, 'post_url': post_url} return emails_with_users_and_watches( subject=_lazy(u'{forum} - {thread}'), text_template='kbforums/email/new_thread.ltxt', html_template='kbforums/email/new_thread.html', context_vars=c, users_and_watches=users_and_watches)
def test_styles_inlining(self): """Test that styles tags are converted to inline styles""" with patch('kitsune.sumo.email_utils.render_to_string') as mocked: mocked.return_value = ('<html>' '<head>' '<style>a { color: #000; }</style>' '</head>' '<body>' '<a href="/test">Hyperlink</a>' '</body>' '</html>') u = UserFactory() msg = emails_with_users_and_watches('test', 'a.ltxt', 'a.html', {}, [(u, [None])]) for m in msg: tag = ('<a href="https://%s/test" style="color:#000">Hyperlink</a>') self.assertIn(tag % Site.objects.get_current().domain, str(m.message()))
def test_styles_inlining(self): """Test that styles tags are converted to inline styles""" with patch("kitsune.sumo.email_utils.render_to_string") as mocked: mocked.return_value = ("<html>" "<head>" "<style>a { color: #000; }</style>" "</head>" "<body>" '<a href="/test">Hyperlink</a>' "</body>" "</html>") u = UserFactory() msg = emails_with_users_and_watches("test", "a.ltxt", "a.html", {}, [(u, [None])]) for m in msg: tag = '<a href="https://%s/test" style="color:#000">Hyperlink</a>' self.assertIn(tag % Site.objects.get_current().domain, str(m.message()))
def _mails(self, users_and_watches): post_url = add_utm(self.post.thread.get_absolute_url(), "forums-thread") c = { "post": self.post.content, "post_html": self.post.content_parsed, "author": self.post.author, "host": Site.objects.get_current().domain, "thread": self.post.thread.title, "forum": self.post.thread.forum.name, "post_url": post_url, } return emails_with_users_and_watches( subject=_lazy("{forum} - {thread}"), text_template="forums/email/new_thread.ltxt", html_template="forums/email/new_thread.html", context_vars=c, users_and_watches=users_and_watches, )
def _mails(self, users_and_watches): """Send readiness mails.""" revision = self.revision document = revision.document log.debug('Sending ready notifications for revision (id=%s)' % revision.id) subject = _lazy(u'{title} has a revision ready for localization') context = context_dict(revision, ready_for_l10n=True) context['l10n_url'] = django_reverse('wiki.select_locale', args=[document.slug]) context['title'] = document.title return email_utils.emails_with_users_and_watches( subject=subject, text_template='wiki/email/ready_for_l10n.ltxt', html_template='wiki/email/ready_for_l10n.html', context_vars=context, users_and_watches=users_and_watches, default_locale=document.locale)
def test_styles_inlining(self): """Test that styles tags are converted to inline styles""" with patch('jingo.render_to_string') as mocked: mocked.return_value = ('<html>' '<head>' '<style>a { color: #000; }</style>' '</head>' '<body>' '<a href="/test">Hyperlink</a>' '</body>' '</html>') u = user(save=True) msg = emails_with_users_and_watches('test', 'a.ltxt', 'a.html', {}, [(u, [None])]) for m in msg: tag = ('<a href="https://%s/test" style="color:#000">' 'Hyperlink</a>') self.assertIn(tag % Site.objects.get_current().domain, str(m.message()))
def new_thread_mails(post, users_and_watches): """Return an interable of EmailMessages to send when a new thread is created.""" post_url = add_utm(post.thread.get_absolute_url(), "kbforums-thread") c = { "post": post.content, "post_html": post.content_parsed, "author": post.creator, "host": Site.objects.get_current().domain, "thread": post.thread.title, "forum": post.thread.document.title, "post_url": post_url, } return emails_with_users_and_watches( subject=_lazy("{forum} - {thread}"), text_template="kbforums/email/new_thread.ltxt", html_template="kbforums/email/new_thread.html", context_vars=c, users_and_watches=users_and_watches, )
def _mails(self, users_and_watches): """Send readiness mails.""" revision = self.revision document = revision.document log.debug("Sending ready notifications for revision (id=%s)" % revision.id) subject = _lazy(u"{title} has a revision ready for localization") url = django_reverse("wiki.translate", args=[document.slug]) context = context_dict(revision, ready_for_l10n=True) context["l10n_url"] = add_utm(url, "wiki-ready-l10n") context["title"] = document.title return email_utils.emails_with_users_and_watches( subject=subject, text_template="wiki/email/ready_for_l10n.ltxt", html_template="wiki/email/ready_for_l10n.html", context_vars=context, users_and_watches=users_and_watches, default_locale=document.locale, )
def _mails(self, users_and_watches): revision = self.revision document = revision.document log.debug("Sending ready for review email for revision (id={0!s})".format(revision.id)) subject = _lazy(u"{title} is ready for review ({creator})") url = reverse("wiki.review_revision", locale=document.locale, args=[document.slug, revision.id]) context = context_dict(revision) context["revision_url"] = add_utm(url, "wiki-ready-review") context["locale"] = document.locale context["title"] = document.title context["creator"] = revision.creator context["comment"] = revision.comment return email_utils.emails_with_users_and_watches( subject=subject, text_template="wiki/email/ready_for_review.ltxt", html_template="wiki/email/ready_for_review.html", context_vars=context, users_and_watches=users_and_watches, default_locale=document.locale, )
def _mails(self, users_and_watches): """Send readiness mails.""" revision = self.revision document = revision.document log.debug("Sending ready notifications for revision (id={0!s})".format(revision.id)) subject = _lazy(u"{title} has a revision ready for localization") url = django_reverse("wiki.select_locale", args=[document.slug]) context = context_dict(revision, ready_for_l10n=True) context["l10n_url"] = add_utm(url, "wiki-ready-l10n") context["title"] = document.title return email_utils.emails_with_users_and_watches( subject=subject, text_template="wiki/email/ready_for_l10n.ltxt", html_template="wiki/email/ready_for_l10n.html", context_vars=context, users_and_watches=users_and_watches, default_locale=document.locale, )
def _mails(self, users_and_watches): revision = self.revision document = revision.document log.debug("Sending edited notification email for document (id={0!s})".format(document.id)) subject = _lazy(u"{title} was edited by {creator}") url = reverse("wiki.document_revisions", locale=document.locale, args=[document.slug]) context = context_dict(revision) context["revisions_url"] = add_utm(url, "wiki-edit") context["locale"] = document.locale context["title"] = document.title context["creator"] = revision.creator context["comment"] = revision.comment return email_utils.emails_with_users_and_watches( subject=subject, text_template="wiki/email/edited.ltxt", html_template="wiki/email/edited.html", context_vars=context, users_and_watches=users_and_watches, default_locale=document.locale, )
def _mails(self, users_and_watches): revision = self.revision document = revision.document log.debug('Sending edited notification email for document (id=%s)' % document.id) subject = _lazy(u'{title} was edited by {creator}') url = reverse('wiki.document_revisions', locale=document.locale, args=[document.slug]) context = context_dict(revision) context['revisions_url'] = url context['locale'] = document.locale context['title'] = document.title context['creator'] = revision.creator return email_utils.emails_with_users_and_watches( subject=subject, text_template='wiki/email/edited.ltxt', html_template='wiki/email/edited.html', context_vars=context, users_and_watches=users_and_watches, default_locale=document.locale)