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


Python FilterSpec.register_front方法代码示例

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


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

示例1: title

# 需要导入模块: from django.contrib.admin.filterspecs import FilterSpec [as 别名]
# 或者: from django.contrib.admin.filterspecs.FilterSpec import register_front [as 别名]
        self.lookup_val = request.GET.get(self.lookup_kwarg, None)
        self.lookup_choices = f.get_choices(include_blank=False)

    def title(self):
        return self.lookup_title

    def choices(self, cl):
        yield {'selected': self.lookup_val is None,
               'query_string': cl.get_query_string({}, [self.lookup_kwarg]),
               'display': _('All')}
        for pk_val, val in self.lookup_choices:
            yield {'selected': self.lookup_val == smart_unicode(pk_val),
                   'query_string': cl.get_query_string({self.lookup_kwarg: pk_val}, [self.lookup_kwarg]),
                   'display': val}

FilterSpec.register_front(lambda f: bool(f.rel) and (not hasattr(f, 'null') or not f.null), RelatedFilterSpec)


#==============================================================================
class RelatedNullFilterSpec(FilterSpec):
    def __init__(self, f, request, params, model, model_admin,
                 field_path=None):
        super(RelatedNullFilterSpec, self).__init__(f, request, params, model, model_admin)
        if isinstance(f, models.ManyToManyField):
            self.lookup_title = f.rel.to._meta.verbose_name
        else:
            self.lookup_title = f.verbose_name
        self.null_lookup_kwarg = '%s__isnull' % f.name
        self.null_lookup_val = request.GET.get(self.null_lookup_kwarg, None)
        rel_name = f.rel.get_related_field().name
        self.lookup_kwarg = '%s__%s__exact' % (f.name, rel_name)
开发者ID:christopinka,项目名称:django-civil,代码行数:33,代码来源:filter.py

示例2: _register_front

# 需要导入模块: from django.contrib.admin.filterspecs import FilterSpec [as 别名]
# 或者: from django.contrib.admin.filterspecs.FilterSpec import register_front [as 别名]
        yield {
                'selected'     : self.file_exists_lookup_val is not None,
                'query_string' : cl.get_query_string({self.file_exists_lookup_kwarg : ""}, [self.file_not_exists_lookup_kwarg]),
                'display'      : 'PreGenCSV',
        }
        yield {
                'selected'     : self.file_not_exists_lookup_val is not None,
                'query_string' : cl.get_query_string({self.file_not_exists_lookup_kwarg : ""}, [self.file_exists_lookup_kwarg]),
                'display'      : 'HUB-Core',
        }

def _register_front(cls, test, factory):
    cls.filter_specs.insert(0, (test, factory))

FilterSpec.register_front = classmethod(_register_front)
FilterSpec.register_front(lambda f: isinstance(f, FileNameField), IndicatorSourceListFilter)

# Actions available in Core
def batch_debug_indicators(modeladmin, request, queryset):
    """ Run selected indicators, and store output and a "debug" csv
    
    Each call to this view generates a view batch folder. The contents of the
    folder:

    - [indicator name].csv for each indicator selected
    - [indicator name]_debug.csv for each indicator selected
    - batch.log
    
    The indicator generation is scheduled in celery, and output is directed to
    batch.log.
    """
开发者ID:syncopated,项目名称:Datahub-Indicators,代码行数:33,代码来源:admin.py


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