SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit a3231e6f authored by Jean-Sébastien Caux's avatar Jean-Sébastien Caux
Browse files

Work on presentation

parent 7a3aab91
No related branches found
No related tags found
No related merge requests found
......@@ -10,3 +10,10 @@ class ForumQuerySet(models.QuerySet):
def anchors(self):
"""Return only the Forums which do not have a parent."""
return self.filter(parent_object_id__isnull=True)
class PostQuerySet(models.QuerySet):
def motions_excluded(self):
"""Filter all Motions out of the Post queryset."""
return self.filter(motion__isnull=True)
......@@ -10,7 +10,7 @@ from django.core.urlresolvers import reverse
from django.db import models
from django.utils import timezone
from .managers import ForumQuerySet
from .managers import ForumQuerySet, PostQuerySet
class Forum(models.Model):
......@@ -198,6 +198,8 @@ class Post(models.Model):
'target="_blank">primer on python.org</a>')
)
objects = PostQuerySet.as_manager()
class Meta:
ordering = ['posted_on',]
......
......@@ -120,7 +120,7 @@
{% endif %}
</ul>
{% for motion in forum.motions.all %}
{% include 'forums/post_card.html' with forum=forum post=motion %}
{% include 'forums/post_card.html' with forum=forum post=motion.post_ptr %}
{% endfor %}
</div>
</div>
......@@ -133,7 +133,7 @@
<li><a href="{% url 'forums:post_create' slug=forum.slug parent_model='forum' parent_id=forum.id %}">Add a new Post</a></li>
</ul>
{% for post in forum.posts.all %}
{% for post in forum.posts.motions_excluded %}
{% include 'forums/post_card.html' with forum=forum post=post %}
{% endfor %}
......
{% load restructuredtext %}
<div class="card{% if post.motion %} text-white bg-dark{% endif %}" id="post{{ post.id }}">
<div class="card {% if post.motion %}text-white bg-dark{% else %}text-body{% endif %}" id="post{{ post.id }}">
<div class="card-header">
{{ post.subject }}
<div class="postInfo">
......@@ -20,7 +20,11 @@
{% if post.followup_posts.all|length > 0 %}
<span class="badge badge-primary badge-pill">{% with nr_followups=post.nr_followups %}{{ nr_followups }} repl{{ nr_followups|pluralize:"y,ies" }}{% endwith %}</span>
{% endif %}&nbsp;
{% if post.post_ptr %}
<a href="{% url 'forums:post_create' slug=forum.slug parent_model='post' parent_id=post.post_ptr.id %}">{% if post.motion %}Post a Comment on this Motion{% else %}Reply to the above post{% endif %}</a>
{% else %}
<a href="{% url 'forums:post_create' slug=forum.slug parent_model='post' parent_id=post.id %}">{% if post.motion %}Post a Comment on this Motion{% else %}Reply to the above post{% endif %}</a>
{% endif %}
</div>
{% if post.motion %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment