macros.jinja 2.64 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) %}
Skia's avatar
Skia committed
19
        <a class="ib" href="{{ url('forum:edit_forum', forum_id=forum.id) }}">Edit</a>
20 21
        <a class="ib" href="{{ url('forum:delete_forum', forum_id=forum.id) }}">Delete</a>
        {% endif %}
Skia's avatar
Skia committed
22 23
    </div>
    {% if not forum.is_category %}
Skia's avatar
Skia committed
24 25 26 27 28 29 30 31 32 33 34 35
    <div class="ib w_small">
        <div class="ib w_medium">
            {{ forum.get_topic_number() }}
        </div>
        <div class="ib w_medium">
            {% set last_msg = forum.get_last_message() %}
            {% if last_msg %}
            {{ last_msg.author }} <br/>
            {{ last_msg.date|date(DATETIME_FORMAT) }} {{ last_msg.date|time(DATETIME_FORMAT) }}
            {% endif %}
        </div>
    </div>
Skia's avatar
Skia committed
36
    {% endif %}
Skia's avatar
Skia committed
37 38 39
</div>
{% endmacro %}

Skia's avatar
Skia committed
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 66 67 68 69 70 71 72 73
{% 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;">
            {% set last_msg = topic.messages.order_by('id').last() %}
            {{ 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
74