当前位置: 首页>>代码示例>>Python>>正文


Python Reservation.find_all方法代码示例

本文整理汇总了Python中indico.modules.rb.models.reservations.Reservation.find_all方法的典型用法代码示例。如果您正苦于以下问题:Python Reservation.find_all方法的具体用法?Python Reservation.find_all怎么用?Python Reservation.find_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在indico.modules.rb.models.reservations.Reservation的用法示例。


在下文中一共展示了Reservation.find_all方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: approve

# 需要导入模块: from indico.modules.rb.models.reservations import Reservation [as 别名]
# 或者: from indico.modules.rb.models.reservations.Reservation import find_all [as 别名]
    def approve(self, notify_blocker=True):
        """Approve the room blocking, rejecting all colliding reservations/occurrences."""
        self.state = BlockedRoomState.accepted

        # Get colliding reservations
        start_dt = datetime.combine(self.blocking.start_date, time())
        end_dt = datetime.combine(self.blocking.end_date, time(23, 59, 59))

        reservation_criteria = [
            Reservation.room_id == self.room_id,
            ~Reservation.is_rejected,
            ~Reservation.is_cancelled
        ]

        # Whole reservations to reject
        reservations = Reservation.find_all(
            Reservation.start_dt >= start_dt,
            Reservation.end_dt <= end_dt,
            *reservation_criteria
        )

        # Single occurrences to reject
        occurrences = ReservationOccurrence.find_all(
            ReservationOccurrence.start_dt >= start_dt,
            ReservationOccurrence.end_dt <= end_dt,
            ReservationOccurrence.is_valid,
            ~ReservationOccurrence.reservation_id.in_(map(attrgetter('id'), reservations)) if reservations else True,
            *reservation_criteria,
            _join=Reservation
        )

        reason = 'Conflict with blocking {}: {}'.format(self.blocking.id, self.blocking.reason)

        for reservation in reservations:
            if self.blocking.can_be_overridden(reservation.created_by_user, reservation.room):
                continue
            reservation.reject(self.blocking.created_by_user, reason)

        for occurrence in occurrences:
            reservation = occurrence.reservation
            if self.blocking.can_be_overridden(reservation.created_by_user, reservation.room):
                continue
            occurrence.reject(self.blocking.created_by_user, reason)

        if notify_blocker:
            # We only need to notify the blocking creator if the blocked room wasn't approved yet.
            # This is the case if it's a new blocking for a room managed by the creator
            notify_request_response(self)
开发者ID:hennogous,项目名称:indico,代码行数:50,代码来源:blocked_rooms.py

示例2: _process

# 需要导入模块: from indico.modules.rb.models.reservations import Reservation [as 别名]
# 或者: from indico.modules.rb.models.reservations.Reservation import find_all [as 别名]
 def _process(self):
     reservations = Reservation.find_all(event_id=self.event_id)
     if not reservations:
         self._redirect(url_for('event_mgmt.rooms_choose_event', self.event))
         return
     return WPRoomBookingEventBookingList(self, self.event, reservations=reservations).display()
开发者ID:pferreir,项目名称:indico-backup,代码行数:8,代码来源:event.py


注:本文中的indico.modules.rb.models.reservations.Reservation.find_all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。