mirror of
https://github.com/netbox-community/netbox.git
synced 2025-09-06 14:23:36 -06:00
Fix synced data support
This commit is contained in:
parent
9ecfd65fe2
commit
79e86f5f0f
@ -359,6 +359,20 @@ class ConfigContextProfileFilterForm(SavedFiltersMixin, FilterForm):
|
|||||||
model = ConfigContextProfile
|
model = ConfigContextProfile
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
FieldSet('q', 'filter_id'),
|
FieldSet('q', 'filter_id'),
|
||||||
|
FieldSet('data_source_id', 'data_file_id', name=_('Data')),
|
||||||
|
)
|
||||||
|
data_source_id = DynamicModelMultipleChoiceField(
|
||||||
|
queryset=DataSource.objects.all(),
|
||||||
|
required=False,
|
||||||
|
label=_('Data source')
|
||||||
|
)
|
||||||
|
data_file_id = DynamicModelMultipleChoiceField(
|
||||||
|
queryset=DataFile.objects.all(),
|
||||||
|
required=False,
|
||||||
|
label=_('Data file'),
|
||||||
|
query_params={
|
||||||
|
'source_id': '$data_source_id'
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -586,7 +586,7 @@ class TagForm(ChangelogMessageMixin, forms.ModelForm):
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class ConfigContextProfileForm(NetBoxModelForm):
|
class ConfigContextProfileForm(SyncedDataMixin, NetBoxModelForm):
|
||||||
schema = JSONField(
|
schema = JSONField(
|
||||||
label=_('Schema'),
|
label=_('Schema'),
|
||||||
required=False,
|
required=False,
|
||||||
@ -606,7 +606,7 @@ class ConfigContextProfileForm(NetBoxModelForm):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = ConfigContextProfile
|
model = ConfigContextProfile
|
||||||
fields = (
|
fields = (
|
||||||
'name', 'description', 'schema', 'data_source', 'data_file', 'comments', 'tags',
|
'name', 'description', 'schema', 'data_source', 'data_file', 'auto_sync_enabled', 'comments', 'tags',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,6 +60,13 @@ class ConfigContextProfile(SyncedDataMixin, PrimaryModel):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
def sync_data(self):
|
||||||
|
"""
|
||||||
|
Synchronize schema from the designated DataFile (if any).
|
||||||
|
"""
|
||||||
|
self.schema = self.data_file.get_data()
|
||||||
|
sync_data.alters_data = True
|
||||||
|
|
||||||
|
|
||||||
class ConfigContext(SyncedDataMixin, CloningMixin, CustomLinksMixin, ChangeLoggedModel):
|
class ConfigContext(SyncedDataMixin, CloningMixin, CustomLinksMixin, ChangeLoggedModel):
|
||||||
"""
|
"""
|
||||||
|
@ -552,6 +552,18 @@ class ConfigContextProfileTable(NetBoxTable):
|
|||||||
verbose_name=_('Name'),
|
verbose_name=_('Name'),
|
||||||
linkify=True
|
linkify=True
|
||||||
)
|
)
|
||||||
|
data_source = tables.Column(
|
||||||
|
verbose_name=_('Data Source'),
|
||||||
|
linkify=True
|
||||||
|
)
|
||||||
|
data_file = tables.Column(
|
||||||
|
verbose_name=_('Data File'),
|
||||||
|
linkify=True
|
||||||
|
)
|
||||||
|
is_synced = columns.BooleanColumn(
|
||||||
|
orderable=False,
|
||||||
|
verbose_name=_('Synced')
|
||||||
|
)
|
||||||
tags = columns.TagColumn(
|
tags = columns.TagColumn(
|
||||||
url_name='extras:configcontextprofile_list'
|
url_name='extras:configcontextprofile_list'
|
||||||
)
|
)
|
||||||
@ -559,9 +571,10 @@ class ConfigContextProfileTable(NetBoxTable):
|
|||||||
class Meta(NetBoxTable.Meta):
|
class Meta(NetBoxTable.Meta):
|
||||||
model = ConfigContextProfile
|
model = ConfigContextProfile
|
||||||
fields = (
|
fields = (
|
||||||
'pk', 'id', 'name', 'description', 'comments', 'tags', 'created', 'last_updated',
|
'pk', 'id', 'name', 'description', 'comments', 'data_source', 'data_file', 'is_synced', 'tags', 'created',
|
||||||
|
'last_updated',
|
||||||
)
|
)
|
||||||
default_columns = ('pk', 'name', 'description')
|
default_columns = ('pk', 'name', 'is_synced', 'description')
|
||||||
|
|
||||||
|
|
||||||
class ConfigContextTable(NetBoxTable):
|
class ConfigContextTable(NetBoxTable):
|
||||||
|
Loading…
Reference in New Issue
Block a user