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


Python MapFeature.get_subclass方法代码示例

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


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

示例1: make_display_filter

# 需要导入模块: from treemap.models import MapFeature [as 别名]
# 或者: from treemap.models.MapFeature import get_subclass [as 别名]
 def make_display_filter(feature_name):
     Feature = MapFeature.get_subclass(feature_name)
     if hasattr(Feature, "display_name_plural"):
         plural = Feature.display_name_plural
     else:
         plural = Feature.display_name + "s"
     return {"label": "Show %s" % plural.lower(), "model": feature_name}
开发者ID:recklessromeo,项目名称:otm-core,代码行数:9,代码来源:instance.py

示例2: make_display_filter

# 需要导入模块: from treemap.models import MapFeature [as 别名]
# 或者: from treemap.models.MapFeature import get_subclass [as 别名]
 def make_display_filter(feature_name):
     Feature = MapFeature.get_subclass(feature_name)
     plural = Feature.terminology(self)['plural']
     return {
         'label': 'Show %s' % plural.lower(),
         'model': feature_name
     }
开发者ID:nvh3010,项目名称:otm-core,代码行数:9,代码来源:instance.py

示例3: render_map_feature_add

# 需要导入模块: from treemap.models import MapFeature [as 别名]
# 或者: from treemap.models.MapFeature import get_subclass [as 别名]
def render_map_feature_add(request, instance, type):
    if type in instance.map_feature_types[1:]:
        app = MapFeature.get_subclass(type).__module__.split(".")[0]
        template = "%s/%s_add.html" % (app, type)
        return render_to_response(template, None, RequestContext(request))
    else:
        raise Http404("Instance does not support feature type " + type)
开发者ID:jwalgran,项目名称:otm-core,代码行数:9,代码来源:map_feature.py

示例4: add_map_feature_types

# 需要导入模块: from treemap.models import MapFeature [as 别名]
# 或者: from treemap.models.MapFeature import get_subclass [as 别名]
    def add_map_feature_types(self, types):
        """
        add_map_feature_types(self, types)

        types is a list of map feature class names.

        Add these types to the instance config,
        save the instance!!!,
        and create udf rows for udfs that have settings defaults,
        if they don't already exist.
        """
        from treemap.models import MapFeature  # prevent circular import
        from treemap.audit import add_default_permissions

        classes = [MapFeature.get_subclass(type) for type in types]

        dups = set(types) & set(self.map_feature_types)
        if len(dups) > 0:
            raise ValidationError('Map feature types already added: %s' % dups)

        self._map_feature_types = list(self.map_feature_types) + list(types)
        self.save()

        for type, clz in zip(types, classes):
            settings = (getattr(clz, 'udf_settings', {}))
            for udfc_name, udfc_settings in settings.items():
                if udfc_settings.get('defaults'):
                    get_or_create_udf(self, type, udfc_name)

        add_default_permissions(self, models=classes)
开发者ID:RickMohr,项目名称:otm-core,代码行数:32,代码来源:instance.py

示例5: get_map_view_context

# 需要导入模块: from treemap.models import MapFeature [as 别名]
# 或者: from treemap.models.MapFeature import get_subclass [as 别名]
def get_map_view_context(request, instance):
    resource_classes = [MapFeature.get_subclass(type)
                        for type in instance.map_feature_types]
    return {
        'fields_for_add_tree': [
            (trans('Tree Height'), 'Tree.height')
        ],
        'resource_classes': resource_classes[1:]
    }
开发者ID:summer-of-open-source,项目名称:OTM2,代码行数:11,代码来源:misc.py

示例6: make_display_filter

# 需要导入模块: from treemap.models import MapFeature [as 别名]
# 或者: from treemap.models.MapFeature import get_subclass [as 别名]
 def make_display_filter(feature_name):
     Feature = MapFeature.get_subclass(feature_name)
     if hasattr(Feature, 'display_name_plural'):
         plural = Feature.display_name_plural
     else:
         plural = Feature.display_name + 's'
     return {
         'label': 'Show %s' % plural.lower(),
         'model': feature_name
     }
开发者ID:cgarrard,项目名称:OTM2,代码行数:12,代码来源:instance.py

示例7: _get_map_view_context

# 需要导入模块: from treemap.models import MapFeature [as 别名]
# 或者: from treemap.models.MapFeature import get_subclass [as 别名]
def _get_map_view_context(request, instance):
    resource_types = [{'name': type,
                       'display': MapFeature.get_subclass(type).display_name}
                      for type in instance.map_feature_types]
    return {
        'fields_for_add_tree': [
            (trans('Tree Height'), 'Tree.height')
        ],
        'resource_types': resource_types[1:]
    }
开发者ID:heath,项目名称:OTM2,代码行数:12,代码来源:views.py

示例8: render_map_feature_add

# 需要导入模块: from treemap.models import MapFeature [as 别名]
# 或者: from treemap.models.MapFeature import get_subclass [as 别名]
def render_map_feature_add(request, instance, type):
    if type in instance.map_feature_types[1:]:
        app = MapFeature.get_subclass(type).__module__.split('.')[0]
        try:
            template = '%s/%s_add.html' % (app, type)
        except:
            template = 'treemap/resource_add.html'
        return render(request, template, {'object_name': to_object_name(type)})
    else:
        raise_non_instance_404(type)
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:12,代码来源:map_feature.py

示例9: any_resource_is_creatable

