本文整理汇总了Python中apps.widgets.notifications.models.UserNotification.create_email_notification方法的典型用法代码示例。如果您正苦于以下问题:Python UserNotification.create_email_notification方法的具体用法?Python UserNotification.create_email_notification怎么用?Python UserNotification.create_email_notification使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类apps.widgets.notifications.models.UserNotification
的用法示例。
在下文中一共展示了UserNotification.create_email_notification方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send
# 需要导入模块: from apps.widgets.notifications.models import UserNotification [as 别名]
# 或者: from apps.widgets.notifications.models.UserNotification import create_email_notification [as 别名]
def send(self):
"""
Sends a reminder email to the user.
"""
if not self.sent:
challenge = challenge_mgr.get_challenge()
subject = "[%s] Reminder for %s" % (challenge.name, self.action.title)
message = render_to_string(
"email/activity_reminder.txt",
{
"action": self.action,
"user": self.user,
"COMPETITION_NAME": challenge.name,
"domain": challenge.domain,
},
)
html_message = render_to_string(
"email/activity_reminder.html",
{
"action": self.action,
"user": self.user,
"COMPETITION_NAME": challenge.name,
"domain": challenge.domain,
},
)
UserNotification.create_email_notification(self.email_address, subject, message, html_message)
self.sent = True
self.save()
示例2: _send_winner_notification
# 需要导入模块: from apps.widgets.notifications.models import UserNotification [as 别名]
# 或者: from apps.widgets.notifications.models.UserNotification import create_email_notification [as 别名]
def _send_winner_notification(self, prize, leader):
"""send notification."""
if leader and not self._notification_exists(prize, leader):
# Notify winner using the template.
template = NoticeTemplate.objects.get(notice_type='prize-winner')
message = template.render({'PRIZE': prize})
UserNotification.create_info_notification(leader.user, message, True, prize)
challenge = challenge_mgr.get_challenge()
subject = "[%s] Congratulations, you won a prize!" % challenge.name
UserNotification.create_email_notification(
leader.user.email, subject, message, message)
示例3: notify_winner
# 需要导入模块: from apps.widgets.notifications.models import UserNotification [as 别名]
# 或者: from apps.widgets.notifications.models.UserNotification import create_email_notification [as 别名]
def notify_winner(self, request, queryset):
"""pick winner."""
_ = request
for obj in queryset:
if obj.winner and not self.notice_sent(obj):
# Notify winner using the template.
template = NoticeTemplate.objects.get(notice_type="raffle-winner")
message = template.render({"PRIZE": obj})
UserNotification.create_info_notification(obj.winner, message, True, obj)
challenge = challenge_mgr.get_challenge()
subject = "[%s] Congratulations, you won a prize!" % challenge.name
UserNotification.create_email_notification(obj.winner.email, subject, message, message)
self.message_user(request, "Winners notification sent.")
示例4: notify_winner
# 需要导入模块: from apps.widgets.notifications.models import UserNotification [as 别名]
# 或者: from apps.widgets.notifications.models.UserNotification import create_email_notification [as 别名]
def notify_winner(self, request, queryset):
"""pick winner."""
_ = request
for obj in queryset:
leader = obj.leader()
if leader and obj.award_to in ('individual_overall', 'individual_team')\
and not self.notice_sent(obj):
# Notify winner using the template.
template = NoticeTemplate.objects.get(notice_type='prize-winner')
message = template.render({'PRIZE': obj})
UserNotification.create_info_notification(leader.user, message, True, obj)
challenge = challenge_mgr.get_challenge()
subject = "[%s] Congratulations, you won a prize!" % challenge.competition_name
UserNotification.create_email_notification(
leader.user.email, subject, message, message)
self.message_user(request, "Winners notification sent.")
示例5: _handle_activity_notification
# 需要导入模块: from apps.widgets.notifications.models import UserNotification [as 别名]
# 或者: from apps.widgets.notifications.models.UserNotification import create_email_notification [as 别名]
def _handle_activity_notification(self, status):
"""Creates a notification for rejected or approved tasks.
This also creates an email message if it is configured.
"""
# don't create notification if the action is the SETUP_WIZARD_ACTIVITY
# that is used in the setup wizard.
if self.action.slug == SETUP_WIZARD_ACTIVITY:
return
# Construct the message to be sent.
status_nicely = "not approved" if status != "approved" else status
message = 'Your response to <a href="%s#action-details">"%s"</a> %s was %s.' % (
reverse("activity_task", args=(self.action.type, self.action.slug)),
self.action.title,
# The below is to tell the javascript to convert into a pretty date.
# See the prettyDate function in media/js/makahiki.js
'<span class="rejection-date" title="%s"></span>' % self.submission_date.isoformat(),
status_nicely,
)
if status != "approved":
challenge = challenge_mgr.get_challenge()
message += " You can still get points by clicking on the link and trying again."
UserNotification.create_error_notification(self.user, message, display_alert=True, content_object=self)
# only send out email notification for rejected action
subject = "[%s] Your response to '%s' was %s" % (challenge.name, self.action.title, status_nicely)
message = render_to_string(
"email/rejected_activity.txt",
{
"object": self,
"COMPETITION_NAME": challenge.name,
"domain": challenge.domain,
"status_nicely": status_nicely,
},
)
html_message = render_to_string(
"email/rejected_activity.html",
{
"object": self,
"COMPETITION_NAME": challenge.name,
"domain": challenge.domain,
"status_nicely": status_nicely,
},
)
UserNotification.create_email_notification(self.user.email, subject, message, html_message)
else:
points = self.points_awarded if self.points_awarded else self.action.point_value
message += " You earned %d points!" % points
UserNotification.create_success_notification(self.user, message, display_alert=True, content_object=self)
# if admin approve an activity (action_type==activity),
# check to the submission queue is empty,
# if so, remove the admin reminder object.
if self.action.type == "activity":
submission_count = ActionMember.objects.filter(
action__type="activity", approval_status="pending"
).count()
if not submission_count:
try:
admin = User.objects.get(username=settings.ADMIN_USER)
action = Action.objects.get(slug=SETUP_WIZARD_ACTIVITY)
EmailReminder.objects.filter(user=admin, action=action).delete()
except ObjectDoesNotExist:
pass
示例6: process_rsvp
# 需要导入模块: from apps.widgets.notifications.models import UserNotification [as 别名]
# 或者: from apps.widgets.notifications.models.UserNotification import create_email_notification [as 别名]
def process_rsvp():
"""Process RSVP notification and penalty"""
noshow_penalty_points = score_mgr.noshow_penalty_points()
signup_points = score_mgr.signup_points()
members = ActionMember.objects.filter(
Q(action__type="event") | Q(action__type="excursion"),
approval_status="pending")
# try and load the notification template.
template_noshow = None
try:
template_noshow = NoticeTemplate.objects.get(
notice_type="event-noshow-penalty")
except NoticeTemplate.DoesNotExist:
pass
template_reminder = None
try:
template_reminder = NoticeTemplate.objects.get(
notice_type="event-post-reminder")
except NoticeTemplate.DoesNotExist:
pass
for member in members:
action = member.action
user = member.user
profile = user.get_profile()
diff = datetime.date.today() - action.event.event_date.date()
if diff.days == NOSHOW_PENALTY_DAYS:
# send out notification to remind the penalty
if template_reminder:
message = template_reminder.render({"ACTIVITY": action})
else:
message = "Hi %s, <p/> We just wanted to remind you that the "\
"%s <a href='http://%s%s'>%s</a> had ended. Please "\
"click on the link to claim your points." % (
profile.name,
action.type.capitalize(),
challenge_mgr.get_challenge().domain,
reverse("activity_task", args=(action.type, action.slug,)),
action.title)
message += "<p/>Because you signed up for the "\
"event, if you do not enter the "\
"confirmation code within %d days after the "\
"event, a total of %d points (%d point "\
"signup bonus plus %d point no-show penalty) will "\
"be deducted from your total points. So please "\
"enter your confirmation code early to avoid the "\
"penalty." % (
NOSHOW_PENALTY_DAYS,
noshow_penalty_points + signup_points,
noshow_penalty_points,
signup_points,
)
message += "<p/><p/>Kukui Cup Administrators"
subject = "[Kukui Cup] Reminder to enter your event confirmation code"
UserNotification.create_email_notification(user.email, subject,
message, message)
print "sent post event email reminder to %s for %s" % (
profile.name, action.title)
elif diff.days == (NOSHOW_PENALTY_DAYS + 1):
# the day after the penalty day, process the penalty reduction
message = "%s: %s (No Show)" % (action.type.capitalize(), action.title)
profile.remove_points(noshow_penalty_points + signup_points,
datetime.datetime.today() - datetime.timedelta(minutes=1),
message,
member)
print "removed noshow penalty points from %s for '%s'" % (profile.name, message)
if template_noshow:
message = template_noshow.render({"ACTIVITY": action})
else:
message = "%d points had been deducted from you, "\
"because you signed up but did not enter the "\
"confirmation code %d days after the %s <a "\
"href='%s'>%s</a>, " % (
noshow_penalty_points + signup_points,
NOSHOW_PENALTY_DAYS,
action.type.capitalize(),
reverse("activity_task", args=(action.type, action.slug,)),
action.title)
message += " If you did attend, please click on the link to "\
"claim your points and reverse the deduction."
UserNotification.create_info_notification(user, message,
display_alert=True,
content_object=member)
print "created no-show penalty notification for %s for %s" % (
profile.name, action.title)