mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-27 02:48:38 -06:00
Schema should be optional
This commit is contained in:
parent
7edc67ed8a
commit
1be9209b04
@ -409,6 +409,7 @@ class DeviceTypeForm(NetBoxModelForm):
|
|||||||
class ModuleTypeProfileForm(NetBoxModelForm):
|
class ModuleTypeProfileForm(NetBoxModelForm):
|
||||||
schema = JSONField(
|
schema = JSONField(
|
||||||
label=_('Schema'),
|
label=_('Schema'),
|
||||||
|
required=False,
|
||||||
help_text=_("Enter a valid JSON schema to define supported attributes.")
|
help_text=_("Enter a valid JSON schema to define supported attributes.")
|
||||||
)
|
)
|
||||||
comments = CommentField()
|
comments = CommentField()
|
||||||
|
@ -25,7 +25,7 @@ class Migration(migrations.Migration):
|
|||||||
('description', models.CharField(blank=True, max_length=200)),
|
('description', models.CharField(blank=True, max_length=200)),
|
||||||
('comments', models.TextField(blank=True)),
|
('comments', models.TextField(blank=True)),
|
||||||
('name', models.CharField(max_length=100, unique=True)),
|
('name', models.CharField(max_length=100, unique=True)),
|
||||||
('schema', models.JSONField()),
|
('schema', models.JSONField(blank=True, null=True)),
|
||||||
('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
|
('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
|
@ -33,6 +33,8 @@ class ModuleTypeProfile(PrimaryModel):
|
|||||||
unique=True
|
unique=True
|
||||||
)
|
)
|
||||||
schema = models.JSONField(
|
schema = models.JSONField(
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
verbose_name=_('schema')
|
verbose_name=_('schema')
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -50,6 +52,7 @@ class ModuleTypeProfile(PrimaryModel):
|
|||||||
super().clean()
|
super().clean()
|
||||||
|
|
||||||
# Validate the schema definition
|
# Validate the schema definition
|
||||||
|
if self.schema:
|
||||||
try:
|
try:
|
||||||
JSONSchemaValidator.check_schema(self.schema)
|
JSONSchemaValidator.check_schema(self.schema)
|
||||||
except SchemaError as e:
|
except SchemaError as e:
|
||||||
|
Loading…
Reference in New Issue
Block a user