# 需要导入模块: from treemap.models import MapFeature [as 别名]
# 或者: from treemap.models.MapFeature import get_subclass [as 别名]
def any_resource_is_creatable(role_related_obj):
    role = _get_role_from_related_object(role_related_obj)
    if role is None:
        return False

    map_features = {MapFeature.get_subclass(m)
                    for m in role.instance.map_feature_types}
    resources = map_features - {Plot}

    return any(map_feature_is_creatable(role, Model) for Model in resources)
开发者ID:nvh3010,项目名称:otm-core,代码行数:12,代码来源:perms.py

示例10: render_map_feature_add

# 需要导入模块: from treemap.models import MapFeature [as 别名]
# 或者: from treemap.models.MapFeature import get_subclass [as 别名]
def render_map_feature_add(request, instance, type):
    if type in instance.map_feature_types[1:]:
        app = MapFeature.get_subclass(type).__module__.split(".")[0]
        try:
            template = "%s/%s_add.html" % (app, type)
            get_template(template)
        except:
            template = "treemap/resource_add.html"
        return render_to_response(template, {"object_name": to_object_name(type)}, RequestContext(request))
    else:
        raise_non_instance_404(type)
开发者ID:RobinIsTheBird,项目名称:otm-core,代码行数:13,代码来源:map_feature.py

示例11: get_map_view_context

# 需要导入模块: from treemap.models import MapFeature [as 别名]
# 或者: from treemap.models.MapFeature import get_subclass [as 别名]
def get_map_view_context(request, instance):
    resource_classes = [MapFeature.get_subclass(type)
                        for type in instance.map_feature_types]
    context = {
        'fields_for_add_tree': [
            (_('Tree Height'), 'Tree.height')
        ],
        'resource_classes': resource_classes[1:],
    }
    add_map_info_to_context(context, instance)
    return context
开发者ID:jwalgran,项目名称:otm-core,代码行数:13,代码来源:misc.py

示例12: get_map_feature_or_404

# 需要导入模块: from treemap.models import MapFeature [as 别名]
# 或者: from treemap.models.MapFeature import get_subclass [as 别名]
def get_map_feature_or_404(feature_id, instance, type=None):
    if type:
        MapFeatureSubclass = MapFeature.get_subclass(type)
        InstanceMapFeature = instance.scope_model(MapFeatureSubclass)
        return get_object_or_404(InstanceMapFeature, pk=feature_id)

    else:
        InstanceMapFeature = instance.scope_model(MapFeature)
        feature = get_object_or_404(InstanceMapFeature, pk=feature_id)

        # Return the concrete subtype (e.g. Plot), not a general MapFeature
        return feature.cast_to_subtype()
开发者ID:recklessromeo,项目名称:otm-core,代码行数:14,代码来源:map_feature.py

示例13: get_map_feature_or_404

# 需要导入模块: from treemap.models import MapFeature [as 别名]
# 或者: from treemap.models.MapFeature import get_subclass [as 别名]
def get_map_feature_or_404(feature_id, instance, type=None):
    if type:
        MapFeatureSubclass = MapFeature.get_subclass(type)
        InstanceMapFeature = instance.scope_model(MapFeatureSubclass)
        return get_object_or_404(InstanceMapFeature, pk=feature_id)

    else:
        InstanceMapFeature = instance.scope_model(MapFeature)
        feature = get_object_or_404(InstanceMapFeature, pk=feature_id)

        # Use feature_type to get the appropriate object, e.g. feature.plot
        feature = getattr(feature, feature.feature_type.lower())
        return feature
开发者ID:atogle,项目名称:OTM2,代码行数:15,代码来源:map_feature.py

示例14: render_map_feature_add

# 需要导入模块: from treemap.models import MapFeature [as 别名]
# 或者: from treemap.models.MapFeature import get_subclass [as 别名]
def render_map_feature_add(request, instance, type):
    if type in instance.map_feature_types[1:]:
        app = MapFeature.get_subclass(type).__module__.split('.')[0]
        try:
            template = '%s/%s_add.html' % (app, type)
            get_template(template)
        except:
            template = 'treemap/resource_add.html'
        return render_to_response(template,
                                  {'object_name': to_object_name(type)},
                                  RequestContext(request))
    else:
        raise Http404('Instance does not support feature type ' + type)
开发者ID:recklessromeo,项目名称:otm-core,代码行数:15,代码来源:map_feature.py

示例15: get_map_feature_or_404

# 需要导入模块: from treemap.models import MapFeature [as 别名]
# 或者: from treemap.models.MapFeature import get_subclass [as 别名]
def get_map_feature_or_404(feature_id, instance, type=None):
    if type:
        if type not in instance.map_feature_types:
            raise_non_instance_404(type)
        MapFeatureSubclass = MapFeature.get_subclass(type)
        InstanceMapFeature = instance.scope_model(MapFeatureSubclass)
        return get_object_or_404(InstanceMapFeature, pk=feature_id)

    else:
        InstanceMapFeature = instance.scope_model(MapFeature)
        feature = get_object_or_404(InstanceMapFeature, pk=feature_id)

        # Return the concrete subtype (e.g. Plot), not a general MapFeature
        typed_feature = feature.cast_to_subtype()
        class_name = typed_feature.__class__.__name__
        if class_name not in instance.map_feature_types:
            raise_non_instance_404(class_name)
        return typed_feature
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:20,代码来源:map_feature.py


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