本文整理汇总了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)
示例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())
示例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))
示例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()
示例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
示例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')
示例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',
'',
])
示例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)