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


Python blocked_rooms.BlockedRoom類代碼示例

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


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

示例1: _create_blocking

 def _create_blocking(**params):
     room = params.pop('room', dummy_room)
     state = params.pop('state', BlockedRoom.State.pending)
     params.setdefault('start_date', date.today())
     params.setdefault('end_date', date.today())
     params.setdefault('reason', u'Blocked')
     params.setdefault('created_by_user', dummy_avatar.user)
     blocking = Blocking(**params)
     if room is not None:
         br = BlockedRoom(room=room, state=state, blocking=blocking)
         if state == BlockedRoom.State.accepted:
             br.approve(notify_blocker=False)
     db.session.add(blocking)
     db.session.flush()
     return blocking
開發者ID:OmeGak,項目名稱:indico,代碼行數:15,代碼來源:fixtures.py

示例2: validate_blocked_rooms

    def validate_blocked_rooms(self, field):
        try:
            field.data = map(int, field.data)
        except Exception as e:
            # In case someone sent crappy data
            raise ValidationError(str(e))

        # Make sure all room ids are valid
        if len(field.data) != Room.find(Room.id.in_(field.data)).count():
            raise ValidationError('Invalid rooms')

        if hasattr(self, '_blocking'):
            start_date = self._blocking.start_date
            end_date = self._blocking.end_date
            blocking_id = self._blocking.id
        else:
            start_date = self.start_date.data
            end_date = self.end_date.data
            blocking_id = None

        overlap = BlockedRoom.find_first(
            BlockedRoom.room_id.in_(field.data),
            BlockedRoom.state != BlockedRoom.State.rejected,
            Blocking.start_date <= end_date,
            Blocking.end_date >= start_date,
            Blocking.id != blocking_id,
            _join=Blocking
        )
        if overlap:
            msg = 'Your blocking for {} is overlapping with another blocking.'.format(overlap.room.full_name)
            raise ValidationError(msg)
開發者ID:bkolobara,項目名稱:indico,代碼行數:31,代碼來源:blockings.py

示例3: __init__

    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,代碼行數:34,代碼來源:calendar.py

示例4: test_find_with_filters_dates

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,代碼行數:9,代碼來源:blocked_rooms_test.py

示例5: test_find_with_filters

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,代碼行數:20,代碼來源:blocked_rooms_test.py

示例6: __init__

    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,代碼行數:46,代碼來源:calendar.py

示例7: test_find_with_filters_state

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,代碼行數:5,代碼來源:blocked_rooms_test.py

示例8: _process_args

 def _process_args(self):
     self.blocked_room = BlockedRoom.get(self._params['blocked_room_id'])
開發者ID:DirkHoffmann,項目名稱:indico,代碼行數:2,代碼來源:blockings.py

示例9: _checkParams

 def _checkParams(self):
     self.blocked_room = BlockedRoom.get(self._params['blocked_room_id'])
開發者ID:NIIF,項目名稱:indico,代碼行數:2,代碼來源:blockings.py


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