Coverage for formkit_ninja / management / commands / import_forms.py: 0.00%
17 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-03-06 04:12 +0000
« prev ^ index » next coverage.py v7.13.1, created at 2026-03-06 04:12 +0000
1from django.core.management.base import BaseCommand
3from formkit_ninja import formkit_schema, models
4from formkit_ninja.schemas import Schemas
5from formkit_ninja.services.schema_import import SchemaImportService
8class Command(BaseCommand):
9 help = "Load all the Partisipa forms to the database"
11 def handle(self, *args, **options):
12 models.FormComponents.objects.all().delete()
13 models.FormKitSchema.objects.all().delete()
14 models.FormKitSchemaNode.objects.all().delete()
15 models.Option.objects.all().delete()
16 models.OptionGroup.objects.all().delete()
18 schemas = Schemas()
19 for schema_name in schemas.list_schemas():
20 # Each part of the form becomes a 'Schema'
21 schema = schemas.as_json(schema_name)
22 pydantic_schema = formkit_schema.FormKitSchema.parse_obj([schema])
23 SchemaImportService.import_schema(pydantic_schema, label=schema_name)