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


Python FormConfig.retrieve方法代码示例

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


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

示例1: test_stacked_config

# 需要导入模块: from floppyforms.templatetags.floppyforms import FormConfig [as 别名]
# 或者: from floppyforms.templatetags.floppyforms.FormConfig import retrieve [as 别名]
    def test_stacked_config(self):
        form = RegistrationForm()
        config = FormConfig()

        config.push()
        config.configure(
            'widget', widgets.Textarea(),
            filter=ConfigFilter("CharField"),
        )

        config.push()
        config.configure(
            'widget', widgets.HiddenInput(),
            filter=ConfigFilter('short_biography'),
        )

        widget = config.retrieve('widget', bound_field=form['short_biography'])
        self.assertEqual(widget.__class__, widgets.HiddenInput)

        config.pop()
        widget = config.retrieve('widget', bound_field=form['short_biography'])
        self.assertEqual(widget.__class__, widgets.Textarea)

        config.pop()
        widget = config.retrieve('widget', bound_field=form['short_biography'])
        self.assertEqual(widget.__class__, widgets.TextInput)
开发者ID:LaMustax,项目名称:django-floppyforms,代码行数:28,代码来源:rendering.py

示例2: test_filter_for_field_class_name

# 需要导入模块: from floppyforms.templatetags.floppyforms import FormConfig [as 别名]
# 或者: from floppyforms.templatetags.floppyforms.FormConfig import retrieve [as 别名]
    def test_filter_for_field_class_name(self):
        form = RegistrationForm()

        config = FormConfig()
        config.configure('widget', widgets.TextInput(), filter=ConfigFilter('CharField'))

        widget = config.retrieve('widget', bound_field=form['comment'])
        self.assertEqual(widget.__class__, widgets.TextInput)

        widget = config.retrieve('widget', bound_field=form['name'])
        self.assertEqual(widget.__class__, widgets.TextInput)
开发者ID:NetAngels,项目名称:django-floppyforms,代码行数:13,代码来源:rendering.py

示例3: test_default_retrieve

# 需要导入模块: from floppyforms.templatetags.floppyforms import FormConfig [as 别名]
# 或者: from floppyforms.templatetags.floppyforms.FormConfig import retrieve [as 别名]
    def test_default_retrieve(self):
        """
        Test if FormConfig returns the correct default values if no
        configuration was made.
        """
        form = RegistrationForm()
        config = FormConfig()

        # retrieve widget

        widget = config.retrieve('widget', bound_field=form['name'])
        self.assertTrue(isinstance(widget, widgets.TextInput))
        self.assertEqual(widget, form.fields['name'].widget)

        widget = config.retrieve('widget', bound_field=form['comment'])
        self.assertTrue(isinstance(widget, widgets.Textarea))
        self.assertEqual(widget, form.fields['comment'].widget)

        # retrieve widget template

        template_name = config.retrieve('widget_template', bound_field=form['name'])
        self.assertEqual(template_name, 'floppyforms/input.html')

        template_name = config.retrieve('widget_template', bound_field=form['comment'])
        self.assertEqual(template_name, 'floppyforms/textarea.html')

        # retrieve label

        label = config.retrieve('label', bound_field=form['email'])
        self.assertEqual(label, 'Email')

        label = config.retrieve('label', bound_field=form['name'])
        self.assertEqual(label, 'First- and Lastname')

        # retrieve help text

        help_text = config.retrieve('help_text', bound_field=form['name'])
        self.assertFalse(help_text)

        help_text = config.retrieve('help_text', bound_field=form['email'])
        self.assertEqual(help_text, 'Please enter a valid email.')

        # retrieve row template

        template = config.retrieve('row_template', fields=(form['name'], form['email'],))
        self.assertEqual(template, 'floppyforms/rows/default.html')

        # retrieve form layout

        template = config.retrieve('layout', forms=(form,))
        self.assertEqual(template, 'floppyforms/layouts/default.html')
开发者ID:LaMustax,项目名称:django-floppyforms,代码行数:53,代码来源:rendering.py

示例4: test_default_retrieve

