Exemplo n.º 1
0
 def _award_possible_reverse_penalty_points(self):
     """ reverse event/excursion noshow penalty."""
     if self._has_noshow_penalty():
         message = "%s (Reverse No Show Penalty)" % self.action
         self.user.get_profile().add_points(
             score_mgr.noshow_penalty_points() + score_mgr.signup_points(), self.award_date, message, self
         )
Exemplo n.º 2
0
 def _award_possible_reverse_penalty_points(self):
     """ reverse event noshow penalty."""
     if self._has_noshow_penalty():
         message = "%s (Reverse No Show Penalty)" % self.action
         self.user.profile.add_points(
             score_mgr.noshow_penalty_points() + score_mgr.signup_points(),
             self.award_date, message, self)
Exemplo n.º 3
0
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)
Exemplo n.º 4
0
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.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)