當前位置: 首頁>>代碼示例>>Python>>正文


Python BlockedRoom.find_with_filters方法代碼示例

本文整理匯總了Python中indico.modules.rb.models.blocked_rooms.BlockedRoom.find_with_filters方法的典型用法代碼示例。如果您正苦於以下問題:Python BlockedRoom.find_with_filters方法的具體用法?Python BlockedRoom.find_with_filters怎麽用?Python BlockedRoom.find_with_filters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在indico.modules.rb.models.blocked_rooms.BlockedRoom的用法示例。


在下文中一共展示了BlockedRoom.find_with_filters方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from indico.modules.rb.models.blocked_rooms import BlockedRoom [as 別名]
# 或者: from indico.modules.rb.models.blocked_rooms.BlockedRoom import find_with_filters [as 別名]
    def __init__(self, occurrences, start_dt, end_dt, candidates=None, rooms=None, specific_room=None,
                 repeat_frequency=None, repeat_interval=None, flexible_days=0, show_blockings=True):
        self.occurrences = occurrences
        self.start_dt = start_dt
        self.end_dt = end_dt
        self.candidates = candidates
        self.rooms = rooms
        self.specific_room = specific_room
        self.repeat_frequency = repeat_frequency
        self.repeat_interval = repeat_interval
        self.flexible_days = flexible_days
        self.show_blockings = show_blockings

        self.conflicts = 0
        self.bars = []

        if self.specific_room and self.rooms:
            raise ValueError('specific_room and rooms are mutually exclusive')

        if self.specific_room:
            self.rooms = [self.specific_room]
        elif self.rooms is None:
            self.rooms = Room.find_all(is_active=True)
        self.rooms = sorted(self.rooms, key=lambda x: natural_sort_key(x.full_name))

        if self.show_blockings:
            self.blocked_rooms = BlockedRoom.find_with_filters({'room_ids': [r.id for r in self.rooms],
                                                                'state': BlockedRoom.State.accepted,
                                                                'start_date': self.start_dt.date(),
                                                                'end_date': self.end_dt.date()})
        else:
            self.blocked_rooms = []

        self._produce_bars()
開發者ID:NIIF,項目名稱:indico,代碼行數:36,代碼來源:calendar.py

示例2: test_find_with_filters_dates

# 需要導入模塊: from indico.modules.rb.models.blocked_rooms import BlockedRoom [as 別名]
# 或者: from indico.modules.rb.models.blocked_rooms.BlockedRoom import find_with_filters [as 別名]
def test_find_with_filters_dates(create_blocking, start_date, end_date, matches):
    start_date = datetime.strptime(start_date, "%Y-%m-%d").date()
    end_date = datetime.strptime(end_date, "%Y-%m-%d").date()
    blockings = [
        create_blocking(start_date=date(2014, 12, 5), end_date=date(2014, 12, 7)),
        create_blocking(start_date=date(2014, 12, 6), end_date=date(2014, 12, 8)),
    ]
    filters = {"start_date": start_date, "end_date": end_date}
    assert set(BlockedRoom.find_with_filters(filters)) == set(blockings[i].blocked_rooms[0] for i in matches)
開發者ID:OmeGak,項目名稱:indico,代碼行數:11,代碼來源:blocked_rooms_test.py

示例3: test_find_with_filters

# 需要導入模塊: from indico.modules.rb.models.blocked_rooms import BlockedRoom [as 別名]
# 或者: from indico.modules.rb.models.blocked_rooms.BlockedRoom import find_with_filters [as 別名]
def test_find_with_filters(create_room, create_blocking):
    rooms = [create_room(), create_room()]
    blockings = [
        create_blocking(start_date=date.today(),
                        end_date=date.today(),
                        room=rooms[0],
                        state=BlockedRoom.State.accepted),
        create_blocking(start_date=date.today() + timedelta(days=1),
                        end_date=date.today() + timedelta(days=1),
                        room=rooms[1]),
        create_blocking(start_date=date.today() + timedelta(days=1),
                        end_date=date.today() + timedelta(days=1),
                        room=rooms[1]),
    ]
    assert set(BlockedRoom.find_with_filters({})) == set(b.blocked_rooms[0] for b in blockings)
    filters = {'start_date': date.today(),
               'end_date': date.today(),
               'room_ids': {rooms[0].id},
               'state': BlockedRoom.State.accepted}
    assert set(BlockedRoom.find_with_filters(filters)) == {blockings[0].blocked_rooms[0]}
開發者ID:MichelCordeiro,項目名稱:indico,代碼行數:22,代碼來源:blocked_rooms_test.py

示例4: __init__

# 需要導入模塊: from indico.modules.rb.models.blocked_rooms import BlockedRoom [as 別名]
# 或者: from indico.modules.rb.models.blocked_rooms.BlockedRoom import find_with_filters [as 別名]
    def __init__(self, occurrences, start_dt, end_dt, candidates=None, rooms=None, specific_room=None,
                 repeat_frequency=None, repeat_interval=None, flexible_days=0, show_blockings=True):
        self.occurrences = occurrences
        self.start_dt = start_dt
        self.end_dt = end_dt
        self.candidates = candidates
        self.rooms = rooms
        self.specific_room = specific_room
        self.repeat_frequency = repeat_frequency
        self.repeat_interval = repeat_interval
        self.flexible_days = flexible_days
        self.show_blockings = show_blockings

        self.conflicts = 0
        self.bars = []

        if self.specific_room and self.rooms:
            raise ValueError('specific_room and rooms are mutually exclusive')

        if self.specific_room:
            self.rooms = [self.specific_room]
        elif self.rooms is None:
            self.rooms = Room.find_all(is_active=True)
        self.rooms = sorted(self.rooms, key=lambda x: natural_sort_key(x.full_name))

        if self.show_blockings:
            # avoid loading user data we don't care about
            user_strategy = defaultload('blocking').defaultload('created_by_user')
            user_strategy.noload('*')
            user_strategy.load_only('first_name', 'last_name')
            room_ids = [r.id for r in self.rooms]
            filters = {
                'room_ids': room_ids,
                'state': BlockedRoom.State.accepted,
                'start_date': self.start_dt.date(),
                'end_date': self.end_dt.date()
            }
            self.blocked_rooms = BlockedRoom.find_with_filters(filters).options(user_strategy)
            self.nonbookable_periods = NonBookablePeriod.find(
                NonBookablePeriod.room_id.in_(room_ids),
                NonBookablePeriod.overlaps(self.start_dt, self.end_dt)
            ).all()
        else:
            self.blocked_rooms = []

        self._produce_bars()
開發者ID:DirkHoffmann,項目名稱:indico,代碼行數:48,代碼來源:calendar.py

示例5: test_find_with_filters_state

# 需要導入模塊: from indico.modules.rb.models.blocked_rooms import BlockedRoom [as 別名]
# 或者: from indico.modules.rb.models.blocked_rooms.BlockedRoom import find_with_filters [as 別名]
def test_find_with_filters_state(create_blocking, state):
    other_state = next(s for s in BlockedRoom.State if s != state)
    create_blocking(state=other_state)
    blocking = create_blocking(state=state)
    assert set(BlockedRoom.find_with_filters({"state": state})) == {blocking.blocked_rooms[0]}
開發者ID:OmeGak,項目名稱:indico,代碼行數:7,代碼來源:blocked_rooms_test.py


注:本文中的indico.modules.rb.models.blocked_rooms.BlockedRoom.find_with_filters方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。