diff --git a/forum/models.py b/forum/models.py index a9953066..0ae36af0 100644 --- a/forum/models.py +++ b/forum/models.py @@ -56,7 +56,10 @@ class ForumTopic(models.Model): description = models.CharField(_('description'), max_length=256, default="") class Meta: - ordering = ['-id'] + ordering = ['-id'] # TODO: add date message ordering + + def __str__(self): + return "%s" % (self.title) def get_absolute_url(self): 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) class Meta: - ordering = ['-id'] + ordering = ['id'] def get_absolute_url(self): return self.topic.get_absolute_url() diff --git a/forum/templates/forum/forum.jinja b/forum/templates/forum/forum.jinja index 6b0fa851..1e052c9a 100644 --- a/forum/templates/forum/forum.jinja +++ b/forum/templates/forum/forum.jinja @@ -21,7 +21,13 @@ {% endblock %} {% block content %} -
{{ forum.get_parent_list() }}
++ Forum + {% for f in forum.get_parent_list() %} + > {{ f }} + {% endfor %} + > {{ forum }} +
+ Forum > +
+ Forum + {% for f in topic.forum.get_parent_list() %} + > {{ f }} + {% endfor %} + > {{ topic.forum }} + > {{ topic }} +
{{ topic.description }}
{% for m in topic.messages.all() %} +{{ m.author.get_display_name() }} - {{ m.date|date(DATETIME_FORMAT) }} +
{{ user_profile_link(m.author) }} - {{ m.date|date(DATETIME_FORMAT) }} {{ m.date|time(DATETIME_FORMAT) }} - Reply as quote
{{ m.message|markdown }}
diff --git a/forum/views.py b/forum/views.py index bf642f66..fef22b34 100644 --- a/forum/views.py +++ b/forum/views.py @@ -38,8 +38,8 @@ class ForumDetailView(DetailView): pk_url_kwarg = "forum_id" class ForumTopicCreateView(CreateView): - model = ForumTopic - fields = ['title'] + model = ForumMessage + fields = ['title', 'message'] template_name = "core/create.jinja" def dispatch(self, request, *args, **kwargs): @@ -49,13 +49,15 @@ class ForumTopicCreateView(CreateView): return super(ForumTopicCreateView, self).dispatch(request, *args, **kwargs) 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 return super(ForumTopicCreateView, self).form_valid(form) class ForumTopicEditView(UpdateView): model = ForumTopic - fields = ['title'] + fields = ['title', 'forum'] pk_url_kwarg = "topic_id" template_name = "core/edit.jinja"