コード例 #1
0
ファイル: tasks.py プロジェクト: marcosmolla/indico
    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
ファイル: tasks.py プロジェクト: MichelCordeiro/indico
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
ファイル: tasks.py プロジェクト: sofian86/indico-gh-test
    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
ファイル: tasks.py プロジェクト: pferreir/indico-backup
    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()