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


Python defaultfilters.yesno方法代码示例

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


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

示例1: build_row

# 需要导入模块: from django.template import defaultfilters [as 别名]
# 或者: from django.template.defaultfilters import yesno [as 别名]
def build_row(self, obj, fields):
        row = []
        for f in fields:
            value = getattr(obj, f)
            try:
                row.append(value.strftime('%m/%d/%Y'))
            except AttributeError:
                if isinstance(value, bool):
                    value = yesno(value, _("yes,no"))
                if f == 'title':
                    value = _(obj.title)
                if f == 'confirmed_on':
                    value = '01/01/1970'
                row.append(value)
        return row 
开发者ID:tejoesperanto,项目名称:pasportaservo,代码行数:17,代码来源:views.py

示例2: add_helpers

# 需要导入模块: from django.template import defaultfilters [as 别名]
# 或者: from django.template.defaultfilters import yesno [as 别名]
def add_helpers(worksheet, row, column, event, job, helpers,
                multiple_shifts_format):
    for helper in helpers:
        row.next()
        column.reset()

        num_shifts = helper.shifts.count()
        num_jobs = len(helper.coordinated_jobs)
        format = None
        if num_shifts + num_jobs > 1:
            format = multiple_shifts_format

        worksheet.write(row.get(), column.next(), escape(helper.firstname),
                        format)
        worksheet.write(row.get(), column.next(), escape(helper.surname),
                        format)
        worksheet.write(row.get(), column.next(), escape(helper.email), format)
        if event.ask_phone:
            worksheet.write(row.get(), column.next(), escape(helper.phone), format)
        if event.ask_shirt:
            worksheet.write(row.get(), column.next(), escape(str(helper.get_shirt_display())), format)
        if event.ask_vegetarian:
            worksheet.write(row.get(), column.next(),
                            escape(filters.yesno(helper.vegetarian)), format)
        if job.infection_instruction:
            worksheet.write(row.get(), column.next(), escape(str(helper.get_infection_instruction_short())), format)
        worksheet.write(row.get(), column.next(), escape(helper.comment),
                        format) 
开发者ID:helfertool,项目名称:helfertool,代码行数:30,代码来源:excel.py

示例3: test_true

# 需要导入模块: from django.template import defaultfilters [as 别名]
# 或者: from django.template.defaultfilters import yesno [as 别名]
def test_true(self):
        self.assertEqual(yesno(True), 'yes') 
开发者ID:nesdis,项目名称:djongo,代码行数:4,代码来源:test_yesno.py

示例4: test_false

# 需要导入模块: from django.template import defaultfilters [as 别名]
# 或者: from django.template.defaultfilters import yesno [as 别名]
def test_false(self):
        self.assertEqual(yesno(False), 'no') 
开发者ID:nesdis,项目名称:djongo,代码行数:4,代码来源:test_yesno.py

示例5: test_none

# 需要导入模块: from django.template import defaultfilters [as 别名]
# 或者: from django.template.defaultfilters import yesno [as 别名]
def test_none(self):
        self.assertEqual(yesno(None), 'maybe') 
开发者ID:nesdis,项目名称:djongo,代码行数:4,代码来源:test_yesno.py

示例6: test_true_arguments

# 需要导入模块: from django.template import defaultfilters [as 别名]
# 或者: from django.template.defaultfilters import yesno [as 别名]
def test_true_arguments(self):
        self.assertEqual(yesno(True, 'certainly,get out of town,perhaps'), 'certainly') 
开发者ID:nesdis,项目名称:djongo,代码行数:4,代码来源:test_yesno.py

示例7: test_false_arguments

# 需要导入模块: from django.template import defaultfilters [as 别名]
# 或者: from django.template.defaultfilters import yesno [as 别名]
def test_false_arguments(self):
        self.assertEqual(yesno(False, 'certainly,get out of town,perhaps'), 'get out of town') 
开发者ID:nesdis,项目名称:djongo,代码行数:4,代码来源:test_yesno.py

示例8: test_none_three_arguments

# 需要导入模块: from django.template import defaultfilters [as 别名]
# 或者: from django.template.defaultfilters import yesno [as 别名]
def test_none_three_arguments(self):
        self.assertEqual(yesno(None, 'certainly,get out of town,perhaps'), 'perhaps') 
开发者ID:nesdis,项目名称:djongo,代码行数:4,代码来源:test_yesno.py

示例9: test_invalid_value

# 需要导入模块: from django.template import defaultfilters [as 别名]
# 或者: from django.template.defaultfilters import yesno [as 别名]
def test_invalid_value(self):
        self.assertIs(yesno(True, 'yes'), True)
        self.assertIs(yesno(False, 'yes'), False)
        self.assertIsNone(yesno(None, 'yes')) 
开发者ID:nesdis,项目名称:djongo,代码行数:6,代码来源:test_yesno.py

示例10: js_bool

# 需要导入模块: from django.template import defaultfilters [as 别名]
# 或者: from django.template.defaultfilters import yesno [as 别名]
def js_bool(value):
    """ Similar to yesno:"true,false,false" """
    if not value:
        return "false"
    return "true"

# Encode all '<'s as \u003c and '>'s as \u003e to prevent <!-- ... --> and </script> from breaking our pages 
开发者ID:canvasnetworks,项目名称:canvas,代码行数:9,代码来源:canvas_tags.py

示例11: friendly

# 需要导入模块: from django.template import defaultfilters [as 别名]
# 或者: from django.template.defaultfilters import yesno [as 别名]
def friendly(value):
    if value in (None, '', [], (), {}):
        return None

    if type(value) is list:
        value = ', '.join(value)
    if type(value) is bool:
        value = yesno(value, u'{0},{1}'.format(_('Yes'), _('No')))
    if not isinstance(value, string_types):
        value = force_text(value)
    return value 
开发者ID:mishbahr,项目名称:djangocms-forms,代码行数:13,代码来源:djangocms_forms_tags.py

示例12: to_html

# 需要导入模块: from django.template import defaultfilters [as 别名]
# 或者: from django.template.defaultfilters import yesno [as 别名]
def to_html(field):
    value = field['value']
    field_type = field['type']

    if value in (None, '', [], (), {}):
        return mark_safe('&mdash;')

    if field_type == 'file':
        value = '<a href="{0}">{0}</a>'.format(value)
    if field_type == 'checkbox':
        value = yesno(bool(value), u'{0},{1}'.format(_('Yes'), _('No')))
    if field_type == 'checkbox_multiple':
        value = ', '.join(list(value))
    return mark_safe(value) 
开发者ID:mishbahr,项目名称:djangocms-forms,代码行数:16,代码来源:djangocms_forms_tags.py


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