mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-26 02:54:20 +00:00
Improve forum style and templates
This commit is contained in:
parent
ff77df3646
commit
93f5096140
@ -372,6 +372,42 @@ textarea {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
/*------------------------------FORUM----------------------------------*/
|
||||
.topic a, .forum a, .category a {
|
||||
color: black;
|
||||
}
|
||||
.topic a:hover, .forum a:hover, .category a:hover {
|
||||
color: #242424;
|
||||
}
|
||||
.topic {
|
||||
border: solid skyblue 1px;
|
||||
padding: 2px;
|
||||
margin: 2px;
|
||||
}
|
||||
.forum {
|
||||
background: lightblue;
|
||||
padding: 2px;
|
||||
margin: 2px;
|
||||
}
|
||||
.category {
|
||||
background: skyblue;
|
||||
}
|
||||
.message {
|
||||
padding: 2px;
|
||||
margin: 2px;
|
||||
background: skyblue;
|
||||
}
|
||||
.message h5 {
|
||||
font-size: 100%;
|
||||
}
|
||||
.msg_author {
|
||||
display: inline-block;
|
||||
width: 19%;
|
||||
}
|
||||
.msg_author img {
|
||||
max-width: 80%;
|
||||
margin: 0px auto;
|
||||
}
|
||||
/*------------------------------SAS------------------------------------*/
|
||||
.album {
|
||||
display: inline-block;
|
||||
|
@ -1,24 +1,6 @@
|
||||
{% extends "core/base.jinja" %}
|
||||
{% from 'forum/macros.jinja' import display_forum %}
|
||||
|
||||
{% block head %}
|
||||
{{ super() }}
|
||||
<style type="text/css" media="all">
|
||||
.topic {
|
||||
border: solid skyblue 1px;
|
||||
padding: 2px;
|
||||
margin: 2px;
|
||||
}
|
||||
.forum {
|
||||
background: lightblue;
|
||||
padding: 2px;
|
||||
margin: 2px;
|
||||
}
|
||||
.category {
|
||||
background: skyblue;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
{% from 'core/macros.jinja' import user_profile_link %}
|
||||
|
||||
{% block content %}
|
||||
<p>
|
||||
@ -33,15 +15,23 @@
|
||||
{% for f in forum.children.all() %}
|
||||
{{ display_forum(f) }}
|
||||
{% endfor %}
|
||||
{% for t in forum.topics.all() %}
|
||||
{% for t in topics %}
|
||||
<div class="topic">
|
||||
<p>
|
||||
<a href="{{ url('forum:view_topic', topic_id=t.id) }}">View</a>
|
||||
<a href="{{ url('forum:edit_topic', topic_id=t.id) }}">Edit</a>
|
||||
</p>
|
||||
<a href="{{ url('forum:view_topic', topic_id=t.id) }}">
|
||||
<div style="display: inline-block; width: 80%">
|
||||
<h5>{{ t.title }}</h5>
|
||||
<p>{{ t.description }}</p>
|
||||
</div>
|
||||
</a>
|
||||
<div style="display: inline-block; width: 19%">
|
||||
{% set last_msg = t.messages.order_by('id').last() %}
|
||||
<p>Last message by {{ user_profile_link(last_msg.author) }} at {{ last_msg.date|date(DATETIME_FORMAT) }} {{
|
||||
last_msg.date|time(DATETIME_FORMAT) }}</p>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<a href="{{ url('forum:new_topic', forum_id=forum.id) }}">New topic</a>
|
||||
{% endblock %}
|
||||
|
@ -1,14 +1,19 @@
|
||||
{% macro display_forum(forum) %}
|
||||
<div class="forum {% if forum.is_category %}category{% endif %}">
|
||||
<p>
|
||||
{% if not forum.is_category %}
|
||||
<a href="{{ url('forum:view_forum', forum_id=forum.id) }}">View</a>
|
||||
{% endif %}
|
||||
<a href="{{ url('forum:edit_forum', forum_id=forum.id) }}">Edit</a>
|
||||
</p>
|
||||
{% if not forum.is_category %}
|
||||
<a href="{{ url('forum:view_forum', forum_id=forum.id) }}">
|
||||
{% endif %}
|
||||
<div>
|
||||
<h5>{{ forum.name }}</h5>
|
||||
<p>{{ forum.description }}</p>
|
||||
</div>
|
||||
{% if not forum.is_category %}
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
|
@ -2,20 +2,6 @@
|
||||
{% from 'core/macros.jinja' import user_profile_link %}
|
||||
{% from 'forum/macros.jinja' import display_forum %}
|
||||
|
||||
{% block head %}
|
||||
{{ super() }}
|
||||
<style type="text/css" media="all">
|
||||
.forum {
|
||||
background: lightblue;
|
||||
padding: 2px;
|
||||
margin: 2px;
|
||||
}
|
||||
.category {
|
||||
background: skyblue;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<p>
|
||||
<a href="{{ url('forum:main') }}">Forum</a> >
|
||||
|
@ -33,13 +33,32 @@
|
||||
<p>{{ topic.description }}</p>
|
||||
<p><a href="{{ url('forum:new_message', topic_id=topic.id) }}">Reply</a></p>
|
||||
{% for m in topic.messages.all() %}
|
||||
<hr>
|
||||
<div>
|
||||
<div class="message">
|
||||
<div class="msg_author">
|
||||
{% if m.author.profile_pict %}
|
||||
<img src="{{ m.author.profile_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 %}
|
||||
<strong>{{ user_profile_link(m.author) }}</strong>
|
||||
</div>
|
||||
<div style="display: inline-block; width: 80%;">
|
||||
<div style="display: inline-block; width: 74%;">
|
||||
{% if m.title %}
|
||||
<h5>{{ m.title }}</h5>
|
||||
<p><strong>{{ user_profile_link(m.author) }}</strong> - {{ m.date|date(DATETIME_FORMAT) }}
|
||||
{{ m.date|time(DATETIME_FORMAT) }} -
|
||||
<a href="{{ url('forum:new_message', topic_id=topic.id) }}?quote_id={{ m.id }}">Reply as quote</a></p>
|
||||
<p>{{ m.message|markdown }}</p>
|
||||
<hr>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div style="display: inline-block; width: 25%;">
|
||||
<span> <a href="{{ url('forum:edit_message', message_id=m.id) }}">{% trans %}Edit{% endtrans %}</a></span>
|
||||
<span><a href="{{ url('forum:new_message', topic_id=topic.id) }}?quote_id={{ m.id }}">
|
||||
{% trans %}Reply as quote{% endtrans %}</a></span><br/>
|
||||
<span>{{ m.date|date(DATETIME_FORMAT) }} {{ m.date|time(DATETIME_FORMAT) }}</span>
|
||||
</div>
|
||||
<div>
|
||||
{{ m.message|markdown }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
@ -11,5 +11,6 @@ urlpatterns = [
|
||||
url(r'^topic/(?P<topic_id>[0-9]+)$', ForumTopicDetailView.as_view(), name='view_topic'),
|
||||
url(r'^topic/(?P<topic_id>[0-9]+)/edit$', ForumTopicEditView.as_view(), name='edit_topic'),
|
||||
url(r'^topic/(?P<topic_id>[0-9]+)/new_message$', ForumMessageCreateView.as_view(), name='new_message'),
|
||||
url(r'^message/(?P<message_id>[0-9]+)/edit$', ForumMessageEditView.as_view(), name='edit_message'),
|
||||
]
|
||||
|
||||
|
@ -6,6 +6,7 @@ from django.core.urlresolvers import reverse, reverse_lazy
|
||||
from django.utils import timezone
|
||||
from django.conf import settings
|
||||
from django import forms
|
||||
from django.db import models
|
||||
from django.core.exceptions import PermissionDenied
|
||||
|
||||
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, CanCreateMixin, TabedViewMixin
|
||||
@ -38,6 +39,11 @@ class ForumDetailView(CanViewMixin, DetailView):
|
||||
template_name = "forum/forum.jinja"
|
||||
pk_url_kwarg = "forum_id"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
kwargs = super(ForumDetailView, self).get_context_data(**kwargs)
|
||||
kwargs['topics'] = self.object.topics.annotate(models.Max('messages__date')).order_by('-messages__date__max')
|
||||
return kwargs
|
||||
|
||||
class ForumTopicCreateView(CanCreateMixin, CreateView):
|
||||
model = ForumMessage
|
||||
fields = ['title', 'message']
|
||||
@ -68,6 +74,12 @@ class ForumTopicDetailView(CanViewMixin, DetailView):
|
||||
template_name = "forum/topic.jinja"
|
||||
context_object_name = "topic"
|
||||
|
||||
class ForumMessageEditView(CanEditMixin, UpdateView):
|
||||
model = ForumMessage
|
||||
fields = ['title', 'message']
|
||||
template_name = "core/edit.jinja"
|
||||
pk_url_kwarg = "message_id"
|
||||
|
||||
class ForumMessageCreateView(CanCreateMixin, CreateView):
|
||||
model = ForumMessage
|
||||
fields = ['title', 'message']
|
||||
|
Loading…
Reference in New Issue
Block a user