本文整理汇总了Python中users.tasks.SendUserEmail类的典型用法代码示例。如果您正苦于以下问题:Python SendUserEmail类的具体用法?Python SendUserEmail怎么用?Python SendUserEmail使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SendUserEmail类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: send_sign_up_notification
def send_sign_up_notification(self):
"""Send sign_up notifications."""
if self.page.slug != 'sign-up':
return
project = self.page.project
is_answer = not self.reply_to
subject = render_to_string("content/emails/sign_up_updated_subject.txt", {
'comment': self,
'is_answer': is_answer,
'project': project,
}).strip()
body = render_to_string("content/emails/sign_up_updated.txt", {
'comment': self,
'is_answer': is_answer,
'project': project,
'domain': Site.objects.get_current().domain,
}).strip()
recipients = {project.created_by.username: project.created_by}
if self.reply_to:
comment = self
while comment.reply_to:
comment = comment.reply_to
recipients[comment.author.username] = comment.author
for username in recipients:
if recipients[username] != self.author:
SendUserEmail.apply_async((recipients[username], subject, body))
开发者ID:AndyHendy,项目名称:lernanta,代码行数:26,代码来源:models.py
示例2: report_abuse
def report_abuse(request, obj, type):
"""Report abusive or irrelavent content."""
if request.method == "POST":
# we only use the form for the csrf middleware. skip validation.
form = AbuseForm(request.POST)
body = """
User %s has reported the following content as objectionable:
Model: %s, ID: %s
""" % (
request.user.get_profile().name,
type,
obj,
)
subject = "Abuse Report"
try:
profile = UserProfile.objects.get(email=settings.ADMINS[0][1])
SendUserEmail.apply_async(args=(profile, subject, body))
except:
pass
return render_to_response("drumbeat/report_received.html", {}, context_instance=RequestContext(request))
else:
form = AbuseForm()
return render_to_response(
"drumbeat/report_abuse.html", {"form": form, "obj": obj, "type": type}, context_instance=RequestContext(request)
)
开发者ID:benrito,项目名称:batucada,代码行数:26,代码来源:views.py
示例3: send_content_notification
def send_content_notification(instance, is_comment):
"""Send notification when a new page or comment is posted."""
project = instance.project
if not is_comment and not instance.listed:
return
ulang = get_language()
subject = {}
body = {}
for l in settings.SUPPORTED_LANGUAGES:
activate(l[0])
subject[l[0]] = render_to_string(
"content/emails/content_update_subject.txt", {
'instance': instance,
'is_comment': is_comment,
'project': project,
}).strip()
body[l[0]] = render_to_string(
"content/emails/content_update.txt", {
'instance': instance,
'is_comment': is_comment,
'project': project,
'domain': Site.objects.get_current().domain,
}).strip()
activate(ulang)
for participation in project.participants():
if instance.author != participation.user and not participation.no_updates:
pl = participation.user.preflang or settings.LANGUAGE_CODE
SendUserEmail.apply_async(
(participation.user, subject[pl], body[pl]))
开发者ID:foxtrotcharlie,项目名称:lernanta,代码行数:29,代码来源:models.py
示例4: publish
def publish(self):
self.is_published = True
self.save()
challenge = self.get_challenge()
# Create activity
msg = '<a href="%s">%s</a>: %s | <a href="%s">Read more</a>' % (
challenge.get_absolute_url(), challenge.title, self.title,
self.get_absolute_url())
status = Status(author=self.created_by,
project=challenge.project,
status=msg)
status.save()
# Send thanks email
user = self.created_by
share_url = reverse('submission_edit_share', kwargs={
'slug': challenge.slug,
'submission_id': self.pk
})
submission_url = reverse('submission_show', kwargs={
'slug': challenge.slug,
'submission_id': self.pk
})
subj = _('Thanks for entering in the Knight-Mozilla Innovation Challenge!')
body = render_to_string('challenges/emails/submission_thanks.txt', {
'share_url': share_url,
'submission_url': submission_url,
})
SendUserEmail.apply_async((user, subj, body))
开发者ID:cillian,项目名称:batucada,代码行数:32,代码来源:models.py
示例5: message_sent_handler
def message_sent_handler(sender, **kwargs):
message = kwargs.get('instance', None)
created = kwargs.get('created', False)
if not created or not isinstance(message, Message):
return
user = message.recipient
preferences = AccountPreferences.objects.filter(
user=user.get_profile())
for preference in preferences:
if preference.value and preference.key == 'no_email_message_received':
return
sender = message.sender.get_profile()
ulang = get_language()
activate(user.get_profile().preflang or settings.LANGUAGE_CODE)
subject = ugettext('New Message from %(sender)s') % {
'sender': sender,
}
body = render_to_string('drumbeatmail/emails/direct_message.txt', {
'sender': sender,
'message': message.body,
'domain': Site.objects.get_current().domain,
'reply_url': reverse('drumbeatmail_reply', kwargs={
'message': message.pk,
}),
})
activate(ulang)
SendUserEmail.apply_async((user.get_profile(), subject, body))
开发者ID:vtamara,项目名称:lernanta,代码行数:27,代码来源:models.py
示例6: send_creation_notification
def send_creation_notification(self):
"""Send notification when a new project is created."""
project = self
ulang = get_language()
subject = {}
body = {}
for l in settings.SUPPORTED_LANGUAGES:
activate(l[0])
subject[l[0]] = render_to_string(
"projects/emails/project_created_subject.txt", {
'project': project,
}).strip()
body[l[0]] = render_to_string(
"projects/emails/project_created.txt", {
'project': project,
'domain': Site.objects.get_current().domain,
}).strip()
activate(ulang)
for organizer in project.organizers():
if not organizer.no_updates:
ol = organizer.user.preflang or settings.LANGUAGE_CODE
SendUserEmail.apply_async(
(organizer.user, subject[ol], body[ol]))
admin_subject = render_to_string(
"projects/emails/admin_project_created_subject.txt", {
'project': project,
}).strip()
admin_body = render_to_string(
"projects/emails/admin_project_created.txt", {
'project': project,
}).strip()
send_mail(admin_subject, admin_body, '[email protected]', ['[email protected]'], fail_silently=True)
开发者ID:MJae,项目名称:lernanta,代码行数:32,代码来源:models.py
示例7: send_wall_notification
def send_wall_notification(self):
"""Send update notifications for messages posted to a study group wall."""
if not self.project:
return
project = self.project
ulang = get_language()
subject = {}
body = {}
for l in settings.SUPPORTED_LANGUAGES:
activate(l[0])
subject[l[0]] = render_to_string(
"statuses/emails/wall_updated_subject.txt", {
'status': self,
'project': project,
}).strip()
body[l[0]] = render_to_string("statuses/emails/wall_updated.txt", {
'status': self,
'project': project,
'domain': Site.objects.get_current().domain,
}).strip()
activate(ulang)
for participation in project.participants():
if self.author != participation.user and (self.important or not participation.no_wall_updates):
pl = participation.user.preflang or settings.LANGUAGE_CODE
SendUserEmail.apply_async(
(participation.user, subject[pl], body[pl]))
开发者ID:MJae,项目名称:lernanta,代码行数:26,代码来源:models.py
示例8: follow_handler
def follow_handler(sender, **kwargs):
rel = kwargs.get("instance", None)
if not isinstance(rel, Relationship):
return
user_subject = _("%(name)s is following you on Drumbeat!" % {"name": rel.source.name})
project_subject = _("%(name)s is following your project on Drumbeat!" % {"name": rel.source.name})
activity = Activity(actor=rel.source, verb="http://activitystrea.ms/schema/1.0/follow")
subject = _(u"%(name)s is now following")
if rel.target_user:
activity.target_user = rel.target_user
user = rel.target_user
pref_key = "no_email_new_follower"
subject = user_subject
else:
activity.project = rel.target_project
user = rel.target_project.created_by
pref_key = "no_email_new_project_follower"
subject = project_subject
activity.save()
preferences = AccountPreferences.objects.filter(user=user)
for pref in preferences:
if pref.value and pref.key == pref_key:
return
body = render_to_string(
"relationships/emails/new_follower.txt", {"user": rel.source, "project": rel.target_project}
)
SendUserEmail.apply_async((user, subject, body))
开发者ID:rossbruniges,项目名称:batucada,代码行数:29,代码来源:models.py
示例9: submission_thanks_handler
def submission_thanks_handler(sender, **kwargs):
submission = kwargs.get('instance', None)
if not isinstance(submission, Submission):
return
challenge = submission.get_challenge()
if not challenge:
return
user = submission.created_by
share_url = reverse('submission_edit_share', kwargs={
'slug': challenge.slug,
'submission_id': submission.pk
})
submission_url = reverse('submission_show', kwargs={
'slug': challenge.slug,
'submission_id': submission.pk
})
subj = _('Thanks for entering in the Knight-Mozilla Innovation Challenge!')
body = render_to_string('challenges/emails/submission_thanks.txt', {
'share_url': share_url,
'submission_url': submission_url,
})
SendUserEmail.apply_async((user, subj, body))
开发者ID:foxtrotcharlie,项目名称:lernanta,代码行数:25,代码来源:models.py
示例10: report_abuse
def report_abuse(request, model, app_label, pk):
"""Report abusive or irrelavent content."""
if request.method == 'POST':
# we only use the form for the csrf middleware. skip validation.
form = AbuseForm(request.POST)
content_type_cls = get_object_or_404(ContentType, model=model, app_label=app_label).model_class()
instance = get_object_or_404(content_type_cls, pk=pk)
try:
url = request.build_absolute_uri(instance.get_absolute_url())
except NoReverseMatch:
url = request.build_absolute_uri(reverse('dashboard_index'))
body = """
User %s has reported the following content as objectionable:
%s
(model: %s, app_label: %s, pk: %s)
""" % (request.user.get_profile().display_name, url, model, app_label, pk)
subject = "Abuse Report"
try:
profile = UserProfile.objects.get(email=settings.ADMINS[0][1])
SendUserEmail.apply_async(args=(profile, subject, body))
except:
pass
return render_to_response('drumbeat/report_received.html', {},
context_instance=RequestContext(request))
else:
form = AbuseForm()
return render_to_response('drumbeat/report_abuse.html', {
'form': form,
'model': model,
'app_label': app_label,
'pk': pk,
}, context_instance=RequestContext(request))
开发者ID:AndyHendy,项目名称:lernanta,代码行数:34,代码来源:views.py
示例11: send_notification
def send_notification(self):
"""Send notification when a new submission is posted."""
context = {
'submission': self,
'domain': Site.objects.get_current().domain,
}
subjects, bodies = localize_email(
'badges/emails/new_submission_subject.txt',
'badges/emails/new_submission.txt', context)
for adopter in self.badge.get_adopters():
SendUserEmail.apply_async((adopter.user, subjects, bodies))
开发者ID:IAmCorbin,项目名称:lernanta,代码行数:11,代码来源:models.py
示例12: send_new_signup_answer_notification
def send_new_signup_answer_notification(answer):
context = {
'answer': answer,
'domain': Site.objects.get_current().domain,
}
subjects, bodies = localize_email(
'signups/emails/new_signup_answer_subject.txt',
'signups/emails/new_signup_answer.txt', context)
for organizer in answer.sign_up.project.organizers():
SendUserEmail.apply_async((organizer.user,
subjects, bodies))
开发者ID:Cyber-World-Uk-Ltd,项目名称:lernanta,代码行数:11,代码来源:models.py
示例13: send_comment_notification
def send_comment_notification(self):
context = {
'comment': self,
'domain': Site.objects.get_current().domain,
}
subjects, bodies = localize_email(
'replies/emails/post_comment_subject.txt',
'replies/emails/post_comment.txt', context)
recipients = self.page_object.comment_notification_recipients(self)
for recipient in recipients:
if self.author != recipient:
SendUserEmail.apply_async((recipient, subjects, bodies))
开发者ID:Cyber-World-Uk-Ltd,项目名称:lernanta,代码行数:12,代码来源:models.py
示例14: follow_handler
def follow_handler(sender, **kwargs):
rel = kwargs.get('instance', None)
created = kwargs.get('created', False)
if not created or not isinstance(rel, Relationship) or rel.deleted:
return
activity = Activity(actor=rel.source,
verb=verbs['follow'],
target_object=rel)
receipts = []
ulang = get_language()
subject = {}
body = {}
if rel.target_user:
for l in settings.SUPPORTED_LANGUAGES:
activate(l[0])
subject[l[0]] = ugettext(
'%(user)s is following you on P2PU!') % {
'user': rel.source}
preferences = AccountPreferences.objects.filter(user=rel.target_user)
for pref in preferences:
if pref.value and pref.key == 'no_email_new_follower':
break
else:
receipts.append(rel.target_user)
else:
activity.scope_object = rel.target_project
for l in settings.SUPPORTED_LANGUAGES:
activate(l[0])
msg = ugettext(
'%(user)s is following %(project)s on P2PU!')
subject[l[0]] = msg % {'user': rel.source,
'project': rel.target_project}
for organizer in rel.target_project.organizers():
if organizer.user != rel.source:
preferences = AccountPreferences.objects.filter(
user=organizer.user, key='no_email_new_project_follower')
for pref in preferences:
if pref.value:
break
else:
receipts.append(organizer.user)
activity.save()
for l in settings.SUPPORTED_LANGUAGES:
activate(l[0])
body[l[0]] = render_to_string(
"relationships/emails/new_follower.txt", {'user': rel.source,
'project': rel.target_project,
'domain': Site.objects.get_current().domain})
activate(ulang)
for user in receipts:
pl = user.preflang or settings.LANGUAGE_CODE
SendUserEmail.apply_async((user, subject[pl], body[pl]))
开发者ID:vtamara,项目名称:lernanta,代码行数:53,代码来源:models.py
示例15: send_wall_notification
def send_wall_notification(self):
"""Send update notifications for messages posted to a study group wall."""
if not self.project:
return
project = self.project
subject = render_to_string(
"statuses/emails/wall_updated_subject.txt", {"status": self, "project": project}
).strip()
body = render_to_string(
"statuses/emails/wall_updated.txt",
{"status": self, "project": project, "domain": Site.objects.get_current().domain},
).strip()
for participation in project.participants():
if self.author != participation.user and (self.important or not participation.no_wall_updates):
SendUserEmail.apply_async((participation.user, subject, body))
if self.author != project.created_by:
SendUserEmail.apply_async((project.created_by, subject, body))
开发者ID:AndyHendy,项目名称:lernanta,代码行数:17,代码来源:models.py
示例16: send_email_notification
def send_email_notification(instance):
project = instance.project
if not instance.listed:
return
context = {
'instance': instance,
'project': project,
'domain': Site.objects.get_current().domain,
}
subjects, bodies = localize_email(
'content/emails/content_update_subject.txt',
'content/emails/content_update.txt', context)
for participation in project.participants():
is_author = (instance.author == participation.user)
if not is_author and not participation.no_updates:
SendUserEmail.apply_async(
(participation.user, subjects, bodies))
开发者ID:ainsleycaroline,项目名称:lernanta,代码行数:17,代码来源:models.py
示例17: send_email_notification
def send_email_notification(instance):
project = instance.project
if not instance.listed:
return
context = {"instance": instance, "project": project, "domain": Site.objects.get_current().domain}
subjects, bodies = localize_email(
"content/emails/content_update_subject.txt", "content/emails/content_update.txt", context
)
from_organizer = project.organizers().filter(user=instance.author).exists()
for participation in project.participants():
is_author = instance.author == participation.user
if from_organizer:
unsubscribed = participation.no_organizers_content_updates
else:
unsubscribed = participation.no_participants_content_updates
if not is_author and not unsubscribed:
SendUserEmail.apply_async((participation.user, subjects, bodies))
开发者ID:pasosdeJesus,项目名称:lernanta,代码行数:17,代码来源:models.py
示例18: send_update_notification
def send_update_notification(self, activity, wall=True):
"""Send update notifications."""
subject = _('[p2pu-%(slug)s-updates] Study group %(name)s was updated') % {
'slug': self.slug,
'name': self.name,
}
body = render_to_string("projects/emails/course_updated.txt", {
'activity': activity,
'project': self,
'wall': wall,
'domain': Site.objects.get_current().domain,
})
for participation in self.participants():
if activity.actor == participation.user:
continue
if (wall and participation.no_wall_updates) or (not wall and participation.no_updates):
continue
SendUserEmail.apply_async((participation.user, subject, body))
if activity.actor != self.created_by:
SendUserEmail.apply_async((self.created_by, subject, body))
开发者ID:Suggsgested,项目名称:lernanta,代码行数:20,代码来源:models.py
示例19: message_sent_handler
def message_sent_handler(sender, **kwargs):
message = kwargs.get("instance", None)
if not isinstance(message, Message):
return
user = message.recipient
preferences = AccountPreferences.objects.filter(user=user.get_profile())
for preference in preferences:
if preference.value and preference.key == "no_email_message_received":
return
sender = message.sender.get_profile().display_name
subject = _("New Message from %(display_name)s" % {"display_name": sender})
body = render_to_string(
"drumbeatmail/emails/direct_message.txt",
{
"sender": sender,
"message": message.body,
"domain": Site.objects.get_current().domain,
"reply_url": reverse("drumbeatmail_reply", kwargs={"message": message.pk}),
},
)
SendUserEmail.apply_async((user.get_profile(), subject, body))
开发者ID:Suggsgested,项目名称:lernanta,代码行数:21,代码来源:models.py
示例20: send_content_notification
def send_content_notification(instance, is_comment):
"""Send notification when a new page or comment is posted."""
project = instance.project
if not is_comment and not instance.listed:
return
subject = render_to_string("content/emails/content_update_subject.txt", {
'instance': instance,
'is_comment': is_comment,
'project': project,
}).strip()
body = render_to_string("content/emails/content_update.txt", {
'instance': instance,
'is_comment': is_comment,
'project': project,
'domain': Site.objects.get_current().domain,
}).strip()
for participation in project.participants():
if instance.author != participation.user and not participation.no_updates:
SendUserEmail.apply_async((participation.user, subject, body))
if instance.author != project.created_by:
SendUserEmail.apply_async((project.created_by, subject, body))
开发者ID:AndyHendy,项目名称:lernanta,代码行数:21,代码来源:models.py
注:本文中的users.tasks.SendUserEmail类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论