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


Python Reservation.find方法代码示例

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


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

示例1: _merge_users

# 需要导入模块: from indico.modules.rb.models.reservations import Reservation [as 别名]
# 或者: from indico.modules.rb.models.reservations.Reservation import find [as 别名]
def _merge_users(target, source, **kwargs):
    BlockingPrincipal.merge_users(target, source, 'blocking')
    Blocking.find(created_by_id=source.id).update({Blocking.created_by_id: target.id})
    Reservation.find(created_by_id=source.id).update({Reservation.created_by_id: target.id})
    Reservation.find(booked_for_id=source.id).update({Reservation.booked_for_id: target.id})
    Room.find(owner_id=source.id).update({Room.owner_id: target.id})
    rb_settings.acls.merge_users(target, source)
开发者ID:mic4ael,项目名称:indico,代码行数:9,代码来源:__init__.py

示例2: rb_merge_users

# 需要导入模块: from indico.modules.rb.models.reservations import Reservation [as 别名]
# 或者: from indico.modules.rb.models.reservations.Reservation import find [as 别名]
def rb_merge_users(new_id, old_id):
    """Updates RB data after an Avatar merge

    :param new_id: Target user
    :param old_id: Source user (being deleted in the merge)
    """
    from indico.modules.rb import settings as rb_settings
    from indico.modules.rb.models.blocking_principals import BlockingPrincipal
    from indico.modules.rb.models.blockings import Blocking
    from indico.modules.rb.models.reservations import Reservation
    from indico.modules.rb.models.rooms import Room

    old_user = User.get(int(old_id))
    new_user = User.get(int(new_id))
    for bp in BlockingPrincipal.find():
        if bp.principal == old_user:
            bp.principal = new_user
    Blocking.find(created_by_id=old_id).update({'created_by_id': new_id})
    Reservation.find(created_by_id=old_id).update({'created_by_id': new_id})
    Reservation.find(booked_for_id=old_id).update({'booked_for_id': new_id})
    Room.find(owner_id=old_id).update({'owner_id': new_id})
    for key in ('authorized_principals', 'admin_principals'):
        principals = rb_settings.get(key)
        principals = principals_merge_users(principals, new_id, old_id)
        rb_settings.set(key, principals)
开发者ID:marcosmolla,项目名称:indico,代码行数:27,代码来源:utils.py

示例3: _merge_users

# 需要导入模块: from indico.modules.rb.models.reservations import Reservation [as 别名]
# 或者: from indico.modules.rb.models.reservations.Reservation import find [as 别名]
def _merge_users(target, source, **kwargs):
    source_principals = set(source.in_blocking_acls.options(joinedload(BlockingPrincipal.blocking)))
    target_blockings = {x.blocking for x in target.in_blocking_acls.options(joinedload(BlockingPrincipal.blocking))}
    for principal in source_principals:
        if principal.blocking not in target_blockings:
            principal.user_id = target.id
        else:
            db.session.delete(principal)
    Blocking.find(created_by_id=source.id).update({Blocking.created_by_id: target.id})
    Reservation.find(created_by_id=source.id).update({Reservation.created_by_id: target.id})
    Reservation.find(booked_for_id=source.id).update({Reservation.booked_for_id: target.id})
    Room.find(owner_id=source.id).update({Room.owner_id: target.id})
    settings.acls.merge_users(target, source)
开发者ID:dbourillot,项目名称:indico,代码行数:15,代码来源:__init__.py

示例4: calculate_rooms_booked_time

# 需要导入模块: from indico.modules.rb.models.reservations import Reservation [as 别名]
# 或者: from indico.modules.rb.models.reservations.Reservation import find [as 别名]
def calculate_rooms_booked_time(rooms, start_date=None, end_date=None):
    if end_date is None:
        end_date = date.today() - relativedelta(days=1)
    if start_date is None:
        start_date = end_date - relativedelta(days=29)
    # Reservations on working days
    reservations = Reservation.find(Reservation.room_id.in_(r.id for r in rooms),
                                    db.extract('dow', ReservationOccurrence.start_dt).between(1, 5),
                                    db.cast(ReservationOccurrence.start_dt, db.Date) >= start_date,
                                    db.cast(ReservationOccurrence.end_dt, db.Date) <= end_date,
                                    ReservationOccurrence.is_valid,
                                    _join=ReservationOccurrence)

    rsv_start = db.cast(ReservationOccurrence.start_dt, db.TIME)
    rsv_end = db.cast(ReservationOccurrence.end_dt, db.TIME)
    slots = ((db.cast(start, db.TIME), db.cast(end, db.TIME)) for start, end in WORKING_TIME_PERIODS)

    # this basically handles all possible ways an occurrence overlaps with each one of the working time slots
    overlaps = sum(db.case([
                ((rsv_start < start) & (rsv_end > end), db.extract('epoch', end - start)),
                ((rsv_start < start) & (rsv_end > start) & (rsv_end <= end), db.extract('epoch', rsv_end - start)),
                ((rsv_start >= start) & (rsv_start < end) & (rsv_end > end), db.extract('epoch', end - rsv_start)),
                ((rsv_start >= start) & (rsv_end <= end), db.extract('epoch', rsv_end - rsv_start))
            ], else_=0) for start, end in slots)

    return reservations.with_entities(db.func.sum(overlaps)).scalar() or 0
