Skip to content

Commit

Permalink
Enhanced DialogModel
Browse files Browse the repository at this point in the history
Earlier DialogModel had answerfile_sections as string
field which made it impossible to register possible dialog
choice.
This commit switches to fields.JSON() usage which should improve
overall report readability and dialog info manipulation in
verifydialogs actor.
  • Loading branch information
fernflower authored and pirat89 committed Feb 13, 2020
1 parent 5463767 commit f06050a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion leapp/dialogs/dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def serialize(self):

@property
def answerfile_sections(self):
return ["{}.{}".format(self.scope, c.key) for c in self.components]
return {"{}.{}".format(self.scope, c.key): c.choices for c in self.components}

@property
def min_label_width(self):
Expand Down
3 changes: 1 addition & 2 deletions leapp/messaging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ def register_dialog(self, dialog, actor):
userchoices = dialog.get_answers(self._answers)
if not userchoices:
# produce DialogModel messages for all the dialogs that don't have answers in answerfile
self.produce(DialogModel(actor=actor.name, answerfile_sections=','.join(dialog.answerfile_sections)),
actor)
self.produce(DialogModel(actor=actor.name, answerfile_sections=dialog.answerfile_sections), actor)
else:
# update dialogs with answers from answerfile. That is necessary for proper answerfile generation
for component, value in userchoices.items():
Expand Down
2 changes: 1 addition & 1 deletion leapp/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class ErrorModel(Model):
class DialogModel(Model):
topic = DialogTopic

answerfile_sections = fields.String()
answerfile_sections = fields.JSON()
actor = fields.String()
details = fields.Nullable(fields.String())

Expand Down

0 comments on commit f06050a

Please sign in to comment.