mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-09 19:40:19 +00:00
Add last unread function
This commit is contained in:
@ -1,6 +1,9 @@
|
||||
{% extends "core/base.jinja" %}
|
||||
{% from 'forum/macros.jinja' import display_forum %}
|
||||
{% from 'core/macros.jinja' import user_profile_link %}
|
||||
{% from 'forum/macros.jinja' import display_forum, display_topic %}
|
||||
|
||||
{% block title %}
|
||||
{{ forum }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div>
|
||||
@ -21,34 +24,7 @@
|
||||
{{ display_forum(f, user) }}
|
||||
{% endfor %}
|
||||
{% for t in topics %}
|
||||
<div class="topic">
|
||||
<div class="ib w_medium">
|
||||
<a class="ib w_big" href="{{ url('forum:view_topic', topic_id=t.id) }}">
|
||||
<h5>{{ t.title }}</h5>
|
||||
<p>{{ t.description }}</p>
|
||||
</a>
|
||||
{% if user.is_owner(t) %}
|
||||
<div class="ib" style="text-align: center;">
|
||||
<a href="{{ url('forum:edit_topic', topic_id=t.id) }}">Edit</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(t.author) }}
|
||||
</div>
|
||||
<div class="ib w_medium" style="text-align: center;">
|
||||
{{ t.messages.count() }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="ib w_medium" style="text-align: center;">
|
||||
{% set last_msg = t.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>
|
||||
{{ display_topic(t, user) }}
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
||||
|
24
forum/templates/forum/last_unread.jinja
Normal file
24
forum/templates/forum/last_unread.jinja
Normal file
@ -0,0 +1,24 @@
|
||||
{% extends "core/base.jinja" %}
|
||||
{% from 'forum/macros.jinja' import display_topic %}
|
||||
|
||||
{% block title %}
|
||||
{% trans %}Last unread messages{% endtrans %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<p>
|
||||
<a href="{{ url('forum:main') }}">Forum</a> >
|
||||
</p>
|
||||
<h3>{% trans %}Forum{% endtrans %}</h3>
|
||||
<h4>{% trans %}Last unread messages{% endtrans %}</h4>
|
||||
<p>
|
||||
<a class="ib" href="{{ url('forum:mark_all_as_read') }}">{% trans %}Mark all as read{% endtrans %}</a>
|
||||
<a class="ib" href="{{ url('forum:last_unread') }}">{% trans %}Refresh{% endtrans %}</a>
|
||||
</p>
|
||||
{% for t in forumtopic_list %}
|
||||
{{ display_topic(t, user, True) }}
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
{% 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">
|
||||
@ -35,4 +37,38 @@
|
||||
</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="{{ 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 %}
|
||||
|
||||
|
@ -2,16 +2,25 @@
|
||||
{% from 'core/macros.jinja' import user_profile_link %}
|
||||
{% from 'forum/macros.jinja' import display_forum %}
|
||||
|
||||
{% block title %}
|
||||
{% trans %}Forum{% endtrans %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<p>
|
||||
<a href="{{ url('forum:main') }}">Forum</a> >
|
||||
</p>
|
||||
<h3>{% trans %}Forum{% endtrans %}</h3>
|
||||
<p>
|
||||
{% if user.is_in_group(settings.SITH_GROUP_FORUM_ADMIN_ID) or user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID) %}
|
||||
<a href="{{ url('forum:new_forum') }}">New forum</a>
|
||||
{% endif %}
|
||||
<a class="ib" href="{{ url('forum:last_unread') }}">{% trans %}View last unread messages{% endtrans %}</a>
|
||||
<a class="ib" href="{{ url('forum:mark_all_as_read') }}">{% trans %}Mark all as read{% endtrans %}</a>
|
||||
<a class="ib" href="{{ url('forum:main') }}">{% trans %}Refresh{% endtrans %}</a>
|
||||
</p>
|
||||
{% if user.is_in_group(settings.SITH_GROUP_FORUM_ADMIN_ID) or user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID) %}
|
||||
<p>
|
||||
<a href="{{ url('forum:new_forum') }}">{% trans %}New forum{% endtrans %}</a>
|
||||
</p>
|
||||
{% endif %}
|
||||
{% for f in forum_list %}
|
||||
<div style="padding: 4px; margin: 4px">
|
||||
{{ display_forum(f, user) }}
|
||||
|
@ -1,6 +1,10 @@
|
||||
{% extends "core/base.jinja" %}
|
||||
{% from 'core/macros.jinja' import user_profile_link %}
|
||||
|
||||
{% block title %}
|
||||
{{ topic }}
|
||||
{% endblock %}
|
||||
|
||||
{% block head %}
|
||||
{{ super() }}
|
||||
<style type="text/css" media="all">
|
||||
@ -32,8 +36,16 @@
|
||||
<h3>{{ topic.title }}</h3>
|
||||
<p>{{ topic.description }}</p>
|
||||
<p><a href="{{ url('forum:new_message', topic_id=topic.id) }}">Reply</a></p>
|
||||
{% set unread = False %}
|
||||
{% for m in topic.messages.all() %}
|
||||
{% if m.id == first_unread_message_id %}
|
||||
<div class="message unread" id="first_unread">
|
||||
{% set unread = True %}
|
||||
{% elif unread %}
|
||||
<div class="message unread">
|
||||
{% else %}
|
||||
<div class="message">
|
||||
{% endif %}
|
||||
<div class="msg_author">
|
||||
{% if m.author.profile_pict %}
|
||||
<img src="{{ m.author.profile_pict.get_download_url() }}" alt="{% trans %}Profile{% endtrans %}" id="picture" />
|
||||
@ -64,6 +76,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{# m.mark_as_read(user) or "" #}
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
||||
|
Reference in New Issue
Block a user