本文整理汇总了Python中indico.modules.rb.models.locations.Location.default_aspect方法的典型用法代码示例。如果您正苦于以下问题:Python Location.default_aspect方法的具体用法?Python Location.default_aspect怎么用?Python Location.default_aspect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类indico.modules.rb.models.locations.Location
的用法示例。
在下文中一共展示了Location.default_aspect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: migrate_locations
# 需要导入模块: from indico.modules.rb.models.locations import Location [as 别名]
# 或者: from indico.modules.rb.models.locations.Location import default_aspect [as 别名]
def migrate_locations(self):
print cformat("%{white!}migrating locations")
default_location_name = self.zodb_root["DefaultRoomBookingLocation"]
custom_attributes_dict = self.rb_root["CustomAttributesList"]
for old_location in self.zodb_root["RoomBookingLocationList"]:
# create location
l = Location(
name=convert_to_unicode(old_location.friendlyName),
is_default=(old_location.friendlyName == default_location_name),
)
print cformat("- %{cyan}{}").format(l.name)
# add aspects
for old_aspect in old_location._aspects.values():
a = Aspect(
name=convert_to_unicode(old_aspect.name),
center_latitude=old_aspect.centerLatitude,
center_longitude=old_aspect.centerLongitude,
zoom_level=old_aspect.zoomLevel,
top_left_latitude=old_aspect.topLeftLatitude,
top_left_longitude=old_aspect.topLeftLongitude,
bottom_right_latitude=old_aspect.bottomRightLatitude,
bottom_right_longitude=old_aspect.bottomRightLongitude,
)
print cformat(" %{blue!}Aspect:%{reset} {}").format(a.name)
l.aspects.append(a)
if old_aspect.defaultOnStartup:
l.default_aspect = a
# add custom attributes
for ca in custom_attributes_dict.get(l.name, []):
if ca["type"] != "str":
raise RuntimeError("Non-str custom attributes are unsupported: {}".format(ca))
attr_name = attribute_map.get(ca["name"], ca["name"])
attr = RoomAttribute(
name=attr_name.replace(" ", "-").lower(),
title=attr_name,
type=ca["type"],
is_required=ca["required"],
is_hidden=ca["hidden"],
)
l.attributes.append(attr)
print cformat(" %{blue!}Attribute:%{reset} {}").format(attr.title)
# add new created location
db.session.add(l)
print
print
db.session.commit()
示例2: migrate_locations
# 需要导入模块: from indico.modules.rb.models.locations import Location [as 别名]
# 或者: from indico.modules.rb.models.locations.Location import default_aspect [as 别名]
def migrate_locations(main_root, rb_root):
print cformat('%{white!}migrating locations')
default_location_name = main_root['DefaultRoomBookingLocation']
custom_attributes_dict = rb_root['CustomAttributesList']
for old_location in main_root['RoomBookingLocationList']:
# create location
l = Location(
name=convert_to_unicode(old_location.friendlyName),
is_default=(old_location.friendlyName == default_location_name)
)
print cformat('- %{cyan}{}').format(l.name)
# add aspects
for old_aspect in old_location._aspects.values():
a = Aspect(
name=convert_to_unicode(old_aspect.name),
center_latitude=old_aspect.centerLatitude,
center_longitude=old_aspect.centerLongitude,
zoom_level=old_aspect.zoomLevel,
top_left_latitude=old_aspect.topLeftLatitude,
top_left_longitude=old_aspect.topLeftLongitude,
bottom_right_latitude=old_aspect.bottomRightLatitude,
bottom_right_longitude=old_aspect.bottomRightLongitude
)
print cformat(' %{blue!}Aspect:%{reset} {}').format(a.name)
l.aspects.append(a)
if old_aspect.defaultOnStartup:
l.default_aspect = a
# add custom attributes
for ca in custom_attributes_dict.get(l.name, []):
if ca['type'] != 'str':
raise RuntimeError('Non-str custom attributes are unsupported: {}'.format(ca))
attr_name = attribute_map.get(ca['name'], ca['name'])
attr = RoomAttribute(name=attr_name.replace(' ', '-').lower(), title=attr_name, type=ca['type'],
is_required=ca['required'], is_hidden=ca['hidden'])
l.attributes.append(attr)
print cformat(' %{blue!}Attribute:%{reset} {}').format(attr.title)
# add new created location
db.session.add(l)
print
print
db.session.commit()