本文整理汇总了Python中widgy.contrib.form_builder.models.Form类的典型用法代码示例。如果您正苦于以下问题:Python Form类的具体用法?Python Form怎么用?Python Form使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Form类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_uncaptcha_compatibility
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
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
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
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
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
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
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
def setUp(self):
self.factory = RequestFactory()
self.form = Form.add_root(widgy_site)