def send_notification_email(self): if self.reply_to: # It's a reply. reply_url = jinja_helpers.url( 'addons.ratings.detail', self.addon.slug, self.reply_to.pk, add_prefix=False) data = { 'name': self.addon.name, 'reply': self.body, 'rating_url': jinja_helpers.absolutify(reply_url) } recipients = [self.reply_to.user.email] subject = u'Mozilla Add-on Developer Reply: %s' % self.addon.name template = 'ratings/emails/reply_review.ltxt' perm_setting = 'reply' else: # It's a new rating. rating_url = jinja_helpers.url( 'addons.ratings.detail', self.addon.slug, self.pk, add_prefix=False) data = { 'name': self.addon.name, 'rating': self, 'rating_url': jinja_helpers.absolutify(rating_url) } recipients = [author.email for author in self.addon.authors.all()] subject = u'Mozilla Add-on User Rating: %s' % self.addon.name template = 'ratings/emails/new_rating.txt' perm_setting = 'new_review' send_mail_jinja( subject, template, data, recipient_list=recipients, perm_setting=perm_setting)
def send_notification_email(self): if self.reply_to: # It's a reply. reply_url = jinja_helpers.url( 'addons.ratings.detail', self.addon.slug, self.reply_to.pk, add_prefix=False) data = { 'name': self.addon.name, 'reply_title': self.title, 'reply': self.body, 'reply_url': jinja_helpers.absolutify(reply_url) } recipients = [self.reply_to.user.email] subject = u'Mozilla Add-on Developer Reply: %s' % self.addon.name template = 'ratings/emails/reply_review.ltxt' perm_setting = 'reply' else: # It's a new rating. reply_url = jinja_helpers.url( 'addons.ratings.reply', self.addon.slug, self.pk, add_prefix=False) data = { 'name': self.addon.name, 'rating': self, 'reply_url': jinja_helpers.absolutify(reply_url) } recipients = [author.email for author in self.addon.authors.all()] subject = u'Mozilla Add-on User Review: %s' % self.addon.name template = 'ratings/emails/add_review.ltxt' perm_setting = 'new_review' send_mail_jinja( subject, template, data, recipient_list=recipients, perm_setting=perm_setting)
def send_notification_email(self): if self.reply_to: # It's a reply. reply_url = helpers.url("addons.reviews.detail", self.addon.slug, self.reply_to.pk, add_prefix=False) data = { "name": self.addon.name, "reply_title": self.title, "reply": self.body, "reply_url": helpers.absolutify(reply_url), } recipients = [self.reply_to.user.email] subject = u"Mozilla Add-on Developer Reply: %s" % self.addon.name template = "reviews/emails/reply_review.ltxt" perm_setting = "reply" else: # It's a new review. reply_url = helpers.url("addons.reviews.reply", self.addon.slug, self.pk, add_prefix=False) data = { "name": self.addon.name, "rating": "%s out of 5 stars" % self.rating, "review": self.body, "reply_url": helpers.absolutify(reply_url), } recipients = [author.email for author in self.addon.authors.all()] subject = u"Mozilla Add-on User Review: %s" % self.addon.name template = "reviews/emails/add_review.ltxt" perm_setting = "new_review" send_mail_jinja(subject, template, Context(data), recipient_list=recipients, perm_setting=perm_setting)
def mail_thankyou(self, request=None): """ Mail a thankyou note for a completed contribution. Raises a ``ContributionError`` exception when the contribution is not complete or email addresses are not found. """ locale = self._switch_locale() # Thankyous must be enabled. if not self.addon.enable_thankyou: # Not an error condition, just return. return # Contribution must be complete. if not self.transaction_id: raise ContributionError('Transaction not complete') # Send from support_email, developer's email, or default. from_email = settings.DEFAULT_FROM_EMAIL if self.addon.support_email: from_email = str(self.addon.support_email) # We need the contributor's email. to_email = self.post_data['payer_email'] if not to_email: raise ContributionError('Empty payer email') # Make sure the url uses the right language. # Setting a prefixer would be nicer, but that requires a request. url_parts = self.addon.meet_the_dev_url().split('/') url_parts[1] = locale.language subject = _('Thanks for contributing to {addon_name}').format( addon_name=self.addon.name) # Send the email. send_mail_jinja( subject, 'stats/contribution-thankyou-email.ltxt', { 'thankyou_note': bleach.clean(unicode(self.addon.thankyou_note), strip=True), 'addon_name': self.addon.name, 'learn_url': '%s%s?src=emailinfo' % (settings.SITE_URL, '/'.join(url_parts)), 'domain': settings.DOMAIN }, from_email, [to_email], fail_silently=True, perm_setting='dev_thanks')
def send_mail(cleaned_data, theme_lock): """ Send emails out for respective review actions taken on themes. """ with override('en-US'): # Make sure the email is always sent in english. theme = cleaned_data['theme'] action = cleaned_data['action'] comment = cleaned_data['comment'] reject_reason = cleaned_data['reject_reason'] reason = None if reject_reason: reason = rvw.THEME_REJECT_REASONS[reject_reason] elif action == rvw.ACTION_DUPLICATE: reason = _('Duplicate Submission') emails = set(theme.addon.authors.values_list('email', flat=True)) context = { 'theme': theme, 'base_url': settings.SITE_URL, 'reason': reason, 'comment': comment } subject = None if action == rvw.ACTION_APPROVE: subject = _('Thanks for submitting your Theme') template = 'editors/themes/emails/approve.html' elif action in (rvw.ACTION_REJECT, rvw.ACTION_DUPLICATE): subject = _('A problem with your Theme submission') template = 'editors/themes/emails/reject.html' elif action == rvw.ACTION_FLAG: subject = _('Theme submission flagged for review') template = 'editors/themes/emails/flag_reviewer.html' # Send the flagged email to themes email. emails = [settings.THEMES_EMAIL] elif action == rvw.ACTION_MOREINFO: subject = _('A question about your Theme submission') template = 'editors/themes/emails/moreinfo.html' context['reviewer_email'] = theme_lock.reviewer.email send_mail_jinja(subject, template, context, recipient_list=emails, from_email=settings.ADDONS_EMAIL, headers={'Reply-To': settings.THEMES_EMAIL})
def send_mail(cleaned_data, theme_lock): """ Send emails out for respective review actions taken on themes. """ with override('en-US'): # Make sure the email is always sent in english. theme = cleaned_data['theme'] action = cleaned_data['action'] comment = cleaned_data['comment'] reject_reason = cleaned_data['reject_reason'] reason = None if reject_reason: reason = amo.THEME_REJECT_REASONS[reject_reason] elif action == amo.ACTION_DUPLICATE: reason = ugettext('Duplicate Submission') emails = set(theme.addon.authors.values_list('email', flat=True)) context = { 'theme': theme, 'base_url': settings.SITE_URL, 'reason': reason, 'comment': comment } subject = None if action == amo.ACTION_APPROVE: subject = ugettext('Thanks for submitting your Theme') template = 'reviewers/themes/emails/approve.html' elif action in (amo.ACTION_REJECT, amo.ACTION_DUPLICATE): subject = ugettext('A problem with your Theme submission') template = 'reviewers/themes/emails/reject.html' elif action == amo.ACTION_FLAG: subject = ugettext('Theme submission flagged for review') template = 'reviewers/themes/emails/flag_reviewer.html' # Send the flagged email to themes email. emails = [settings.THEMES_EMAIL] elif action == amo.ACTION_MOREINFO: subject = ugettext('A question about your Theme submission') template = 'reviewers/themes/emails/moreinfo.html' context['reviewer_email'] = theme_lock.reviewer.email send_mail_jinja(subject, template, context, recipient_list=emails, from_email=settings.ADDONS_EMAIL, headers={'Reply-To': settings.THEMES_EMAIL})
def mail_thankyou(self, request=None): """ Mail a thankyou note for a completed contribution. Raises a ``ContributionError`` exception when the contribution is not complete or email addresses are not found. """ locale = self._switch_locale() # Thankyous must be enabled. if not self.addon.enable_thankyou: # Not an error condition, just return. return # Contribution must be complete. if not self.transaction_id: raise ContributionError('Transaction not complete') # Send from support_email, developer's email, or default. from_email = settings.DEFAULT_FROM_EMAIL if self.addon.support_email: from_email = str(self.addon.support_email) # We need the contributor's email. to_email = self.post_data['payer_email'] if not to_email: raise ContributionError('Empty payer email') # Make sure the url uses the right language. # Setting a prefixer would be nicer, but that requires a request. url_parts = self.addon.meet_the_dev_url().split('/') url_parts[1] = locale.language subject = _('Thanks for contributing to {addon_name}').format( addon_name=self.addon.name) # Send the email. send_mail_jinja( subject, 'stats/contribution-thankyou-email.ltxt', {'thankyou_note': bleach.clean(unicode(self.addon.thankyou_note), strip=True), 'addon_name': self.addon.name, 'learn_url': '%s%s?src=emailinfo' % (settings.SITE_URL, '/'.join(url_parts)), 'domain': settings.DOMAIN}, from_email, [to_email], fail_silently=True, perm_setting='dev_thanks')
def send_confirmation_email(self): context = { 'api_key_confirmation_link': (absolutify(reverse('devhub.api_key')) + f'?token={self.token}'), 'domain': settings.DOMAIN, } return send_mail_jinja(ugettext('Confirmation for developer API keys'), 'devhub/email/api_key_confirmation.ltxt', context, recipient_list=[self.user.email], countdown=settings.API_KEY_CONFIRMATION_DELAY)