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

Skia's avatar
Skia committed
3 4
{% macro display_forum(forum, user, is_root=False) %}
<div class="forum {% if is_root %}category{% endif %}">
Skia's avatar
Skia committed
5
    <div class="ib w_big">
Skia's avatar
Skia committed
6
        {% if not is_root %}
Skia's avatar
Skia committed
7 8 9 10
        <a class="ib w_big" href="{{ url('forum:view_forum', forum_id=forum.id) }}">
        {% else %}
        <div class="ib w_big">
        {% endif %}
Skia's avatar
Skia committed
11
            <div class="title">{{ forum.name }}</div>
Skia's avatar
Skia committed
12
            <p>{{ forum.description }}</p>
Skia's avatar
Skia committed
13
        {% if not is_root %}
Skia's avatar
Skia committed
14 15 16 17
        </a>
        {% else %}
        </div>
        {% endif %}
18
        {% if user.is_owner(forum) %}
Skia's avatar
Skia committed
19
        <div class="tools">
20 21
        <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>
Skia's avatar
Skia committed
22
        </div>
23
        {% endif %}
Skia's avatar
Skia committed
24
    </div>
Skia's avatar
Skia committed
25
    {% if not is_root %}
Skia's avatar
Skia committed
26
    <div class="ib w_small">
Skia's avatar
Skia committed
27
        <p class="ib w_medium">
Skia's avatar
Skia committed
28
            {{ forum.topic_number }}
Skia's avatar
Skia committed
29 30
        </p>
        <div class="ib w_medium last_message" style="font-size: x-small; text-align: center">
Skia's avatar
Skia committed
31
            {% if forum.last_message %}
Skia's avatar
Skia committed
32
            {{ user_profile_link_short_name(forum.last_message.author) }} <br/>
Skia's avatar
Skia committed
33
            <a href="{{ forum.last_message.get_absolute_url() }}">
Skia's avatar
Skia committed
34
                <date>
Skia's avatar
Skia committed
35
                {{ forum.last_message.date|localtime|date(DATETIME_FORMAT) }}
Skia's avatar
Skia committed
36 37 38
                {{ forum.last_message.date|localtime|time(DATETIME_FORMAT) }}
                </date><br>
                <span>
Skia's avatar
Skia committed
39
                {{ forum.last_message.topic }}
Skia's avatar
Skia committed
40
                </span>
Skia's avatar
Skia committed
41
            </a>
Skia's avatar
Skia committed
42 43 44
            {% endif %}
        </div>
    </div>
Skia's avatar
Skia committed
45
    {% endif %}
Skia's avatar
Skia committed
46 47 48
</div>
{% endmacro %}

Skia's avatar
Skia committed
49 50 51 52
{% macro display_topic(topic, user, first_unread=False) %}
<div class="topic">
    <div class="ib w_medium">
        {% if first_unread %}
Skia's avatar
Skia committed
53
        <a class="ib w_big" href="{{ topic.get_first_unread_message(user).get_absolute_url() }}">
Skia's avatar
Skia committed
54 55 56
        {% else %}
        <a class="ib w_big" href="{{ url('forum:view_topic', topic_id=topic.id) }}">
        {% endif %}
Skia's avatar
Skia committed
57
            <div class="title">{{ topic.title or topic.messages.first().title }}</div>
Skia's avatar
Skia committed
58 59
            <p>{{ topic.description }}</p>
        </a>
60
        {% if user.can_edit(topic) %}
Skia's avatar
Skia committed
61
        <div class="ib tools" style="text-align: center;">
Skia's avatar
Skia committed
62 63 64 65
            <a href="{{ url('forum:edit_topic', topic_id=topic.id) }}">{% trans %}Edit{% endtrans %}</a>
        </div>
        {% endif %}
    </div>
Skia's avatar
Skia committed
66
    <div class="ib w_medium last_message">
Skia's avatar
Skia committed
67
        <div class="ib w_medium">
Skia's avatar
Skia committed
68
            <p class="ib w_medium" style="text-align: center;">
Skia's avatar
Skia committed
69
                {{ user_profile_link_short_name(topic.author) }}
Skia's avatar
Skia committed
70 71
            </p>
            <p class="ib w_medium" style="text-align: center;">
72
                {{ topic._message_number }}
Skia's avatar
Skia committed
73
            </p>
Skia's avatar
Skia committed
74
        </div>
Skia's avatar
Skia committed
75
        <p class="ib w_medium" style="text-align: center;">
76 77
            {% set last_msg = topic.last_message %}
            {% if last_msg %}
Skia's avatar
Skia committed
78
            {{ user_profile_link_short_name(last_msg.author) }} <br/>
Skia's avatar
Skia committed
79
            <a href="{{ last_msg.get_absolute_url() }}">
Skia's avatar
Skia committed
80
                <date>{{ last_msg.date|localtime|date(DATETIME_FORMAT) }} {{ last_msg.date|localtime|time(DATETIME_FORMAT) }}</date>
Skia's avatar
Skia committed
81
            </a>
82
            {% endif %}
Skia's avatar
Skia committed
83
        </p>
Skia's avatar
Skia committed
84 85 86
    </div>
</div>
{% endmacro %}
Skia's avatar
Skia committed
87

Skia's avatar
Skia committed
88 89 90 91 92 93 94 95 96 97 98 99 100
{% 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 %}>
Skia's avatar
Skia committed
101
        <div class="msg_header">
Skia's avatar
Skia committed
102 103 104 105 106 107 108 109 110
            <div class="ib w_big title">
                <a href="{{ m.get_absolute_url() }}">
                {{ m.date|localtime|date(DATETIME_FORMAT) }}
                {{ m.date|localtime|time(DATETIME_FORMAT) }}
                {%- if m.title -%}
                    - {{ m.title }}
                {%- endif -%}
                </a>
            </div>
Skia's avatar
Skia committed
111
            <div class="ib w_small">
Skia's avatar
Skia committed
112 113
                <span><a href="{{ m.get_absolute_url() }}">#{{ m.id }}</a></span>
                <br/>
Skia's avatar
Skia committed
114 115 116 117 118 119 120 121 122 123 124 125 126
                <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 %}
            </div>
Skia's avatar
Skia committed
127 128 129 130 131 132 133 134 135
        </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 %}">
Skia's avatar
Skia committed
136
                {{ meta.get_action_display() }} {{ meta.user.get_short_name() }}
Skia's avatar
Skia committed
137 138 139 140 141
                {% trans %} at {% endtrans %}{{ meta.date|localtime|time(DATETIME_FORMAT) }}
                {% trans %} the {% endtrans %}{{ meta.date|localtime|date(DATETIME_FORMAT)}}</li>
        {% endfor %}
        </ul>
        {% endif %}
Skia's avatar
Skia committed
142
        <div class="forum_signature">{{ m.author.forum_signature|markdown }}</div>
Skia's avatar
Skia committed
143 144
    </div>
</div>
145 146 147 148 149 150 151 152 153
{% else %}
<div id="msg_{{ m.id }}" class="message">
    <div class="msg_author deleted">
    </div>
    <div class="msg_content deleted">
        <p class="ib w_big">{% trans %}Deleted or unreadable message.{% endtrans %}</p>
        <p class="ib w_small">{{ m.date|localtime|date(DATETIME_FORMAT) }} {{ m.date|localtime|time(DATETIME_FORMAT) }}</p>
    </div>
</div>
Skia's avatar
Skia committed
154
{% endif %}
155
{{ m.mark_as_read(user) or "" }}
Skia's avatar
Skia committed
156 157
{% endmacro %}