Skip to content

Commit

Permalink
chore: Fix model of templates returned by the database
Browse files Browse the repository at this point in the history
  • Loading branch information
TheophileDiot committed Aug 8, 2024
1 parent b4df834 commit f99a6de
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/common/db/Database.py
Original file line number Diff line number Diff line change
Expand Up @@ -3191,7 +3191,7 @@ def get_templates(self, plugin: Optional[str] = None) -> Dict[str, dict]:

templates = {}
for template in query:
templates[template.id] = {"plugin_id": template.plugin_id, "name": template.name, "settings": {}, "configs": {}, "steps": {}}
templates[template.id] = {"plugin_id": template.plugin_id, "name": template.name, "settings": {}, "configs": {}, "steps": []}

steps_settings = {}
for setting in (
Expand Down Expand Up @@ -3226,12 +3226,12 @@ def get_templates(self, plugin: Optional[str] = None) -> Dict[str, dict]:
.with_entities(Template_steps.id, Template_steps.title, Template_steps.subtitle)
.filter_by(template_id=template.id)
):
templates[template.id]["steps"][step.id] = {"title": step.title, "subtitle": step.subtitle}
templates[template.id]["steps"].append({"title": step.title, "subtitle": step.subtitle})

if step.id in steps_settings:
templates[template.id]["steps"][step.id]["settings"] = steps_settings[step.id]
templates[template.id]["steps"][step.id - 1]["settings"] = steps_settings[step.id]
if step.id in steps_configs:
templates[template.id]["steps"][step.id]["configs"] = steps_configs[step.id]
templates[template.id]["steps"][step.id - 1]["configs"] = steps_configs[step.id]

return templates

Expand Down

0 comments on commit f99a6de

Please sign in to comment.