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


Python Form.add_root方法代码示例

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


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

示例1: test_uncaptcha_compatibility

# 需要导入模块: from widgy.contrib.form_builder.models import Form [as 别名]
# 或者: from widgy.contrib.form_builder.models.Form import add_root [as 别名]
    def test_uncaptcha_compatibility(self):
        form = Form.add_root(widgy_site)
        fields = form.children['fields']
        fields.add_child(widgy_site, Uncaptcha)

        assert not Uncaptcha.valid_child_of(fields)
        self.assertRaises(ParentChildRejection, fields.add_child, widgy_site, Uncaptcha)
开发者ID:sigmundv,项目名称:django-widgy,代码行数:9,代码来源:tests.py

示例2: test_delete_doesnt_delete

# 需要导入模块: from widgy.contrib.form_builder.models import Form [as 别名]
# 或者: from widgy.contrib.form_builder.models.Form import add_root [as 别名]
    def test_delete_doesnt_delete(self):
        form = Form.add_root(widgy_site)
        input = form.children['fields'].add_child(widgy_site, FormInput)

        form.delete()

        form = Form.objects.get(pk=form.pk)
        self.assertTrue(form.node.is_root())
        self.assertIn(input, form.children['fields'].get_children())
开发者ID:sigmundv,项目名称:django-widgy,代码行数:11,代码来源:tests.py

示例3: test_widget

# 需要导入模块: from widgy.contrib.form_builder.models import Form [as 别名]
# 或者: from widgy.contrib.form_builder.models.Form import add_root [as 别名]
    def test_widget(self):
        self.form = Form.add_root(widgy_site)

        field_widget = self.form.children['fields'].add_child(widgy_site, FormInput,
                                                              type='checkbox',
                                                              label='Test',
                                                              )
        field = field_widget.get_formfield()

        self.assertTrue(isinstance(field.widget, forms.CheckboxInput))
开发者ID:sigmundv,项目名称:django-widgy,代码行数:12,代码来源:tests.py

示例4: setUp

# 需要导入模块: from widgy.contrib.form_builder.models import Form [as 别名]
# 或者: from widgy.contrib.form_builder.models.Form import add_root [as 别名]
    def setUp(self):
        self.form = form = Form.add_root(widgy_site)

        self.to_field = to_field = form.children['fields'].add_child(widgy_site, FormInput)
        to_field.type = 'email'
        to_field.save()

        self.email_handler = email_handler = form.children['meta'].children['handlers'].add_child(widgy_site, EmailUserHandler)
        email_handler.to_ident = to_field.ident
        email_handler.save()
开发者ID:sigmundv,项目名称:django-widgy,代码行数:12,代码来源:tests.py

示例5: make_form

# 需要导入模块: from widgy.contrib.form_builder.models import Form [as 别名]
# 或者: from widgy.contrib.form_builder.models.Form import add_root [as 别名]
 def make_form(self):
     form = Form.add_root(widgy_site)
     fields = []
     fields.append(form.children['fields'].add_child(widgy_site, FormInput,
                                                     label='field 1',
                                                     type='text'))
     fields.append(form.children['fields'].add_child(widgy_site, FormInput,
                                                     label='field 2',
                                                     type='text'))
     fields.append(form.children['fields'].add_child(widgy_site, Textarea,
                                                     label='field 3',))
     return form, fields
开发者ID:sigmundv,项目名称:django-widgy,代码行数:14,代码来源:tests.py

示例6: test_get_formfield

# 需要导入模块: from widgy.contrib.form_builder.models import Form [as 别名]
# 或者: from widgy.contrib.form_builder.models.Form import add_root [as 别名]
    def test_get_formfield(self):
        self.form = Form.add_root(widgy_site)

        input = self.form.children['fields'].add_child(widgy_site, FormInput)
        input.type = 'text'
        input.label = 'Test'
        input.save()

        field = input.get_formfield()

        self.assertTrue(isinstance(field, forms.CharField))
        self.assertEqual(field.label, 'Test')
开发者ID:sigmundv,项目名称:django-widgy,代码行数:14,代码来源:tests.py

示例7: test_serialize_file_field

# 需要导入模块: from widgy.contrib.form_builder.models import Form [as 别名]
# 或者: from widgy.contrib.form_builder.models.Form import add_root [as 别名]
    def test_serialize_file_field(self):
        form = Form.add_root(widgy_site)
        file_field = form.children['fields'].add_child(widgy_site, FileUpload,
                                                       required=False)

        FormSubmission.objects.submit(form=form, data={
            file_field.get_formfield_name(): ContentFile(b'foobar', name='asdf.txt'),
        })

        FormSubmission.objects.submit(form=form, data={
            file_field.get_formfield_name(): None,
        })

        serialized_values = [s[file_field.ident] for s in form.submissions.as_dictionaries()]

        self.assertEqual(serialized_values, [
            '/media/form-uploads/asdf.txt',
            '',
        ])
开发者ID:sigmundv,项目名称:django-widgy,代码行数:21,代码来源:tests.py

示例8: setUp

# 需要导入模块: from widgy.contrib.form_builder.models import Form [as 别名]
# 或者: from widgy.contrib.form_builder.models.Form import add_root [as 别名]
 def setUp(self):
     self.factory = RequestFactory()
     self.form = Form.add_root(widgy_site)
开发者ID:sigmundv,项目名称:django-widgy,代码行数:5,代码来源:test_core.py


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