macros.jinja 2.69 KB
Newer Older
Skia's avatar
Skia committed
1 2
{% from 'core/macros.jinja' import user_profile_link %}

3
{% macro display_forum(forum, user) %}
Skia's avatar
Skia committed
4
<div class="forum {% if forum.is_category %}category{% endif %}">
Skia's avatar
Skia committed
5 6 7 8 9 10 11 12 13 14 15 16 17
    <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 %}
18
        {% if user.is_owner(forum) %}
19 20
        <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>
21
        {% endif %}
Skia's avatar
Skia committed
22 23
    </div>
    {% if not forum.is_category %}
Skia's avatar
Skia committed
24 25
    <div class="ib w_small">
        <div class="ib w_medium">
Skia's avatar
Skia committed
26
            {{ forum.topic_number }}
Skia's avatar
Skia committed
27 28
        </div>
        <div class="ib w_medium">
Skia's avatar
Skia committed
29 30 31
            {% if forum.last_message %}
            {{ forum.last_message.author }} <br/>
            {{ forum.last_message.date|date(DATETIME_FORMAT) }} {{ forum.last_message.date|time(DATETIME_FORMAT) }}
Skia's avatar
Skia committed
32 33 34
            {% endif %}
        </div>
    </div>
Skia's avatar
Skia committed
35
    {% endif %}
Skia's avatar
Skia committed
36 37 38
</div>
{% endmacro %}

Skia's avatar
Skia committed
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
{% 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="{{ url('forum:view_topic', topic_id=topic.id) }}#first_unread">
        {% 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.is_owner(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;">
Skia's avatar
Skia committed
66
            {% set last_msg = topic.messages.order_by('id').select_related('author').last() %}
Skia's avatar
Skia committed
67 68 69 70 71 72
            {{ user_profile_link(last_msg.author) }} <br/>
            {{ last_msg.date|date(DATETIME_FORMAT) }} {{ last_msg.date|time(DATETIME_FORMAT) }}
        </div>
    </div>
</div>
{% endmacro %}
Skia's avatar
Skia committed
73