Make a lot of pimp in the Forum

This commit is contained in:
Skia 2017-05-20 12:40:30 +02:00
parent ec307cd5df
commit d7135e4d27
7 changed files with 231 additions and 134 deletions

View File

@ -48,8 +48,8 @@ a {
.ib { .ib {
display: inline-block; display: inline-block;
padding: 2px; padding: 1px;
margin: 2px; margin: 1px;
} }
.w_big { .w_big {
@ -57,11 +57,11 @@ a {
} }
.w_medium { .w_medium {
width: 45%; width: 47%;
} }
.w_small { .w_small {
width: 20%; width: 23%;
} }
/*--------------------------------HEADER-------------------------------*/ /*--------------------------------HEADER-------------------------------*/
@ -271,11 +271,15 @@ code {
} }
blockquote { blockquote {
margin: 10px; margin: 5px;
padding: 5px; padding: 2px;
border: solid 1px $black-color; border: solid 1px $black-color;
} }
blockquote h5:first-child {
font-size: 100%;
}
.edit-bar { .edit-bar {
display: block; display: block;
margin: 4px; margin: 4px;
@ -498,60 +502,99 @@ textarea {
/*------------------------------FORUM----------------------------------*/ /*------------------------------FORUM----------------------------------*/
.topic a, .forum a, .category a { #forum {
a {
color: $black-color; color: $black-color;
} }
.topic a:hover, .forum a:hover, .category a:hover { a:hover {
color: #424242; color: #424242;
text-decoration: underline; text-decoration: underline;
} }
.topic { .topic {
border: solid $primary-neutral-color 1px; border: solid $primary-neutral-color 1px;
padding: 2px; padding: 1px;
margin: 2px; margin: 1px;
} p {
margin: 1px;
font-size: smaller;
}
}
.forum { .tools {
font-size: x-small;
border: none;
a {
padding: 1px;
}
}
.title {
font-size: small;
font-weight: bold;
padding: 2px;
}
.last_message date {
white-space: nowrap;
}
.last_message span {
white-space: nowrap;
text-overflow: ellipsis;
overflow:hidden;
width: 100%;
display: block;
}
.forum {
background: $primary-neutral-light-color; background: $primary-neutral-light-color;
padding: 2px; padding: 1px;
margin: 2px; margin: 1px;
} p {
margin: 1px;
font-size: smaller;
}
}
.category { .category {
margin-top: 5px;
background: $secondary-color; background: $secondary-color;
} .title {
text-transform: uppercase;
}
}
.message { .message {
padding: 2px; padding: 1px;
margin: 2px; margin: 1px;
background: $white-color; background: $white-color;
&:nth-child(odd) { &:nth-child(odd) {
background: $primary-neutral-light-color; background: $primary-neutral-light-color;
} }
h5 { .title {
font-size: 100%; font-size: 100%;
} }
&.unread { &.unread {
background: #d8e7f3; background: #d8e7f3;
} }
} }
.msg_author.deleted { .msg_author.deleted {
background: #ffcfcf; background: #ffcfcf;
} }
.msg_content { .msg_content {
&.deleted { &.deleted {
background: #ffefef; background: #ffefef;
} }
display: inline-block; display: inline-block;
width: 80%; width: 80%;
vertical-align: top; vertical-align: top;
} }
.msg_author { .msg_author {
display: inline-block; display: inline-block;
width: 19%; width: 19%;
text-align: center; text-align: center;
@ -560,18 +603,24 @@ textarea {
max-width: 70%; max-width: 70%;
margin: 0px auto; margin: 0px auto;
} }
} }
.msg_meta { .msg_header {
display: inline-block;
width: 100%;
font-size: small;
}
.msg_meta {
font-size: small; font-size: small;
list-style-type: none; list-style-type: none;
li { li {
padding: 2px; padding: 1px;
margin: 2px; margin: 1px;
}
} }
}
.forum_signature { .forum_signature {
color: #C0C0C0; color: #C0C0C0;
border-top: 1px solid #C0C0C0; border-top: 1px solid #C0C0C0;
a { a {
@ -580,6 +629,7 @@ textarea {
text-decoration: underline; text-decoration: underline;
} }
} }
}
} }
/*------------------------------SAS------------------------------------*/ /*------------------------------SAS------------------------------------*/

View File

@ -6,13 +6,14 @@
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<div> <div>
<a href="{{ url('forum:main') }}">{% trans %}Forum{% endtrans %}</a> <a href="{{ url('forum:main') }}">{% trans %}Forum{% endtrans %}</a>
{% for f in forum.get_parent_list()|reverse %} {% for f in forum.get_parent_list()|reverse %}
> <a href="{{ f.get_absolute_url() }}">{{ f }}</a> > <a href="{{ f.get_absolute_url() }}">{{ f }}</a>
{% endfor %} {% endfor %}
> <a href="{{ forum.get_absolute_url() }}">{{ forum }}</a> > <a href="{{ forum.get_absolute_url() }}">{{ forum }}</a>
</div> </div>
<div id="forum">
<h3>{{ forum.name }}</h3> <h3>{{ forum.name }}</h3>
<p> <p>
{% if user.is_in_group(settings.SITH_GROUP_FORUM_ADMIN_ID) or user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID) %} {% if user.is_in_group(settings.SITH_GROUP_FORUM_ADMIN_ID) or user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID) %}
@ -34,6 +35,7 @@
</div> </div>
</div> </div>
</div> </div>
{{ display_forum(forum, user, True) }}
{% for f in forum.children.all() %} {% for f in forum.children.all() %}
{{ display_forum(f, user) }} {{ display_forum(f, user) }}
{% endfor %} {% endfor %}
@ -58,7 +60,13 @@
{% for t in topics %} {% for t in topics %}
{{ display_topic(t, user) }} {{ display_topic(t, user) }}
{% endfor %} {% endfor %}
<p style="text-align: right; background: #d8e7f3;">
{% for p in topics.paginator.page_range %}
<span class="ib" style="background: {% if p == topics.number %}white{% endif %}; margin: 0;"><a href="?topic_page={{ p }}">{{ p }}</a></span>
{% endfor %}
</p>
{% endif %} {% endif %}
</div>
{% endblock %} {% endblock %}