开发者ID:indico,项目名称:indico,代码行数:28,代码来源:statistics.py

示例5: _createTabCtrl

# 需要导入模块: from indico.modules.rb.models.reservations import Reservation [as 别名]
# 或者: from indico.modules.rb.models.reservations.Reservation import find [as 别名]
 def _createTabCtrl(self):
     self._tabCtrl = TabControl()
     self._tabExistBookings = self._tabCtrl.newTab('existing', 'Existing Bookings',
                                                   url_for('event_mgmt.rooms_booking_list', self._conf))
     self._tabNewBooking = self._tabCtrl.newTab('new', 'New Booking',
                                                url_for('event_mgmt.rooms_choose_event', self._conf))
     if not Reservation.find(event_id=self._conf.getId()).count():
         self._tabExistBookings.setEnabled(False)
     self._setActiveTab()
开发者ID:MichelCordeiro,项目名称:indico,代码行数:11,代码来源:event.py

示例6: rb_merge_users

# 需要导入模块: from indico.modules.rb.models.reservations import Reservation [as 别名]
# 或者: from indico.modules.rb.models.reservations.Reservation import find [as 别名]
def rb_merge_users(new_id, old_id):
    """Updates RB data after an Avatar merge

    :param new_id: Target user
    :param old_id: Source user (being deleted in the merge)
    """
    from indico.modules.rb import settings
    from indico.modules.rb.models.blocking_principals import BlockingPrincipal
    from indico.modules.rb.models.blockings import Blocking
    from indico.modules.rb.models.reservations import Reservation
    from indico.modules.rb.models.rooms import Room

    BlockingPrincipal.find(entity_type='Avatar', entity_id=old_id).update({'entity_id': new_id})
    Blocking.find(created_by_id=old_id).update({'created_by_id': new_id})
    Reservation.find(created_by_id=old_id).update({'created_by_id': new_id})
    Reservation.find(booked_for_id=old_id).update({'booked_for_id': new_id})
    Room.find(owner_id=old_id).update({'owner_id': new_id})
    for key in ('authorized_principals', 'admin_principals'):
        principals = settings.get(key, [])
        principals = principals_merge_users(principals, new_id, old_id)
        settings.set(key, principals)
开发者ID:pferreir,项目名称:indico-backup,代码行数:23,代码来源:utils.py

示例7: compose_rooms_stats

# 需要导入模块: from indico.modules.rb.models.reservations import Reservation [as 别名]
# 或者: from indico.modules.rb.models.reservations.Reservation import find [as 别名]
def compose_rooms_stats(rooms):
    reservations = Reservation.find(Reservation.room_id.in_(r.id for r in rooms))
    return {
        'active': {
            'valid': reservations.filter(Reservation.is_valid, ~Reservation.is_archived).count(),
            'pending': reservations.filter(Reservation.is_pending, ~Reservation.is_archived).count(),
            'cancelled': reservations.filter(Reservation.is_cancelled, ~Reservation.is_archived).count(),
            'rejected': reservations.filter(Reservation.is_rejected, ~Reservation.is_archived).count(),
        },
        'archived': {
            'valid': reservations.filter(Reservation.is_valid, Reservation.is_archived).count(),
            'pending': reservations.filter(Reservation.is_pending, Reservation.is_archived).count(),
            'cancelled': reservations.filter(Reservation.is_cancelled, Reservation.is_archived).count(),
            'rejected': reservations.filter(Reservation.is_rejected, Reservation.is_archived).count()
        }
    }
开发者ID:belokop,项目名称:indico_bare,代码行数:18,代码来源:statistics.py

