Commit eee6f41d authored by Michal Čihař's avatar Michal Čihař

Optimize rendering of checks

Inclusion means extra evaluation of context vars, let's avoid it by
template tag.
parent 1c95d84c
......@@ -287,6 +287,13 @@ def show_message(tags, message):
}
@register.inclusion_tag('list-checks.html')
def show_checks(checks):
return {
'checks': checks,
}
@register.simple_tag
def avatar(user, size=80):
url = avatar_for_email(user.email, size)
......
......@@ -14,7 +14,7 @@
<tr>
<th>{{ unit.translation.language }}</th>
<td>{{ unit.get_state_flags }}</td>
<td>{% with unit.checks as checks %}{% include "list-checks.html" %}{% endwith %}</td>
<td>{% show_checks unit.checks %}</td>
<td><a href="{{ unit.get_absolute_url }}" class="button small-button">{% trans "Edit" %}</a></td>
</tr>
{% endfor %}
......
......@@ -36,16 +36,15 @@
</thead>
<tbody>
{% for source in sources.object_list %}
{% with source.get_source_comments as comments %}
<tr>
<td class="expander">
<span class="ui-icon ui-icon-triangle-1-e expander-icon"></span>
</td>
<td class="translatetext expander">{{ source.source|fmttranslation }}</td>
<td>
{% with source.active_source_checks as checks %}
{% include "list-checks.html" %}
{% endwith %}
{% if source.get_source_comments.exists %}
{% show_checks source.active_source_checks %}
{% if comments %}
<span class="check">{% trans "Comment" %}</span>
{% endif %}
</td>
......@@ -58,18 +57,17 @@
{% with source as unit %}
{% include "unit-details.html" %}
{% endwith %}
{% with source.get_source_comments as comments %}
{% if comments %}
<tr><th colspan="2">{% trans "User comments" %}</th></tr>
{% include "list-comments.html" %}
{% endif %}
{% endwith %}
<tr class="details"><td colspan="2"><a href="{% url 'js-detail' project=object.project.slug subproject=object.slug checksum=source.checksum %}" class="load-details"></a><img src="{% get_media_prefix %}loading.gif" /></td></tr>
</table>
</td>
<td>
</td>
</tr>
{% endwith %}
{% endfor %}
</tbody>
</table>
......
......@@ -99,7 +99,7 @@
<tr>
<th class="labelscolumn">{% trans "Failing checks" %}</th>
<td>
{% include "list-checks.html" %}
{% show_checks checks %}
</td>
</tr>
{% endif %}
......@@ -268,7 +268,7 @@
{% with unit.active_source_checks as checks %}
{% if checks %}
<h4>{% trans "Failing checks" %}</h4>
{% include "list-checks.html" %}
{% show_checks checks %}
{% endif %}
{% endwith %}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment