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


Python Location.default_aspect方法代码示例

本文整理汇总了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()
开发者ID:jacquesd,项目名称:indico,代码行数:55,代码来源:roombooking.py

示例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()
开发者ID:pferreir,项目名称:indico-backup,代码行数:50,代码来源:migrate_to_sqlalchemy.py


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