mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-25 18:44:23 +00:00
Add Ariadne's thread
This commit is contained in:
parent
ea52462217
commit
4dd6f01e60
@ -56,7 +56,10 @@ class ForumTopic(models.Model):
|
|||||||
description = models.CharField(_('description'), max_length=256, default="")
|
description = models.CharField(_('description'), max_length=256, default="")
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ['-id']
|
ordering = ['-id'] # TODO: add date message ordering
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "%s" % (self.title)
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('forum:view_topic', kwargs={'topic_id': self.id})
|
return reverse('forum:view_topic', kwargs={'topic_id': self.id})
|
||||||
@ -72,7 +75,7 @@ class ForumMessage(models.Model):
|
|||||||
date = models.DateTimeField(_('date'), default=timezone.now)
|
date = models.DateTimeField(_('date'), default=timezone.now)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ['-id']
|
ordering = ['id']
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return self.topic.get_absolute_url()
|
return self.topic.get_absolute_url()
|
||||||
|
@ -21,7 +21,13 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<p>{{ forum.get_parent_list() }}</p>
|
<p>
|
||||||
|
<a href="{{ url('forum:main') }}">Forum</a>
|
||||||
|
{% for f in forum.get_parent_list() %}
|
||||||
|
> <a href="{{ f.get_absolute_url() }}">{{ f }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
> <a href="{{ forum.get_absolute_url() }}">{{ forum }}</a>
|
||||||
|
</p>
|
||||||
<h3>{{ forum.name }}</h3>
|
<h3>{{ forum.name }}</h3>
|
||||||
<a href="{{ url('forum:new_forum') }}?parent={{ forum.id }}">New forum</a>
|
<a href="{{ url('forum:new_forum') }}?parent={{ forum.id }}">New forum</a>
|
||||||
{% for f in forum.children.all() %}
|
{% for f in forum.children.all() %}
|
||||||
|
@ -17,6 +17,9 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
<p>
|
||||||
|
<a href="{{ url('forum:main') }}">Forum</a> >
|
||||||
|
</p>
|
||||||
<h3>{% trans %}Forum{% endtrans %}</h3>
|
<h3>{% trans %}Forum{% endtrans %}</h3>
|
||||||
<a href="{{ url('forum:new_forum') }}">New forum</a>
|
<a href="{{ url('forum:new_forum') }}">New forum</a>
|
||||||
{% for f in forum_list %}
|
{% for f in forum_list %}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
{% extends "core/base.jinja" %}
|
{% extends "core/base.jinja" %}
|
||||||
|
{% from 'core/macros.jinja' import user_profile_link %}
|
||||||
|
|
||||||
{% block head %}
|
{% block head %}
|
||||||
{{ super() }}
|
{{ super() }}
|
||||||
@ -20,13 +21,22 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
<p>
|
||||||
|
<a href="{{ url('forum:main') }}">Forum</a>
|
||||||
|
{% for f in topic.forum.get_parent_list() %}
|
||||||
|
> <a href="{{ f.get_absolute_url() }}">{{ f }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
> <a href="{{ topic.forum.get_absolute_url() }}">{{ topic.forum }}</a>
|
||||||
|
> <a href="{{ topic.get_absolute_url() }}">{{ topic }}</a>
|
||||||
|
</p>
|
||||||
<h3>{{ topic.title }}</h3>
|
<h3>{{ topic.title }}</h3>
|
||||||
<p>{{ topic.description }}</p>
|
<p>{{ topic.description }}</p>
|
||||||
<p><a href="{{ url('forum:new_message', topic_id=topic.id) }}">Reply</a></p>
|
<p><a href="{{ url('forum:new_message', topic_id=topic.id) }}">Reply</a></p>
|
||||||
{% for m in topic.messages.all() %}
|
{% for m in topic.messages.all() %}
|
||||||
|
<hr>
|
||||||
<div>
|
<div>
|
||||||
<h5>{{ m.title }}</h5>
|
<h5>{{ m.title }}</h5>
|
||||||
<p><strong>{{ m.author.get_display_name() }}</strong> - {{ m.date|date(DATETIME_FORMAT) }}
|
<p><strong>{{ user_profile_link(m.author) }}</strong> - {{ m.date|date(DATETIME_FORMAT) }}
|
||||||
{{ m.date|time(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>
|
<a href="{{ url('forum:new_message', topic_id=topic.id) }}?quote_id={{ m.id }}">Reply as quote</a></p>
|
||||||
<p>{{ m.message|markdown }}</p>
|
<p>{{ m.message|markdown }}</p>
|
||||||
|
@ -38,8 +38,8 @@ class ForumDetailView(DetailView):
|
|||||||
pk_url_kwarg = "forum_id"
|
pk_url_kwarg = "forum_id"
|
||||||
|
|
||||||
class ForumTopicCreateView(CreateView):
|
class ForumTopicCreateView(CreateView):
|
||||||
model = ForumTopic
|
model = ForumMessage
|
||||||
fields = ['title']
|
fields = ['title', 'message']
|
||||||
template_name = "core/create.jinja"
|
template_name = "core/create.jinja"
|
||||||
|
|
||||||
def dispatch(self, request, *args, **kwargs):
|
def dispatch(self, request, *args, **kwargs):
|
||||||
@ -49,13 +49,15 @@ class ForumTopicCreateView(CreateView):
|
|||||||
return super(ForumTopicCreateView, self).dispatch(request, *args, **kwargs)
|
return super(ForumTopicCreateView, self).dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
form.instance.forum = self.forum
|
topic = ForumTopic(title=form.instance.title, author=self.request.user, forum=self.forum)
|
||||||
|
topic.save()
|
||||||
|
form.instance.topic = topic
|
||||||
form.instance.author = self.request.user
|
form.instance.author = self.request.user
|
||||||
return super(ForumTopicCreateView, self).form_valid(form)
|
return super(ForumTopicCreateView, self).form_valid(form)
|
||||||
|
|
||||||
class ForumTopicEditView(UpdateView):
|
class ForumTopicEditView(UpdateView):
|
||||||
model = ForumTopic
|
model = ForumTopic
|
||||||
fields = ['title']
|
fields = ['title', 'forum']
|
||||||
pk_url_kwarg = "topic_id"
|
pk_url_kwarg = "topic_id"
|
||||||
template_name = "core/edit.jinja"
|
template_name = "core/edit.jinja"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user