Skip to content
Snippets Groups Projects
Commit 31fbdb31 authored by Todd Dembrey's avatar Todd Dembrey
Browse files

Improve how the score and comment block renders

parent f74e460b
No related branches found
No related tags found
No related merge requests found
...@@ -22,12 +22,12 @@ class ScoreFieldBlock(OptionalFormFieldBlock): ...@@ -22,12 +22,12 @@ class ScoreFieldBlock(OptionalFormFieldBlock):
template = 'review/render_scored_answer_field.html' template = 'review/render_scored_answer_field.html'
def render(self, value, context=None): def render(self, value, context=None):
data = json.loads(context['data']) comment, score = json.loads(context['data'])
label = value['field_label'] label = value['field_label']
context['data'] = { context.update(**{
label: data[0], 'comment': comment,
f'Score {label}': RATE_CHOICES_DICT.get(data[1], RATE_CHOICE_NA) 'score': RATE_CHOICES_DICT.get(int(score), RATE_CHOICE_NA)
} })
return super().render(value, context) return super().render(value, context)
......
{% load bleach_tags %} {% load bleach_tags %}
{% block data_display %} {% block data_display %}
{% if data %} <div>
{% for label, item in data.items %} <h5>{{ value.field_label }}</h5>
<div> <div>{{ score }}</div>
<h5>{{ label }}</h5> <div>{{ comment|bleach }}</div>
<div>{{ item|bleach }}</div> </div>
</div>
{% endfor %}
{% else %}
<div>
<h5>{{ value.field_label }}</h5>
<div>No response</div>
</div>
{% endif %}
{% endblock %} {% endblock %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment