@dd.displayfield(_("My answer"))
    def answer_buttons(self, obj, ar):
        # assert isinstance(obj, Answer)
        cs = obj.question.get_choiceset()
        if cs is None:
            return ''

        elems = []
        pv = dict(question=obj.question)

        ba = Responses.actions.toggle_choice
        if ba is None:
            raise Exception("No toggle_choice on {0}?".format(ar.actor))
        sar = ba.request_from(ar)

        # print("20150203 answer_buttons({0})".format(sar))

        # if the response is registered, just display the choice, no
        # toggle buttons since answer cannot be toggled:
        # 20151211
        sar.selected_rows = [obj.response]
        if not sar.get_permission():
            return str(obj)

        AnswerChoice = rt.modules.polls.AnswerChoice
        for c in cs.choices.all():
            pv.update(choice=c)
            text = str(c)
            qs = AnswerChoice.objects.filter(
                response=obj.response, **pv)
            if qs.count() == 1:
                text = [E.b('[', text, ']')]
            elif qs.count() == 0:
                pass
            else:
                raise Exception(
                    (qs.query, qs.count()) % "Oops: %s returned %d rows.")
            sar.set_action_param_values(**pv)
            e = sar.ar2button(obj.response, text, style="text-decoration:none")
            elems.append(e)
        return E.span(*join_elems(elems), class_="htmlText")
dataset/ETHPy150Open lsaffre/lino/lino/modlib/polls/models.py/AnswersByResponse.answer_buttons/swapped operands of `%`