View File

@ -15,9 +15,17 @@
<a class="ib" href="{{ url('forum:mark_all_as_read') }}">{% trans %}Mark all as read{% 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:last_unread') }}">{% trans %}Refresh{% endtrans %}</a> <a class="ib" href="{{ url('forum:last_unread') }}">{% trans %}Refresh{% endtrans %}</a>
</p> </p>
{% for t in forumtopic_list %} {% for t in page_obj.object_list %}
{{ display_topic(t, user, True) }} {{ display_topic(t, user, True) }}
{% endfor %} {% endfor %}
<p style="text-align: right; background: #d8e7f3;">
{% for p in paginator.page_range %}
<span class="ib" style="background: {% if p == paginator.number %}white{% endif %}; margin: 0;">
<a href="?page={{ p }}">{{ p }}</a>
</span>
{% endfor %}
</p>
{% endblock %} {% endblock %}

View File

@ -1,37 +1,43 @@
{% from 'core/macros.jinja' import user_profile_link %} {% from 'core/macros.jinja' import user_profile_link %}
{% macro display_forum(forum, user) %} {% macro display_forum(forum, user, is_root=False) %}
<div class="forum {% if forum.is_category %}category{% endif %}"> <div class="forum {% if is_root %}category{% endif %}">
<div class="ib w_big"> <div class="ib w_big">
{% if not forum.is_category %} {% if not is_root %}
<a class="ib w_big" href="{{ url('forum:view_forum', forum_id=forum.id) }}"> <a class="ib w_big" href="{{ url('forum:view_forum', forum_id=forum.id) }}">
{% else %} {% else %}
<div class="ib w_big"> <div class="ib w_big">
{% endif %} {% endif %}
<h5>{{ forum.name }}</h5> <div class="title">{{ forum.name }}</div>
<p>{{ forum.description }}</p> <p>{{ forum.description }}</p>
{% if not forum.is_category %} {% if not is_root %}
</a> </a>
{% else %} {% else %}
</div> </div>
{% endif %} {% endif %}
{% if user.is_owner(forum) %} {% if user.is_owner(forum) %}
<div class="tools">
<a class="ib" href="{{ url('forum:edit_forum', forum_id=forum.id) }}">{% trans %}Edit{% endtrans %}</a> <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> <a class="ib" href="{{ url('forum:delete_forum', forum_id=forum.id) }}">{% trans %}Delete{% endtrans %}</a>
</div>
{% endif %} {% endif %}
</div> </div>
{% if not forum.is_category %} {% if not is_root %}
<div class="ib w_small"> <div class="ib w_small">
<div class="ib w_medium"> <p class="ib w_medium">
{{ forum.topic_number }} {{ forum.topic_number }}
</div> </p>
<div class="ib w_medium" style="font-size: x-small; text-align: center"> <div class="ib w_medium last_message" style="font-size: x-small; text-align: center">
{% if forum.last_message %} {% if forum.last_message %}
{{ forum.last_message.author }} <br/> {{ forum.last_message.author }} <br/>
<a href="{{ forum.last_message.get_absolute_url() }}"> <a href="{{ forum.last_message.get_absolute_url() }}">
<date>
{{ forum.last_message.date|localtime|date(DATETIME_FORMAT) }} {{ forum.last_message.date|localtime|date(DATETIME_FORMAT) }}
{{ forum.last_message.date|localtime|time(DATETIME_FORMAT) }}<br/> {{ forum.last_message.date|localtime|time(DATETIME_FORMAT) }}
</date><br>
<span>
{{ forum.last_message.topic }} {{ forum.last_message.topic }}
</span>
</a> </a>
{% endif %} {% endif %}
</div> </div>
@ -48,33 +54,33 @@
{% else %} {% else %}
<a class="ib w_big" href="{{ url('forum:view_topic', topic_id=topic.id) }}"> <a class="ib w_big" href="{{ url('forum:view_topic', topic_id=topic.id) }}">
{% endif %} {% endif %}
<h5>{{ topic.title }}</h5> <div class="title">{{ topic.title }}</div>
<p>{{ topic.description }}</p> <p>{{ topic.description }}</p>
</a> </a>
{% if user.can_edit(topic) %} {% if user.can_edit(topic) %}
<div class="ib" style="text-align: center;"> <div class="ib tools" style="text-align: center;">
<a href="{{ url('forum:edit_topic', topic_id=topic.id) }}">{% trans %}Edit{% endtrans %}</a> <a href="{{ url('forum:edit_topic', topic_id=topic.id) }}">{% trans %}Edit{% endtrans %}</a>
</div> </div>
{% endif %} {% endif %}
</div> </div>
<div class="ib w_medium last_message">
<div class="ib w_medium"> <div class="ib w_medium">
<div class="ib w_medium"> <p class="ib w_medium" style="text-align: center;">
<div class="ib w_medium" style="text-align: center;">
{{ user_profile_link(topic.author) }} {{ user_profile_link(topic.author) }}
</div> </p>
<div class="ib w_medium" style="text-align: center;"> <p class="ib w_medium" style="text-align: center;">
{{ topic.messages.count() }} {{ topic.messages.count() }}
</p>
</div> </div>
</div> <p class="ib w_medium" style="text-align: center;">
<div class="ib w_medium" style="text-align: center;">
{% set last_msg = topic.last_message %} {% set last_msg = topic.last_message %}
{% if last_msg %} {% if last_msg %}
{{ user_profile_link(last_msg.author) }} <br/> {{ user_profile_link(last_msg.author) }} <br/>
<a href="{{ last_msg.get_absolute_url() }}"> <a href="{{ last_msg.get_absolute_url() }}">
{{ last_msg.date|date(DATETIME_FORMAT) }} {{ last_msg.date|time(DATETIME_FORMAT) }} <date>{{ last_msg.date|date(DATETIME_FORMAT) }} {{ last_msg.date|time(DATETIME_FORMAT) }}</date>
</a> </a>
{% endif %} {% endif %}
</div> </p>
</div> </div>
</div> </div>
{% endmacro %} {% endmacro %}
@ -92,12 +98,9 @@
<strong><a href="{{ m.author.get_absolute_url() }}">{{ m.author.get_short_name() }}</a></strong> <strong><a href="{{ m.author.get_absolute_url() }}">{{ m.author.get_short_name() }}</a></strong>
</div> </div>
<div class="msg_content {% if m.deleted %}deleted{% endif %}" {% if m.id == first_unread_message_id %}id="first_unread"{% endif %}> <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%;"> <div class="msg_header">
{% if m.title %} <div class="ib w_big title">{{ m.title }}</div>
<h5>{{ m.title }}</h5> <div class="ib w_small">
{% 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 }}"> <span><a href="{{ url('forum:new_message', topic_id=m.topic.id) }}?quote_id={{ m.id }}">
{% trans %}Reply as quote{% endtrans %}</a></span> {% trans %}Reply as quote{% endtrans %}</a></span>
{% if user.can_edit(m) %} {% if user.can_edit(m) %}
@ -113,6 +116,7 @@
<br/> <br/>
<span>{{ m.date|localtime|date(DATETIME_FORMAT) }} {{ m.date|localtime|time(DATETIME_FORMAT) }}</span> <span>{{ m.date|localtime|date(DATETIME_FORMAT) }} {{ m.date|localtime|time(DATETIME_FORMAT) }}</span>
</div> </div>
</div>
<hr> <hr>
<div> <div>
{{ m.message|markdown }} {{ m.message|markdown }}

