Sith/forum/templates/forum/forum.jinja
thomas girod ef968f3673
Better usage of cache for groups and clubs related operations (#634)
* Better usage of cache for group retrieval

* Cache clearing on object deletion or update

* replace signals by save and delete override

* add is_anonymous check in is_owned_by

Add in many is_owned_by(self, user) methods that user is not anonymous. Since many of those functions do db queries, this should reduce a little bit the load of the db.

* Stricter usage of User.is_in_group

Constrain the parameters that can be passed to the function to make sure only a str or an int can be used. Also force to explicitly specify if the group id or the group name is used.

* write test and correct bugs

* remove forgotten populate commands

* Correct test
2023-05-02 12:36:59 +02:00

75 lines
2.3 KiB
Django/Jinja

{% extends "core/base.jinja" %}
{% from 'forum/macros.jinja' import display_forum, display_breadcrumb, display_topic, display_search_bar %}
{% block title %}
{{ forum }}
{% endblock %}
{% block content %}
{{ display_breadcrumb(forum) }}
<div id="forum">
<h3>{{ forum.name }}</h3>
<p>
{%
if user.is_com_admin
or user.is_in_group(pk=settings.SITH_GROUP_FORUM_ADMIN_ID)
or user.can_edit(forum)
%}
<a class="ib button" href="{{ url('forum:new_forum') }}?parent={{ forum.id }}">{% trans %}New forum{% endtrans %}</a> <br/>
{% endif %}
{% if not forum.is_category %}
<a class="ib button" href="{{ url('forum:new_topic', forum_id=forum.id) }}">{% trans %}New topic{% endtrans %}</a>
{% endif %}
{{ display_search_bar(request) }}
</p>
{% if forum.children.exists() %}
<div>
<div class="ib w_big">
{% trans %}Title{% endtrans %}
</div>
<div class="ib w_small">
<div class="ib w_medium">
{% trans %}Topics{% endtrans %}
</div>
<div class="ib w_small">
{% trans %}Last message{% endtrans %}
</div>
</div>
</div>
{{ display_forum(forum, user, True) }}
{% for f in forum.children.all().select_related("_last_message__author", "_last_message__topic") %}
{{ display_forum(f, user) }}
{% endfor %}
{% endif %}
{% if topics %}
<div>
<div class="ib w_medium">
{% trans %}Title{% endtrans %}
</div>
<div class="ib w_medium">
<div class="ib w_small">
{% trans %}Author{% endtrans %}
</div>
<div class="ib w_medium">
{% trans %}Messages{% endtrans %}
</div>
<div class="ib w_small">
{% trans %}Last message{% endtrans %}
</div>
</div>
</div>
{% for t in topics %}
{{ display_topic(t, user) }}
{% endfor %}
<p style="text-align: right; background: #d8e7f3;">
{% for p in topics.paginator.page_range %}
<span class="ib" style="background: {% if p == topics.number %}white{% endif %}; margin: 0;"><a href="?topic_page={{ p }}">{{ p }}</a></span>
{% endfor %}
</p>
{% endif %}
</div>
{% endblock %}