本文整理汇总了Python中indico.modules.rb.models.locations.Location.find_first方法的典型用法代码示例。如果您正苦于以下问题:Python Location.find_first方法的具体用法?Python Location.find_first怎么用?Python Location.find_first使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类indico.modules.rb.models.locations.Location
的用法示例。
在下文中一共展示了Location.find_first方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _checkParams
# 需要导入模块: from indico.modules.rb.models.locations import Location [as 别名]
# 或者: from indico.modules.rb.models.locations.Location import find_first [as 别名]
def _checkParams(self):
self._with_kpi = request.args.get('withKPI', type=bool)
self._actionSucceeded = request.args.get('actionSucceeded', default=False, type=bool)
location_name = request.view_args.get('locationId')
self._location = Location.find_first(name=location_name)
if not self._location:
raise IndicoError('Unknown Location: {0}'.format(location_name))
示例2: wrapper
# 需要导入模块: from indico.modules.rb.models.locations import Location [as 别名]
# 或者: from indico.modules.rb.models.locations.Location import find_first [as 别名]
def wrapper(*args, **kw):
location_name = getattr(request, request_attribute).get(parameter_name, None)
location = Location.find_first(name=location_name)
if not location:
raise NotFound(_('There is no location named: {0}').format(location_name))
setattr(args[0], attribute_name, location)
return f(*args, **kw)
示例3: _process_args
# 需要导入模块: from indico.modules.rb.models.locations import Location [as 别名]
# 或者: from indico.modules.rb.models.locations.Location import find_first [as 别名]
def _process_args(self):
self._locationName = request.form.get('newLocationName').strip()
if not self._locationName:
raise BadRequest(_('Location name may not be empty'))
if '/' in self._locationName:
raise BadRequest(_('Location name may not contain slashes'))
if Location.find_first(name=self._locationName):
raise BadRequest(_('Location "{0}" already exists').format(self._locationName))
示例4: export_roomName
# 需要导入模块: from indico.modules.rb.models.locations import Location [as 别名]
# 或者: from indico.modules.rb.models.locations.Location import find_first [as 别名]
def export_roomName(self, aw):
loc = Location.find_first(name=self._location)
if loc is None:
return
search_str = '%{}%'.format(self._room_name)
rooms_data = Room.get_with_data('vc_equipment', 'non_vc_equipment',
filters=[Room.location_id == loc.id, Room.name.ilike(search_str)])
for result in rooms_data:
yield _serializable_room(result)
示例5: wrapper
# 需要导入模块: from indico.modules.rb.models.locations import Location [as 别名]
# 或者: from indico.modules.rb.models.locations.Location import find_first [as 别名]
def wrapper(*args, **kw):
if not args:
raise IndicoError(_("Wrong usage of location decorator"))
location_name = getattr(request, request_attribute).get(parameter_name, None)
location = Location.find_first(name=location_name)
if not location:
raise NotFoundError(_("There is no location named: {0}").format(location_name))
setattr(args[0], attribute_name, location)
return f(*args, **kw)
示例6: export_roomName
# 需要导入模块: from indico.modules.rb.models.locations import Location [as 别名]
# 或者: from indico.modules.rb.models.locations.Location import find_first [as 别名]
def export_roomName(self, user):
loc = Location.find_first(name=self._location)
if loc is None:
return
search_str = '%{}%'.format(self._room_name)
rooms_data = Room.get_with_data(
filters=[
Room.location_id == loc.id,
or_(Room.name.ilike(search_str),
Room.verbose_name.ilike(search_str))
])
for result in rooms_data:
yield _serializable_room(result)
示例7: export_room
# 需要导入模块: from indico.modules.rb.models.locations import Location [as 别名]
# 或者: from indico.modules.rb.models.locations.Location import find_first [as 别名]
def export_room(self, user):
loc = Location.find_first(name=self._location)
if loc is None:
return
# Retrieve rooms
rooms_data = list(Room.get_with_data(filters=[Room.id.in_(self._ids), Room.location_id == loc.id]))
# Retrieve reservations
reservations = None
if self._detail == 'reservations':
reservations = OrderedMultiDict(_export_reservations(self, True, False, [
Reservation.room_id.in_(x['room'].id for x in rooms_data)
]))
for result in rooms_data:
yield _serializable_room(result, reservations)
示例8: _checkParams
# 需要导入模块: from indico.modules.rb.models.locations import Location [as 别名]
# 或者: from indico.modules.rb.models.locations.Location import find_first [as 别名]
def _checkParams(self):
self._location = Location.find_first(name=self._param('location'))
aspect_data = self._param('aspect')
try:
zoom_level = int(aspect_data.get('zoom_level', '0'))
except ValueError:
zoom_level = 0
self._aspect = Aspect(
name=aspect_data.get('name', ''),
center_latitude=aspect_data.get('center_latitude', ''),
center_longitude=aspect_data.get('center_longitude', ''),
zoom_level=zoom_level,
top_left_latitude=aspect_data.get('top_left_latitude', ''),
top_left_longitude=aspect_data.get('top_left_longitude', ''),
bottom_right_latitude=aspect_data.get('bottom_right_latitude', ''),
bottom_right_longitude=aspect_data.get('bottom_right_longitude', '')
)
self._default_on_startup = aspect_data.get('DefaultOnStartup', False)
示例9: migrate_rooms
# 需要导入模块: from indico.modules.rb.models.locations import Location [as 别名]
# 或者: from indico.modules.rb.models.locations.Location import find_first [as 别名]
def migrate_rooms(self):
eq = defaultdict(set)
vc = defaultdict(set)
for old_room_id, old_room in self.rb_root["Rooms"].iteritems():
eq[old_room._locationName].update(e for e in old_room._equipment.split("`") if e)
vc[old_room._locationName].update(e for e in getattr(old_room, "avaibleVC", []) if e)
print cformat("%{white!}migrating equipment")
for name, eqs in eq.iteritems():
l = Location.find_first(name=name)
if l is None:
print cformat("%{yellow!}*** WARNING")
print cformat(
"%{{yellow!}}***%{{reset}} Location '{}' does not exist. Skipped equipment: {}".format(name, eqs)
)
continue
l.equipment_types.extend(EquipmentType(name=x) for x in eqs)
print cformat("- [%{cyan}{}%{reset}] {}").format(name, eqs)
db.session.add(l)
db.session.commit()
print
print cformat("%{white!}migrating vc equipment")
for name, vcs in vc.iteritems():
l = Location.find_first(name=name)
if l is None:
print cformat("%{yellow!}*** WARNING")
print cformat(
"%{{yellow!}}***%{{reset}} Location '{}' does not exist. Skipped VC equipment: {}".format(name, vcs)
)
continue
pvc = l.get_equipment_by_name("Video conference")
for vc_name in vcs:
req = EquipmentType(name=vc_name)
req.parent = pvc
l.equipment_types.append(req)
print cformat("- [%{cyan}{}%{reset}] {}").format(name, req.name)
db.session.add(l)
db.session.commit()
print
print cformat("%{white!}migrating rooms")
for old_room_id, old_room in self.rb_root["Rooms"].iteritems():
l = Location.find_first(name=old_room._locationName)
if l is None:
print cformat("%{yellow!}*** WARNING")
print cformat(
"%{{yellow!}}***%{{reset}} Location '{}' does not exist. Skipped room '{}'".format(
old_room._locationName, old_room.id
)
)
continue
r = Room(
id=old_room_id,
name=convert_to_unicode((old_room._name or "").strip() or generate_name(old_room)),
site=convert_to_unicode(old_room.site),
division=convert_to_unicode(old_room.division),
building=convert_to_unicode(old_room.building),
floor=convert_to_unicode(old_room.floor),
number=convert_to_unicode(old_room.roomNr),
notification_before_days=(
(old_room.resvStartNotificationBefore or None)
if getattr(old_room, "resvStartNotification", False)
else None
),
notification_for_responsible=getattr(old_room, "resvNotificationToResponsible", False),
notification_for_assistance=getattr(old_room, "resvNotificationAssistance", False),
reservations_need_confirmation=old_room.resvsNeedConfirmation,
telephone=convert_to_unicode(getattr(old_room, "telephone", None)),
key_location=convert_to_unicode(getattr(old_room, "whereIsKey", None)),
capacity=getattr(old_room, "capacity", None),
surface_area=getattr(old_room, "surfaceArea", None),
latitude=getattr(old_room, "latitude", None),
longitude=getattr(old_room, "longitude", None),
comments=convert_to_unicode(getattr(old_room, "comments", None)),
owner_id=self.merged_avatars.get(old_room.responsibleId, old_room.responsibleId),
is_active=old_room.isActive,
is_reservable=old_room.isReservable,
max_advance_days=int(old_room.maxAdvanceDays) if getattr(old_room, "maxAdvanceDays", None) else None,
)
print cformat("- [%{cyan}{}%{reset}] %{grey!}{:4}%{reset} %{green!}{}%{reset}").format(
l.name, r.id, r.name
)
for old_bookable_time in getattr(old_room, "_dailyBookablePeriods", []):
r.bookable_hours.append(
BookableHours(start_time=old_bookable_time._startTime, end_time=old_bookable_time._endTime)
)
print cformat(" %{blue!}Bookable:%{reset} {}").format(r.bookable_hours[-1])
for old_nonbookable_date in getattr(old_room, "_nonBookableDates", []):
r.nonbookable_periods.append(
#.........这里部分代码省略.........
示例10: _process_args
# 需要导入模块: from indico.modules.rb.models.locations import Location [as 别名]
# 或者: from indico.modules.rb.models.locations.Location import find_first [as 别名]
def _process_args(self):
self._location = Location.find_first(name=self._param('location'))
示例11: migrate_rooms
# 需要导入模块: from indico.modules.rb.models.locations import Location [as 别名]
# 或者: from indico.modules.rb.models.locations.Location import find_first [as 别名]
def migrate_rooms(rb_root, photo_path, avatar_id_map):
eq = defaultdict(set)
vc = defaultdict(set)
for old_room_id, old_room in rb_root['Rooms'].iteritems():
eq[old_room._locationName].update(e for e in old_room._equipment.split('`') if e)
vc[old_room._locationName].update(e for e in getattr(old_room, 'avaibleVC', []) if e)
print cformat('%{white!}migrating equipment')
for name, eqs in eq.iteritems():
l = Location.find_first(name=name)
l.equipment_types.extend(EquipmentType(name=x) for x in eqs)
print cformat('- [%{cyan}{}%{reset}] {}').format(name, eqs)
db.session.add(l)
db.session.commit()
print
print cformat('%{white!}migrating vc equipment')
for name, vcs in vc.iteritems():
l = Location.find_first(name=name)
pvc = l.get_equipment_by_name('Video conference')
for vc_name in vcs:
req = EquipmentType(name=vc_name)
req.parent = pvc
l.equipment_types.append(req)
print cformat('- [%{cyan}{}%{reset}] {}').format(name, req.name)
db.session.add(l)
db.session.commit()
print
print cformat('%{white!}migrating rooms')
for old_room_id, old_room in rb_root['Rooms'].iteritems():
l = Location.find_first(name=old_room._locationName)
r = Room(
id=old_room_id,
name=convert_to_unicode((old_room._name or '').strip() or generate_name(old_room)),
site=convert_to_unicode(old_room.site),
division=convert_to_unicode(old_room.division),
building=convert_to_unicode(old_room.building),
floor=convert_to_unicode(old_room.floor),
number=convert_to_unicode(old_room.roomNr),
notification_before_days=((old_room.resvStartNotificationBefore or None)
if getattr(old_room, 'resvStartNotification', False)
else None),
notification_for_responsible=getattr(old_room, 'resvNotificationToResponsible', False),
notification_for_assistance=getattr(old_room, 'resvNotificationAssistance', False),
reservations_need_confirmation=old_room.resvsNeedConfirmation,
telephone=old_room.telephone,
key_location=convert_to_unicode(old_room.whereIsKey),
capacity=old_room.capacity,
surface_area=getattr(old_room, 'surfaceArea', None),
latitude=getattr(old_room, 'latitude', None),
longitude=getattr(old_room, 'longitude', None),
comments=convert_to_unicode(old_room.comments),
owner_id=avatar_id_map.get(old_room.responsibleId, old_room.responsibleId),
is_active=old_room.isActive,
is_reservable=old_room.isReservable,
max_advance_days=int(old_room.maxAdvanceDays) if getattr(old_room, 'maxAdvanceDays', None) else None
)
print cformat('- [%{cyan}{}%{reset}] %{grey!}{:4}%{reset} %{green!}{}%{reset}').format(l.name, r.id, r.name)
for old_bookable_time in getattr(old_room, '_dailyBookablePeriods', []):
r.bookable_hours.append(
BookableHours(
start_time=old_bookable_time._startTime,
end_time=old_bookable_time._endTime
)
)
print cformat(' %{blue!}Bookable:%{reset} {}').format(r.bookable_hours[-1])
for old_nonbookable_date in getattr(old_room, '_nonBookableDates', []):
r.nonbookable_periods.append(
NonBookablePeriod(
start_dt=old_nonbookable_date._startDate,
end_dt=old_nonbookable_date._endDate
)
)
print cformat(' %{blue!}Nonbookable:%{reset} {}').format(r.nonbookable_periods[-1])
if photo_path:
try:
with open(os.path.join(photo_path, 'large_photos',
get_canonical_name_of(old_room) + '.jpg'), 'rb') as f:
large_photo = f.read()
except Exception:
large_photo = None
try:
with open(os.path.join(photo_path, 'small_photos',
get_canonical_name_of(old_room) + '.jpg'), 'rb') as f:
small_photo = f.read()
except Exception:
small_photo = None
#.........这里部分代码省略.........