當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。