コード例 #1
0
    def send_reminders(self):
        right_now = datetime.datetime.utcnow()
        
        # right now >= due date - reminder interval  ==>
        # due date - reminder interval <= right now ==>
        # due date <= right now + reminder interval

        if settings.DEFAULT_ASSIGNMENT_PRE_REMINDER_INTERVAL:
            for unfinished_assignment in self.my_django_model.objects.exclude(
                status='completed').filter(
                sent_pre_reminder=False).filter(
                due_date__lte=right_now + datetime.timedelta(seconds=settings.DEFAULT_ASSIGNMENT_PRE_REMINDER_INTERVAL)):
                
                send_message(message_type='assignment-pre-reminder',
                             context={'assignment': unfinished_assignment},
                             recipient=unfinished_assignment.user)
                unfinished_assignment.sent_pre_reminder = True
                unfinished_assignment.save()
        
        for unfinished_assignment in self.my_django_model.objects.exclude(
            status='completed').filter(
            sent_reminder=False).filter(
            due_date__lte=right_now + datetime.timedelta(seconds=settings.DEFAULT_ASSIGNMENT_REMINDER_INTERVAL)):
            
            send_message(message_type='assignment-reminder',
                         context={'assignment': unfinished_assignment},
                         recipient=unfinished_assignment.user)
            unfinished_assignment.sent_reminder = True
            unfinished_assignment.save()
コード例 #2
0
    def remind_invitees(self, auth_token, session_id):
        """
        remind invitees of an upcoming Session

         This method sends Session reminders for an Session regardless of whether
        they have already been sent and regardless of the Session's status.  This
        is mostly for demos.

         The system will not remember that it has sent Session reminders via
        this method -- they will still be sent asynchronously on lead time
        expiry if they haven't already.

        @param auth_token
        @param session_id   primary key of Session in question
        @returns            None
        """

        session = self._find_by_id(session_id)
        recipients = set()
        for surr in session.session_user_role_requirements.all():
            for user in surr.users.all():
                recipients.add(user)
        send_message(message_type='session-reminder',
                     context={'session': session},
                     recipients=recipients)
コード例 #3
0
 def send_confirmations(self):
     end_of_today = (datetime.datetime.utcnow() + datetime.timedelta(days=1)).replace(hour=0, minute=0,
         second=0, microsecond=0)
     for assignment in facade.models.Assignment.objects.filter(
             sent_confirmation=False).filter(
             effective_date_assigned__lte=end_of_today):
         send_message(message_type='assignment-confirmation',
                      context={'assignment': assignment},
                      recipient=assignment.user)
         assignment.sent_confirmation = True
         assignment.save()
コード例 #4
0
    def _send_payment_confirmation(self, po):
        """
        Send a payment confirmation to the user associated with the purchase
        order that the Payment was for, if the purchase order was associated
        with a user and not an organization.

        @param po purchase order in question
        """

        send_message(message_type='payment-confirmation',
                     context={'purchase_order': po},
                     recipient=po.user)
コード例 #5
0
    def _send_payment_confirmation(self, po):
        """
        Send a payment confirmation to the user associated with the purchase
        order that the Payment was for, if the purchase order was associated
        with a user and not an organization.

        @param po purchase order in question
        """

        send_message(message_type='payment-confirmation',
                     context={'purchase_order': po},
                     recipient=po.user)
コード例 #6
0
 def send_late_notices(self):
     # right now >= due date + late notice interval
     # due date + late notice interval <= right now
     # due date <= right now - late notice interval
     
     right_now = datetime.datetime.utcnow()
     for late_assignment in facade.models.Assignment.objects.filter(
             status='late', sent_late_notice=False,
             due_date__lte=right_now - datetime.timedelta(
                 seconds=settings.DEFAULT_ASSIGNMENT_LATE_NOTICE_INTERVAL)):
         send_message(message_type='assignment-late-notice',
                      context={'assignment': late_assignment},
                      recipient=late_assignment.user)
         late_assignment.sent_late_notice = True
         late_assignment.save()
コード例 #7
0
    def resend_receipt(self, auth_token, purchase_order_id):
        """
        Send a payment confirmation email to a purchase order's associated user.
        
        @param auth_token
        @type auth_token pr_services.models.AuthToken
        @param purchase_order_id the primary key of the purchase order
        @type purchase_order_id int
        """

        self.authorizer.check_arbitrary_permissions(auth_token, "resend_payment_confirmations")

        po = self._find_by_id(purchase_order_id)
        template_context = po.get_template_context()
        send_message(message_type="payment-confirmation", context=template_context, recipients=po.user)
コード例 #8
0
    def _process_session_reminders(self):
        """
        send Session reminders for all eligible Sessions

        This is not available via RPC.
        """

        sessions_to_process = self._get_sessions_needing_reminders()
        for session in sessions_to_process:
            recipients = set()
            for surr in session.session_user_role_requirements.all():
                for user in surr.users.all():
                    recipients.add(user)
            send_message(message_type='session-reminder',
                         context={'session': session}, recipients=recipients)
            session.sent_reminders = True
            session.save()
    def resend_receipt(self, auth_token, purchase_order_id):
        """
        Send a payment confirmation email to a purchase order's associated user.
        
        @param auth_token
        @type auth_token pr_services.models.AuthToken
        @param purchase_order_id the primary key of the purchase order
        @type purchase_order_id int
        """

        self.authorizer.check_arbitrary_permissions(
            auth_token, 'resend_payment_confirmations')

        po = self._find_by_id(purchase_order_id)
        template_context = po.get_template_context()
        send_message(message_type='payment-confirmation',
                     context=template_context,
                     recipients=po.user)
コード例 #10
0
    def _process_session_reminders(self):
        """
        send Session reminders for all eligible Sessions

        This is not available via RPC.
        """

        sessions_to_process = self._get_sessions_needing_reminders()
        for session in sessions_to_process:
            recipients = set()
            for surr in session.session_user_role_requirements.all():
                for user in surr.users.all():
                    recipients.add(user)
            send_message(message_type='session-reminder',
                         context={'session': session},
                         recipients=recipients)
            session.sent_reminders = True
            session.save()
コード例 #11
0
    def remind_invitees(self, auth_token, session_id):
        """
        remind invitees of an upcoming Session

         This method sends Session reminders for an Session regardless of whether
        they have already been sent and regardless of the Session's status.  This
        is mostly for demos.

         The system will not remember that it has sent Session reminders via
        this method -- they will still be sent asynchronously on lead time
        expiry if they haven't already.

        @param auth_token
        @param session_id   primary key of Session in question
        @returns            None
        """

        session = self._find_by_id(session_id)
        recipients = set()
        for surr in session.session_user_role_requirements.all():
            for user in surr.users.all():
                recipients.add(user)
        send_message(message_type='session-reminder',
                     context={'session': session}, recipients=recipients)