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


Python forms.FormidableSerializer类代码示例

本文整理汇总了Python中formidable.serializers.forms.FormidableSerializer的典型用法代码示例。如果您正苦于以下问题:Python FormidableSerializer类的具体用法?Python FormidableSerializer怎么用?Python FormidableSerializer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_create_ordering

    def test_create_ordering(self):
        # aggregate fields
        def extend(l, elt):
            l.extend(elt)
            return l

        fields = reduce(extend, [
            self.fields_with_items, self.fields_without_items,
            self.format_field_helptext, self.format_field_separator,
            self.format_field_title
        ], [])
        data = copy.deepcopy(self.data)
        data['fields'] = fields
        serializer = FormidableSerializer(data=data)
        self.assertTrue(serializer.is_valid())
        form = serializer.save()
        self.assertTrue(form.fields.filter(
            slug='dropdown-input', order=0
        ).exists())
        self.assertTrue(form.fields.filter(
            slug='text_input', order=1
        ).exists())
        self.assertTrue(form.fields.filter(
            slug='myhelptext', order=2
        ).exists())
        self.assertTrue(form.fields.filter(
            slug='sepa', order=3
        ).exists())
        self.assertTrue(form.fields.filter(
            slug='mytitle', order=4
        ).exists())
开发者ID:novafloss,项目名称:django-formidable,代码行数:31,代码来源:test_end_point.py

示例2: test_create_form

 def test_create_form(self):
     serializer = FormidableSerializer(data=self.data)
     self.assertTrue(serializer.is_valid())
     instance = serializer.save()
     self.assertEquals(instance.label, 'test_create')
     self.assertEquals(instance.description, 'description create')
     self.assertEquals(instance.fields.count(), 0)
开发者ID:novafloss,项目名称:django-formidable,代码行数:7,代码来源:test_end_point.py

示例3: test_update_fields_items

 def test_update_fields_items(self):
     self.dropdown_fields = self.form.fields.create(
         slug='dropdown-input', type_id='dropdown', label='weapons',
         order=self.form.get_next_field_order()
     )
     self.dropdown_fields.accesses.create(
         access_id='padawan', level=constants.EDITABLE
     )
     order = self.dropdown_fields.get_next_order()
     self.dropdown_fields.items.create(
         value='gun', label='eagle', order=order
     )
     self.dropdown_fields.items.create(
         value='sword', label='excalibur', order=order + 1
     )
     data = copy.deepcopy(self.data)
     data['fields'] = self.fields_items
     serializer = FormidableSerializer(instance=self.form, data=data)
     self.assertTrue(serializer.is_valid())
     form = serializer.save()
     self.assertEquals(form.pk, self.form.pk)
     field = form.fields.first()
     self.assertEquals(self.dropdown_fields.pk, field.pk)
     self.assertEquals(field.label, 'edited field')
     self.assertEquals(field.items.count(), 2)
     self.assertTrue(
         field.items.filter(value='gun', label='desert-eagle').exists()
     )
     self.assertTrue(
         field.items.filter(value='sword', label='Andúril').exists()
     )
     qs = field.accesses.filter(
         access_id='padawan', level=constants.REQUIRED
     )
     self.assertTrue(qs.exists())
开发者ID:novafloss,项目名称:django-formidable,代码行数:35,代码来源:test_end_point.py

示例4: test_create_field_error_validations

 def test_create_field_error_validations(self):
     data = copy.deepcopy(self.data)
     fields_data = copy.deepcopy(self.fields_with_validation)
     fields_data[0]['validations'][0]['value'] = 'test'
     data['fields'] = fields_data
     serializer = FormidableSerializer(data=data)
     self.assertFalse(serializer.is_valid())
开发者ID:novafloss,项目名称:django-formidable,代码行数:7,代码来源:test_end_point.py

示例5: test_delete_items_on_update

 def test_delete_items_on_update(self):
     self.dropdown_fields = self.form.fields.create(
         slug='dropdown-input', type_id='dropdown', label='weapons',
         order=self.form.get_next_field_order()
     )
     self.dropdown_fields.accesses.create(
         access_id='padawan', level=constants.REQUIRED
     )
     order = self.dropdown_fields.get_next_order()
     self.dropdown_fields.items.create(
         value='gun', label='eagle', order=order
     )
     self.dropdown_fields.items.create(
         value='sword', label='excalibur', order=order + 1
     )
     data = copy.deepcopy(self.data)
     data['fields'] = copy.deepcopy(self.fields_items)
     data['fields'][0]['items'] = []
     serializer = FormidableSerializer(instance=self.form, data=data)
     self.assertTrue(serializer.is_valid(), serializer.errors)
     form = serializer.save()
     self.assertEquals(form.pk, self.form.pk)
     self.assertEquals(form.fields.count(), 1)
     field = form.fields.first()
     self.assertEquals(field.items.count(), 0)
开发者ID:novafloss,项目名称:django-formidable,代码行数:25,代码来源:test_end_point.py

示例6: test_create_field_without_items

 def test_create_field_without_items(self):
     data = copy.deepcopy(self.data)
     fields = copy.deepcopy(self.fields_with_items)
     fields[0].pop('items')
     data['fields'] = fields
     serializer = FormidableSerializer(data=data)
     self.assertFalse(serializer.is_valid())
     self.assertIn('fields', serializer.errors)
