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


Python FormidableSerializer.save方法代码示例

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


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

示例1: handle

# 需要导入模块: from formidable.serializers.forms import FormidableSerializer [as 别名]
# 或者: from formidable.serializers.forms.FormidableSerializer import save [as 别名]
 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,代码行数:12,代码来源:populate.py

示例2: test_delete_items_on_update

# 需要导入模块: from formidable.serializers.forms import FormidableSerializer [as 别名]
# 或者: from formidable.serializers.forms.FormidableSerializer import save [as 别名]
 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,代码行数:27,代码来源:test_end_point.py

示例3: test_update_fields_items

# 需要导入模块: from formidable.serializers.forms import FormidableSerializer [as 别名]
# 或者: from formidable.serializers.forms.FormidableSerializer import save [as 别名]
 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,代码行数:37,代码来源:test_end_point.py

示例4: test_create_form

# 需要导入模块: from formidable.serializers.forms import FormidableSerializer [as 别名]
# 或者: from formidable.serializers.forms.FormidableSerializer import save [as 别名]
 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,代码行数:9,代码来源:test_end_point.py

示例5: test_create_ordering

# 需要导入模块: from formidable.serializers.forms import FormidableSerializer [as 别名]
# 或者: from formidable.serializers.forms.FormidableSerializer import save [as 别名]
    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,代码行数:33,代码来源:test_end_point.py

示例6: test_create_helptext

# 需要导入模块: from formidable.serializers.forms import FormidableSerializer [as 别名]
# 或者: from formidable.serializers.forms.FormidableSerializer import save [as 别名]
 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,代码行数:11,代码来源:test_end_point.py

示例7: test_create_fields_with_defaults

# 需要导入模块: from formidable.serializers.forms import FormidableSerializer [as 别名]
# 或者: from formidable.serializers.forms.FormidableSerializer import save [as 别名]
 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,代码行数:12,代码来源:test_end_point.py

示例8: test_create_field_with_validations

# 需要导入模块: from formidable.serializers.forms import FormidableSerializer [as 别名]
# 或者: from formidable.serializers.forms.FormidableSerializer import save [as 别名]
 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,代码行数:13,代码来源:test_end_point.py

示例9: test_create_sepa

# 需要导入模块: from formidable.serializers.forms import FormidableSerializer [as 别名]
# 或者: from formidable.serializers.forms.FormidableSerializer import save [as 别名]
 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,代码行数:13,代码来源:test_end_point.py

示例10: test_create_title

# 需要导入模块: from formidable.serializers.forms import FormidableSerializer [as 别名]
# 或者: from formidable.serializers.forms.FormidableSerializer import save [as 别名]
 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,代码行数:13,代码来源:test_end_point.py

示例11: test_create_field_on_update

# 需要导入模块: from formidable.serializers.forms import FormidableSerializer [as 别名]
# 或者: from formidable.serializers.forms.FormidableSerializer import save [as 别名]
 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,代码行数:14,代码来源:test_end_point.py

示例12: test_create_order

# 需要导入模块: from formidable.serializers.forms import FormidableSerializer [as 别名]
# 或者: from formidable.serializers.forms.FormidableSerializer import save [as 别名]
 def test_create_order(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)
     self.assertTrue(
         instance.fields.filter(order=0, slug='text_input').exists()
     )
     self.assertTrue(
         instance.fields.filter(order=1, slug='input-date').exists()
     )
开发者ID:novafloss,项目名称:django-formidable,代码行数:15,代码来源:test_end_point.py

示例13: test_create_defaults_on_update

# 需要导入模块: from formidable.serializers.forms import FormidableSerializer [as 别名]
# 或者: from formidable.serializers.forms.FormidableSerializer import save [as 别名]
 def test_create_defaults_on_update(self):
     self.form.fields.create(
         type_id='dropdown', label='state', slug='text',
         order=3,
     )
     data = copy.deepcopy(self.data)
     data['fields'] = copy.deepcopy(self.fields_with_defaults)
     serializer = FormidableSerializer(instance=self.form, data=data)
     self.assertTrue(serializer.is_valid(), serializer.errors)
     instance = serializer.save()
     field = instance.fields.get(slug='state')
     self.assertEqual(field.defaults.count(), 1)
     self.assertTrue(field.defaults.filter(value='france').exists())
开发者ID:novafloss,项目名称:django-formidable,代码行数:15,代码来源:test_end_point.py

示例14: test_delete_on_update

# 需要导入模块: from formidable.serializers.forms import FormidableSerializer [as 别名]
# 或者: from formidable.serializers.forms.FormidableSerializer import save [as 别名]
 def test_delete_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()
     )
     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)
     serializer = FormidableSerializer(instance=self.form, data=self.data)
     self.assertTrue(serializer.is_valid())
     form = serializer.save()
     self.assertEquals(form.pk, self.form.pk)
     self.assertEquals(form.fields.count(), 0)
开发者ID:novafloss,项目名称:django-formidable,代码行数:17,代码来源:test_end_point.py

示例15: test_create_radios_buttons_field

# 需要导入模块: from formidable.serializers.forms import FormidableSerializer [as 别名]
# 或者: from formidable.serializers.forms.FormidableSerializer import save [as 别名]
 def test_create_radios_buttons_field(self):
     data = copy.deepcopy(self.data)
     data['fields'] = copy.deepcopy(self.radios_buttons_fields)
     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.assertTrue(field.type_id, 'radios_buttons')
     self.assertEqual(field.items.count(), 2)
     self.assertTrue(
         field.items.filter(order=0, value='tutu', label='toto').exists()
     )
     self.assertTrue(
         field.items.filter(order=1, value='foo', label='bar').exists()
     )
开发者ID:novafloss,项目名称:django-formidable,代码行数:18,代码来源:test_end_point.py


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