mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-14 02:03:22 +00:00
132 lines
5.5 KiB
Django/Jinja
132 lines
5.5 KiB
Django/Jinja
{% from 'core/macros.jinja' import user_profile_link %}
|
||
|
||
{% macro display_forum(forum, user) %}
|
||
<div class="forum {% if forum.is_category %}category{% endif %}">
|
||
<div class="ib w_big">
|
||
{% if not forum.is_category %}
|
||
<a class="ib w_big" href="{{ url('forum:view_forum', forum_id=forum.id) }}">
|
||
{% else %}
|
||
<div class="ib w_big">
|
||
{% endif %}
|
||
<h5>{{ forum.name }}</h5>
|
||
<p>{{ forum.description }}</p>
|
||
{% if not forum.is_category %}
|
||
</a>
|
||
{% else %}
|
||
</div>
|
||
{% endif %}
|
||
{% if user.is_owner(forum) %}
|
||
<a class="ib" href="{{ url('forum:edit_forum', forum_id=forum.id) }}">{% trans %}Edit{% endtrans %}</a>
|
||
<a class="ib" href="{{ url('forum:delete_forum', forum_id=forum.id) }}">{% trans %}Delete{% endtrans %}</a>
|
||
{% endif %}
|
||
</div>
|
||
{% if not forum.is_category %}
|
||
<div class="ib w_small">
|
||
<div class="ib w_medium">
|
||
{{ forum.topic_number }}
|
||
</div>
|
||
<div class="ib w_medium">
|
||
{% if forum.last_message %}
|
||
{{ forum.last_message.author }} <br/>
|
||
<a href="{{ forum.last_message.get_absolute_url() }}">
|
||
{{ forum.last_message.date|localtime|date(DATETIME_FORMAT) }} {{ forum.last_message.date|localtime|time(DATETIME_FORMAT) }}
|
||
</a>
|
||
{% endif %}
|
||
</div>
|
||
</div>
|
||
{% endif %}
|
||
</div>
|
||
{% endmacro %}
|
||
|
||
{% macro display_topic(topic, user, first_unread=False) %}
|
||
<div class="topic">
|
||
<div class="ib w_medium">
|
||
{% if first_unread %}
|
||
<a class="ib w_big" href="{{ topic.get_first_unread_message(user).get_absolute_url() }}">
|
||
{% else %}
|
||
<a class="ib w_big" href="{{ url('forum:view_topic', topic_id=topic.id) }}">
|
||
{% endif %}
|
||
<h5>{{ topic.title }}</h5>
|
||
<p>{{ topic.description }}</p>
|
||
</a>
|
||
{% if user.can_edit(topic) %}
|
||
<div class="ib" style="text-align: center;">
|
||
<a href="{{ url('forum:edit_topic', topic_id=topic.id) }}">{% trans %}Edit{% endtrans %}</a>
|
||
</div>
|
||
{% endif %}
|
||
</div>
|
||
<div class="ib w_medium">
|
||
<div class="ib w_medium">
|
||
<div class="ib w_medium" style="text-align: center;">
|
||
{{ user_profile_link(topic.author) }}
|
||
</div>
|
||
<div class="ib w_medium" style="text-align: center;">
|
||
{{ topic.messages.count() }}
|
||
</div>
|
||
</div>
|
||
<div class="ib w_medium" style="text-align: center;">
|
||
{% set last_msg = topic.messages.order_by('id').select_related('author').last() %}
|
||
{{ user_profile_link(last_msg.author) }} <br/>
|
||
<a href="{{ last_msg.get_absolute_url() }}">
|
||
{{ last_msg.date|date(DATETIME_FORMAT) }} {{ last_msg.date|time(DATETIME_FORMAT) }}
|
||
</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
{% endmacro %}
|
||
|
||
{% macro display_message(m, user, unread=False) %}
|
||
{% if user.can_view(m) %}
|
||
<div id="msg_{{ m.id }}" class="message {% if unread %}unread{% endif %}">
|
||
<div class="msg_author {% if m.deleted %}deleted{% endif %}">
|
||
{% if m.author.avatar_pict %}
|
||
<img src="{{ m.author.avatar_pict.get_download_url() }}" alt="{% trans %}Profile{% endtrans %}" id="picture" />
|
||
{% else %}
|
||
<img src="{{ static('core/img/unknown.jpg') }}" alt="{% trans %}Profile{% endtrans %}" id="picture" />
|
||
{% endif %}
|
||
<br/>
|
||
<strong><a href="{{ m.author.get_absolute_url() }}">{{ m.author.get_short_name() }}</a></strong>
|
||
</div>
|
||
<div class="msg_content {% if m.deleted %}deleted{% endif %}" {% if m.id == first_unread_message_id %}id="first_unread"{% endif %}>
|
||
<div style="display: inline-block; width: 74%;">
|
||
{% if m.title %}
|
||
<h5>{{ m.title }}</h5>
|
||
{% endif %}
|
||
</div>
|
||
<div style="display: inline-block; width: 25%;">
|
||
<span><a href="{{ url('forum:new_message', topic_id=m.topic.id) }}?quote_id={{ m.id }}">
|
||
{% trans %}Reply as quote{% endtrans %}</a></span>
|
||
{% if user.can_edit(m) %}
|
||
<span> <a href="{{ url('forum:edit_message', message_id=m.id) }}">{% trans %}Edit{% endtrans %}</a></span>
|
||
{% endif %}
|
||
{% if m.can_be_moderated_by(user) %}
|
||
{% if m.deleted %}
|
||
<span> <a href="{{ url('forum:undelete_message', message_id=m.id) }}">{% trans %}Undelete{% endtrans %}</a></span>
|
||
{% else %}
|
||
<span> <a href="{{ url('forum:delete_message', message_id=m.id) }}">{% trans %}Delete{% endtrans %}</a></span>
|
||
{% endif %}
|
||
{% endif %}
|
||
<br/>
|
||
<span>{{ m.date|localtime|date(DATETIME_FORMAT) }} {{ m.date|localtime|time(DATETIME_FORMAT) }}</span>
|
||
</div>
|
||
<hr>
|
||
<div>
|
||
{{ m.message|markdown }}
|
||
</div>
|
||
{% if m.can_be_moderated_by(user) %}
|
||
<ul class="msg_meta">
|
||
{% for meta in m.metas.select_related('user').order_by('id') %}
|
||
<li style="background: {% if m.author == meta.user %}#bfffbf{% else %}#ffffbf{% endif %}">
|
||
{{ meta.get_action_display() }} {{ meta.user.get_display_name() }}
|
||
{% trans %} at {% endtrans %}{{ meta.date|localtime|time(DATETIME_FORMAT) }}
|
||
{% trans %} the {% endtrans %}{{ meta.date|localtime|date(DATETIME_FORMAT)}}</li>
|
||
{% endfor %}
|
||
</ul>
|
||
{% endif %}
|
||
</div>
|
||
</div>
|
||
{{ m.mark_as_read(user) or "" }}
|
||
{% endif %}
|
||
{% endmacro %}
|
||
|