开发者ID:novafloss,项目名称:django-formidable,代码行数:8,代码来源:test_end_point.py

示例7: test_create_wrong_access

 def test_create_wrong_access(self):
     data = copy.deepcopy(self.data)
     fields = copy.deepcopy(self.fields_with_items)
     fields[0]['accesses'][0]['access_id'] = 'wrong'
     data['fields'] = fields
     serializer = FormidableSerializer(data=data)
     self.assertFalse(serializer.is_valid())
     self.assertIn('fields', serializer.errors)
开发者ID:novafloss,项目名称:django-formidable,代码行数:8,代码来源:test_end_point.py

示例8: test_create_form_with_presets_invalid_argument

 def test_create_form_with_presets_invalid_argument(self):
     data = copy.deepcopy(self.data)
     data['presets'] = copy.deepcopy(self.presets_with_wrong_parameters)
     serializer = FormidableSerializer(data=data)
     self.assertFalse(serializer.is_valid(), serializer.errors)
     self.assertIn(
         serializer.errors['non_field_errors'][0],
         'Preset (confirmation) argument is using an undefined field (testField2)'  # noqa
     )
开发者ID:novafloss,项目名称:django-formidable,代码行数:9,代码来源:test_end_point.py

示例9: test_create_helptext

 def test_create_helptext(self):
     data = copy.deepcopy(self.data)
     data['fields'] = self.format_field_helptext
     serializer = FormidableSerializer(data=data)
     self.assertTrue(serializer.is_valid())
     instance = serializer.save()
     self.assertEqual(instance.fields.count(), 1)
     qs = instance.fields.filter(type_id='help_text', help_text='Hello')
     self.assertTrue(qs.exists())
开发者ID:novafloss,项目名称:django-formidable,代码行数:9,代码来源:test_end_point.py

示例10: handle

 def handle(self, *args, **options):
     for filename in options['filename']:
         with open(filename) as f:
             data = json.load(f)
             serializer = FormidableSerializer(data=data)
             if serializer.is_valid():
                 serializer.save()
                 self.stdout.write('Successfully populate "%s"' % filename)
             else:
                 self.stdout.write('Broken "%s" %s' % (filename, serializer.errors))
开发者ID:moumoutte,项目名称:django-formidable,代码行数:10,代码来源:populate.py

示例11: test_create_fields_with_defaults

 def test_create_fields_with_defaults(self):
     data = copy.deepcopy(self.data)
     data['fields'] = self.fields_with_defaults
     serializer = FormidableSerializer(data=data)
     self.assertTrue(serializer.is_valid(), serializer.errors)
     instance = serializer.save()
     self.assertEqual(instance.fields.count(), 1)
     field = instance.fields.first()
     self.assertEqual(field.defaults.count(), 1)
     self.assertTrue(field.defaults.filter(value='france').exists())
开发者ID:novafloss,项目名称:django-formidable,代码行数:10,代码来源:test_end_point.py

示例12: test_create_sepa

 def test_create_sepa(self):
     data = copy.deepcopy(self.data)
     data['fields'] = self.format_field_separator
     serializer = FormidableSerializer(data=data)
     self.assertTrue(serializer.is_valid())
     instance = serializer.save()
     self.assertEqual(instance.fields.count(), 1)
     qs = instance.fields.filter(
         type_id='separator', slug='sepa'
     )
     self.assertTrue(qs.exists())
开发者ID:novafloss,项目名称:django-formidable,代码行数:11,代码来源:test_end_point.py

示例13: test_create_title

 def test_create_title(self):
     data = copy.deepcopy(self.data)
     data['fields'] = self.format_field_title
     serializer = FormidableSerializer(data=data)
     self.assertTrue(serializer.is_valid())
     instance = serializer.save()
     self.assertEqual(instance.fields.count(), 1)
     qs = instance.fields.filter(
         type_id='title', label='This is an Onboarding Form.'
     )
     self.assertTrue(qs.exists())
开发者ID:novafloss,项目名称:django-formidable,代码行数:11,代码来源:test_end_point.py

示例14: test_create_field_with_validations

 def test_create_field_with_validations(self):
     data = copy.deepcopy(self.data)
     data['fields'] = self.fields_with_validation
     serializer = FormidableSerializer(data=data)
     self.assertTrue(serializer.is_valid())
     instance = serializer.save()
     self.assertEquals(instance.fields.count(), 2)
     field = instance.fields.filter(type_id='date').first()
     self.assertEquals(field.validations.count(), 1)
     validation = field.validations.first()
     self.assertEquals(validation.value, 'false')
开发者ID:novafloss,项目名称:django-formidable,代码行数:11,代码来源:test_end_point.py

示例15: test_create_field_on_update

 def test_create_field_on_update(self):
     data = copy.deepcopy(self.data)
     data['fields'] = self.fields
     serializer = FormidableSerializer(instance=self.form, data=data)
     self.assertTrue(serializer.is_valid())
     form = serializer.save()
     self.assertEquals(form.pk, self.form.pk)
     self.assertEquals(form.fields.count(), 1)
     field = form.fields.first()
     self.assertEquals(field.type_id, 'text')
     # check accesses are fully created
     self.assertEquals(field.accesses.count(), 4)
开发者ID:novafloss,项目名称:django-formidable,代码行数:12,代码来源:test_end_point.py


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