Skip to content

Commit

Permalink
feat(gdpr): add poll text to poll answers
Browse files Browse the repository at this point in the history
Render the poll's text in poll answers in gdpr api

Refs KER-332
  • Loading branch information
nicobav committed Mar 8, 2024
1 parent dea0395 commit 7c6b3b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions democracy/models/section.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,15 +415,16 @@ class Meta:

@poll_option_recache_on_save
class SectionPollAnswer(BasePollAnswer, SerializableMixin):
serialize_fields = (
{"name": "id"},
{"name": "option", "accessor": lambda x: x.text},
)
serialize_fields = ({"name": "id"}, {"name": "option", "accessor": lambda x: x.text}, {"name": "poll_text"})
comment = models.ForeignKey(SectionComment, related_name="poll_answers", on_delete=models.CASCADE)
option = models.ForeignKey(SectionPollOption, related_name="answers", on_delete=models.PROTECT)

objects = SerializableBaseModelManager()

@property
def poll_text(self):
return get_translations_dict(self.option.poll, "text")

class Meta:
verbose_name = _("section poll answer")
verbose_name_plural = _("section poll answers")
Expand Down
1 change: 1 addition & 0 deletions kerrokantasi/tests/gdpr/test_gdpr_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def _get_poll_answer_data(poll_answer: SectionPollAnswer) -> dict:
"children": [
{"key": "ID", "value": poll_answer.id},
{"key": "OPTION", "value": poll_answer.option.text},
{"key": "POLL_TEXT", "value": get_translations_dict(poll_answer.option.poll, "text")},
],
}

Expand Down

0 comments on commit 7c6b3b9

Please sign in to comment.