# 需要导入模块: from floppyforms.templatetags.floppyforms import FormConfig [as 别名]
# 或者: from floppyforms.templatetags.floppyforms.FormConfig import retrieve [as 别名]
    def test_default_retrieve(self):
        """
        Test if FormConfig returns the correct default values if no
        configuration was made.
        """
        form = RegistrationForm()
        config = FormConfig()

        # retrieve widget

        widget = config.retrieve("widget", bound_field=form["name"])
        self.assertTrue(isinstance(widget, widgets.TextInput))
        self.assertEqual(widget, form.fields["name"].widget)

        widget = config.retrieve("widget", bound_field=form["comment"])
        self.assertTrue(isinstance(widget, widgets.Textarea))
        self.assertEqual(widget, form.fields["comment"].widget)

        # retrieve widget template

        template_name = config.retrieve("widget_template", bound_field=form["name"])
        self.assertEqual(template_name, "floppyforms/text.html")

        template_name = config.retrieve("widget_template", bound_field=form["comment"])
        self.assertEqual(template_name, "floppyforms/textarea.html")

        # retrieve label

        label = config.retrieve("label", bound_field=form["email"])
        self.assertEqual(label, "Email")

        label = config.retrieve("label", bound_field=form["name"])
        self.assertEqual(label, "First- and Lastname")

        # retrieve help text

        help_text = config.retrieve("help_text", bound_field=form["name"])
        self.assertFalse(help_text)

        help_text = config.retrieve("help_text", bound_field=form["email"])
        self.assertEqual(help_text, "Please enter a valid email.")

        # retrieve row template

        template = config.retrieve("row_template", fields=(form["name"], form["email"]))
        self.assertEqual(template, "floppyforms/rows/default.html")

        # retrieve form layout

        template = config.retrieve("layout", forms=(form,))
        self.assertEqual(template, "floppyforms/layouts/default.html")
开发者ID:andrewsmedina,项目名称:django-floppyforms,代码行数:53,代码来源:test_rendering.py

示例5: test_filter_for_name_object

# 需要导入模块: from floppyforms.templatetags.floppyforms import FormConfig [as 别名]
# 或者: from floppyforms.templatetags.floppyforms.FormConfig import retrieve [as 别名]
    def test_filter_for_name_object(self):
        form = RegistrationForm()

        config = FormConfig()
        config.configure('widget', widgets.Textarea(), filter=ConfigFilter('object'))

        widget = config.retrieve('widget', bound_field=form['email'])
        self.assertEqual(widget.__class__, widgets.EmailInput)

        widget = config.retrieve('widget', bound_field=form['name'])
        self.assertEqual(widget.__class__, widgets.TextInput)

        widget = config.retrieve('widget', bound_field=form['comment'])
        self.assertEqual(widget.__class__, widgets.Textarea)
开发者ID:NetAngels,项目名称:django-floppyforms,代码行数:16,代码来源:rendering.py

示例6: test_retrieve_for_multiple_valid_values

# 需要导入模块: from floppyforms.templatetags.floppyforms import FormConfig [as 别名]
# 或者: from floppyforms.templatetags.floppyforms.FormConfig import retrieve [as 别名]
    def test_retrieve_for_multiple_valid_values(self):
        form = RegistrationForm()
        config = FormConfig()

        config.configure("widget", widgets.Textarea(), filter=ConfigFilter("CharField"))
        config.configure("widget", widgets.HiddenInput(), filter=ConfigFilter("short_biography"))

        widget = config.retrieve("widget", bound_field=form["name"])
        self.assertEqual(widget.__class__, widgets.Textarea)
        widget = config.retrieve("widget", bound_field=form["comment"])
        self.assertEqual(widget.__class__, widgets.Textarea)

        # we get HiddenInput since this was configured last, even the Textarea
        # config applies to ``short_biography``
        widget = config.retrieve("widget", bound_field=form["short_biography"])
        self.assertEqual(widget.__class__, widgets.HiddenInput)
开发者ID:andrewsmedina,项目名称:django-floppyforms,代码行数:18,代码来源:test_rendering.py

示例7: test_field_filter_works_on_subclasses

# 需要导入模块: from floppyforms.templatetags.floppyforms import FormConfig [as 别名]
# 或者: from floppyforms.templatetags.floppyforms.FormConfig import retrieve [as 别名]
    def test_field_filter_works_on_subclasses(self):
        form = RegistrationForm()
        config = FormConfig()

        config.configure("widget", widgets.HiddenInput(), filter=ConfigFilter("IntegerField"))

        widget = config.retrieve("widget", bound_field=form["age"])
        self.assertEqual(widget.__class__, widgets.HiddenInput)
开发者ID:andrewsmedina,项目名称:django-floppyforms,代码行数:10,代码来源:test_rendering.py


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