示例#1
0
    def run(self):
        if not rb_settings.get('notifications_enabled'):
            self._v_logger.info(
                'Notifications not sent because they are globally disabled')
            return

        occurrences = ReservationOccurrence.find(
            Room.notifications_enabled,
            Reservation.is_accepted,
            Reservation.repeat_frequency != RepeatFrequency.WEEK,
            ReservationOccurrence.is_valid,
            ReservationOccurrence.start_dt >= datetime.now(),
            ~ReservationOccurrence.notification_sent,
            _build_notification_window_filter(),
            _join=[Reservation, Room])

        try:
            for occ in occurrences:
                notify_upcoming_occurrence(occ)
                occ.notification_sent = True
                if occ.reservation.repeat_frequency == RepeatFrequency.DAY:
                    occ.reservation.occurrences.update(
                        {'notification_sent': True})
        finally:
            db.session.commit()
示例#2
0
def roombooking_occurrences():
    if not Config.getInstance().getIsRoomBookingActive():
        logger.info('Notifications not sent because room booking is disabled')
        return
    if not rb_settings.get('notifications_enabled'):
        logger.info('Notifications not sent because they are globally disabled')
        return

    occurrences = ReservationOccurrence.find(
        Room.notifications_enabled,
        Reservation.is_accepted,
        Reservation.repeat_frequency != RepeatFrequency.WEEK,
        ReservationOccurrence.is_valid,
        ReservationOccurrence.start_dt >= datetime.now(),
        ~ReservationOccurrence.notification_sent,
        _build_notification_window_filter(),
        _join=[Reservation, Room]
    )

    try:
        for occ in occurrences:
            notify_upcoming_occurrence(occ)
            occ.notification_sent = True
            if occ.reservation.repeat_frequency == RepeatFrequency.DAY:
                occ.reservation.occurrences.update({'notification_sent': True})
    finally:
        db.session.commit()
示例#3
0
    def run(self):
        occurrences = ReservationOccurrence.find(
            Reservation.is_accepted,
            ~ReservationOccurrence.notification_sent,
            ReservationOccurrence.is_valid,
            ReservationOccurrence.start_dt >= func.now(),
            _build_notification_before_days_filter(settings.get('notification_before_days', 0)),
            _join=[Reservation, Room]
        )

        for occ in occurrences:
            occ.notification_sent = True
            if occ.reservation.repeat_frequency == RepeatFrequency.DAY:
                occ.reservation.occurrences.update({'notification_sent': True})
            notify_upcoming_occurrence(occ)
示例#4
0
    def run(self):
        occurrences = ReservationOccurrence.find(
            Reservation.is_accepted,
            ~ReservationOccurrence.notification_sent,
            ReservationOccurrence.is_valid,
            ReservationOccurrence.start_dt >= func.now(),
            _build_notification_before_days_filter(
                settings.get('notification_before_days', 0)),
            _join=[Reservation, Room])

        try:
            for occ in occurrences:
                notify_upcoming_occurrence(occ)
                occ.notification_sent = True
                if occ.reservation.repeat_frequency == RepeatFrequency.DAY:
                    occ.reservation.occurrences.update(
                        {'notification_sent': True})
        finally:
            db.session.commit()