refactor(config_management): Adjust rendered config str -> dict

ref: #248 #353
This commit is contained in:
2024-10-17 13:55:38 +09:30
parent 976a5f0706
commit cb6f15b933
4 changed files with 6 additions and 5 deletions

View File

@ -17,4 +17,5 @@
"ITSM"
],
"cSpell.language": "en-AU",
"jest.enable": false,
}

View File

@ -245,13 +245,13 @@ class ConfigGroups(GroupsCommonFields, SaveHistory):
return self.parent
def render_config(self) -> str:
def render_config(self):
config: dict = dict()
if self.parent:
config.update(json.loads(ConfigGroups.objects.get(id=self.parent.id).render_config()))
config.update(ConfigGroups.objects.get(id=self.parent.id).render_config())
if self.config:
@ -294,7 +294,7 @@ class ConfigGroups(GroupsCommonFields, SaveHistory):
config['software'] = merge_software(config['software'], software_actions['software'])
return json.dumps(config)
return config

View File

@ -61,7 +61,7 @@ class ConfigGroupsModel(
def test_config_groups_rendered_config_is_dict(self):
""" Rendered Config is a string """
assert type(self.item.render_config()) is str
assert type(self.item.render_config()) is dict
def test_config_groups_rendered_config_is_correct(self):

View File

@ -155,7 +155,7 @@ class View(ChangeView):
context['child_groups'] = ConfigGroups.objects.filter(parent=self.kwargs['pk'])
context['config'] = json.dumps(json.loads(self.object.render_config()), indent=4, sort_keys=True)
context['config'] = json.dumps(self.object.render_config(), indent=4, sort_keys=True)
context['tickets'] = TicketLinkedItem.objects.filter(