示例8: calculate_rooms_booked_time

# 需要导入模块: from indico.modules.rb.models.reservations import Reservation [as 别名]
# 或者: from indico.modules.rb.models.reservations.Reservation import find [as 别名]
def calculate_rooms_booked_time(rooms, start_date=None, end_date=None):
    if end_date is None:
        end_date = date.today() - relativedelta(days=1)
    if start_date is None:
        start_date = end_date - relativedelta(days=29)
    # Reservations on working days
    reservations = Reservation.find(Reservation.room_id.in_(r.id for r in rooms),
                                    extract('dow', ReservationOccurrence.start_dt).between(1, 5),
                                    ReservationOccurrence.start_dt >= start_date,
                                    ReservationOccurrence.end_dt <= end_date,
                                    ReservationOccurrence.is_valid,
                                    _join=ReservationOccurrence)
    # Take into account only working hours
    earliest_time = greatest(cast(ReservationOccurrence.start_dt, TIME), Location.working_time_start)
    latest_time = least(cast(ReservationOccurrence.end_dt, TIME), Location.working_time_end)
    booked_time = reservations.with_entities(func.sum(latest_time - earliest_time)).scalar()
    return (booked_time or timedelta()).total_seconds()
开发者ID:belokop,项目名称:indico_bare,代码行数:19,代码来源:statistics.py

示例9: _process

# 需要导入模块: from indico.modules.rb.models.reservations import Reservation [as 别名]
# 或者: from indico.modules.rb.models.reservations.Reservation import find [as 别名]
 def _process(self):
     rooms = sorted(self._location.rooms, key=lambda r: natural_sort_key(r.full_name))
     kpi = {}
     if self._with_kpi:
         kpi['occupancy'] = calculate_rooms_occupancy(self._location.rooms)
         kpi['total_rooms'] = len(self._location.rooms)
         kpi['active_rooms'] = sum(1 for room in self._location.rooms if room.is_active)
         kpi['reservable_rooms'] = sum(1 for room in self._location.rooms if room.is_reservable)
         kpi['reservable_capacity'] = sum(room.capacity or 0 for room in self._location.rooms if room.is_reservable)
         kpi['reservable_surface'] = sum(room.surface_area or 0 for room in self._location.rooms
                                         if room.is_reservable)
         kpi['booking_stats'] = compose_rooms_stats(self._location.rooms)
         kpi['booking_count'] = Reservation.find(Reservation.room.has(Room.location == self._location)).count()
     return WPRoomBookingAdminLocation(self, 'rb-rooms',
                                       location=self._location,
                                       rooms=rooms,
                                       action_succeeded=self._actionSucceeded,
                                       equipment_types=self._location.equipment_types.all(),
                                       attributes=self._location.attributes.all(),
                                       kpi=kpi).display()
开发者ID:bkolobara,项目名称:indico,代码行数:22,代码来源:locations.py

示例10: _process

# 需要导入模块: from indico.modules.rb.models.reservations import Reservation [as 别名]
# 或者: from indico.modules.rb.models.reservations.Reservation import find [as 别名]
 def _process(self):
     rooms = sorted(self._location.rooms, key=lambda r: natural_sort_key(r.full_name))
     kpi = {}
     if self._with_kpi:
         kpi['occupancy'] = calculate_rooms_occupancy(self._location.rooms.all())
         kpi['total_rooms'] = self._location.rooms.count()
         kpi['active_rooms'] = self._location.rooms.filter_by(is_active=True).count()
         kpi['reservable_rooms'] = self._location.rooms.filter_by(is_reservable=True).count()
         kpi['reservable_capacity'] = (self._location.rooms.with_entities(func.sum(Room.capacity))
                                                           .filter_by(is_reservable=True).scalar())
         kpi['reservable_surface'] = (self._location.rooms.with_entities(func.sum(Room.surface_area))
                                                          .filter_by(is_reservable=True).scalar())
         kpi['booking_stats'] = compose_rooms_stats(self._location.rooms.all())
         kpi['booking_count'] = Reservation.find(Reservation.room_id.in_(r.id for r in self._location.rooms)).count()
     return WPRoomBookingAdminLocation(self,
                                       location=self._location,
                                       rooms=rooms,
                                       action_succeeded=self._actionSucceeded,
                                       equipment_types=self._location.equipment_types.all(),
                                       attributes=self._location.attributes.all(),
                                       kpi=kpi).display()
开发者ID:NIIF,项目名称:indico,代码行数:23,代码来源:locations.py


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