当前位置: 首页>>代码示例>>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;未经允许,请勿转载。