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


Python Program.default_for_domain方法代码示例

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


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

示例1: handle

# 需要导入模块: from corehq.apps.commtrack.models import Program [as 别名]
# 或者: from corehq.apps.commtrack.models.Program import default_for_domain [as 别名]
    def handle(self, *args, **options):
        self.stdout.write("Fixing default programs...\n")

        for domain in Domain.get_all():
            if not domain.commtrack_enabled:
                continue

            if Program.default_for_domain(domain.name):
                continue

            programs = Program.by_domain(domain.name)

            # filter anything named 'default' or 'Default'
            current_default = [
                p for p in programs
                if p.name == 'Default' or p.name == 'default'
            ]

            # if they never changed their default programs
            # name, we don't want to add a confusing new one
            # so just flip this to the default
            if len(current_default) == 1:
                p.default = True
                p.save()
            else:
                get_or_create_default_program(domain.name)
开发者ID:kamilk161,项目名称:commcare-hq,代码行数:28,代码来源:fix_default_program.py

示例2: get_or_create_default_program

# 需要导入模块: from corehq.apps.commtrack.models import Program [as 别名]
# 或者: from corehq.apps.commtrack.models.Program import default_for_domain [as 别名]
def get_or_create_default_program(domain):
    program = Program.default_for_domain(domain)

    if program:
        return program
    else:
        return make_program(
            domain,
            _('Uncategorized'),
            _('uncategorized'),
            default=True
        )
开发者ID:kamilk161,项目名称:commcare-hq,代码行数:14,代码来源:util.py

示例3: __init__

# 需要导入模块: from corehq.apps.commtrack.models import Program [as 别名]
# 或者: from corehq.apps.commtrack.models.Program import default_for_domain [as 别名]
    def __init__(self, product, *args, **kwargs):
        self.product = product

        kwargs['initial'] = self.product._doc
        kwargs['initial']['code'] = self.product.code

        super(ProductForm, self).__init__(*args, **kwargs)

        programs = Program.by_domain(self.product.domain, wrap=False)
        self.fields['program_id'].choices = tuple((prog['_id'], prog['name']) for prog in programs)

        # make sure to select default program if
        # this is a new product
        if not product._id:
            self.initial['program_id'] = Program.default_for_domain(
                self.product.domain
            )._id
开发者ID:kamilk161,项目名称:commcare-hq,代码行数:19,代码来源:forms.py


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