View File

@ -7,9 +7,10 @@
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<p> <p>
<a href="{{ url('forum:main') }}">{% trans %}Forum{% endtrans %}</a> > <a href="{{ url('forum:main') }}">{% trans %}Forum{% endtrans %}</a> >
</p> </p>
<div id="forum">
<h3>{% trans %}Forum{% endtrans %}</h3> <h3>{% trans %}Forum{% endtrans %}</h3>
<p> <p>
<a class="ib" href="{{ url('forum:last_unread') }}">{% trans %}View last unread messages{% endtrans %}</a> <a class="ib" href="{{ url('forum:last_unread') }}">{% trans %}View last unread messages{% endtrans %}</a>
@ -19,14 +20,28 @@
<a href="{{ url('forum:new_forum') }}">{% trans %}New forum{% endtrans %}</a> <a href="{{ url('forum:new_forum') }}">{% trans %}New forum{% endtrans %}</a>
</p> </p>
{% endif %} {% endif %}
<div>
<div class="ib w_big">
{% trans %}Title{% endtrans %}
</div>
<div class="ib w_small">
<div class="ib w_medium">
{% trans %}Topics{% endtrans %}
</div>
<div class="ib w_small">
{% trans %}Last message{% endtrans %}
</div>
</div>
</div>
{% for f in forum_list %} {% for f in forum_list %}
<div style="padding: 4px; margin: 4px"> <div>
{{ display_forum(f, user) }} {{ display_forum(f, user, True) }}
{% for c in f.children.all() %} {% for c in f.children.all() %}
{{ display_forum(c, user) }} {{ display_forum(c, user) }}
{% endfor %} {% endfor %}
</div> </div>
{% endfor %} {% endfor %}
</div>
{% endblock %} {% endblock %}

