mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-22 07:41:14 +00:00
Merge pull request #956 from ae-utbm/query-page-hist
Fix N+1 queries on page history
This commit is contained in:
commit
29c4a36479
@ -3,17 +3,18 @@
|
|||||||
{% macro page_history(page) %}
|
{% macro page_history(page) %}
|
||||||
<p>{% trans page_name=page.name %}You're seeing the history of page "{{ page_name }}"{% endtrans %}</p>
|
<p>{% trans page_name=page.name %}You're seeing the history of page "{{ page_name }}"{% endtrans %}</p>
|
||||||
<ul>
|
<ul>
|
||||||
{% for r in (page.revisions.all()|sort(attribute='date', reverse=True)) %}
|
{% set page_name = page.get_full_name() %}
|
||||||
{% if loop.index < 2 %}
|
{%- for rev in page.revisions.order_by("-date").select_related("author") -%}
|
||||||
<li><a href="{{ url('core:page', page_name=page.get_full_name()) }}">{% trans %}last{% endtrans %}</a> -
|
<li>
|
||||||
{{ user_profile_link(page.revisions.last().author) }} -
|
{% if loop.first %}
|
||||||
{{ page.revisions.last().date|localtime|date(DATETIME_FORMAT) }} {{ page.revisions.last().date|localtime|time(DATETIME_FORMAT) }}</a></li>
|
<a href="{{ url('core:page', page_name=page_name) }}">{% trans %}last{% endtrans %}</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li><a href="{{ url('core:page_rev', page_name=page.get_full_name(), rev=r['id']) }}">{{ r.revision }}</a> -
|
<a href="{{ url('core:page_rev', page_name=page_name, rev=rev.id) }}">{{ rev.revision }}</a>
|
||||||
{{ user_profile_link(r.author) }} -
|
{% endif %}
|
||||||
{{ r.date|localtime|date(DATETIME_FORMAT) }} {{ r.date|localtime|time(DATETIME_FORMAT) }}</a></li>
|
{{ user_profile_link(rev.author) }} -
|
||||||
{% endif %}
|
{{ rev.date|localtime|date(DATETIME_FORMAT) }} {{ rev.date|localtime|time(DATETIME_FORMAT) }}
|
||||||
{% endfor %}
|
</li>
|
||||||
|
{%- endfor -%}
|
||||||
</ul>
|
</ul>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user