View File

@ -35,6 +35,7 @@
> <a href="{{ topic.get_absolute_url() }}">{{ topic }}</a> > <a href="{{ topic.get_absolute_url() }}">{{ topic }}</a>
</p> </p>
<h3>{{ topic.title }}</h3> <h3>{{ topic.title }}</h3>
<div id="forum">
<p>{{ topic.description }}</p> <p>{{ topic.description }}</p>
<p><a href="{{ url('forum:new_message', topic_id=topic.id) }}">{% trans %}Reply{% endtrans %}</a></p> <p><a href="{{ url('forum:new_message', topic_id=topic.id) }}">{% trans %}Reply{% endtrans %}</a></p>
@ -62,6 +63,7 @@
<span class="ib" style="background: {% if p == msgs.number %}white{% endif %}; margin: 0;"><a href="?page={{ p }}">{{ p }}</a></span> <span class="ib" style="background: {% if p == msgs.number %}white{% endif %}; margin: 0;"><a href="?page={{ p }}">{{ p }}</a></span>
{% endfor %} {% endfor %}
</p> </p>
</div>
{% endblock %} {% endblock %}

View File

@ -59,6 +59,7 @@ class ForumMarkAllAsRead(RedirectView):
class ForumLastUnread(ListView): class ForumLastUnread(ListView):
model = ForumTopic model = ForumTopic
template_name = "forum/last_unread.jinja" template_name = "forum/last_unread.jinja"
paginate_by = settings.SITH_FORUM_PAGE_LENGTH / 2
def get_queryset(self): def get_queryset(self):
l = ForumMessage.objects.exclude(readers=self.request.user).filter( l = ForumMessage.objects.exclude(readers=self.request.user).filter(
@ -117,7 +118,16 @@ class ForumDetailView(CanViewMixin, DetailView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
kwargs = super(ForumDetailView, self).get_context_data(**kwargs) kwargs = super(ForumDetailView, self).get_context_data(**kwargs)
kwargs['topics'] = self.object.topics.annotate(models.Max('messages__date')).order_by('-messages__date__max') qs = self.object.topics.order_by('-_last_message__date').select_related('_last_message')
paginator = Paginator(qs,
settings.SITH_FORUM_PAGE_LENGTH)
page = self.request.GET.get('topic_page')
try:
kwargs["topics"] = paginator.page(page)
except PageNotAnInteger:
kwargs["topics"] = paginator.page(1)
except EmptyPage:
kwargs["topics"] = paginator.page(paginator.num_pages)
return kwargs return kwargs
class TopicForm(forms.ModelForm): class TopicForm(forms.ModelForm):
@ -164,7 +174,7 @@ class ForumTopicDetailView(CanViewMixin, DetailView):
kwargs['first_unread_message_id'] = msg.id kwargs['first_unread_message_id'] = msg.id
except: except:
kwargs['first_unread_message_id'] = float("inf") kwargs['first_unread_message_id'] = float("inf")
paginator = Paginator(self.object.messages.select_related('author__avatar_pict').all(), paginator = Paginator(self.object.messages.select_related('author__avatar_pict').order_by('date'),
settings.SITH_FORUM_PAGE_LENGTH) settings.SITH_FORUM_PAGE_LENGTH)
page = self.request.GET.get('page') page = self.request.GET.get('page')
try: try: