# HG changeset patch # User neko259 # Date 2013-04-06 10:34:14 # Node ID 263648230b70979e1aea456215aba76f97fee809 # Parent 67f0542df0a8244ebe1d680fa385d32a8d0aa87c Truncating thread text in threads list. Fixed tag threads order. diff --git a/boards/models.py b/boards/models.py --- a/boards/models.py +++ b/boards/models.py @@ -45,10 +45,10 @@ class PostManager(models.Manager): self.delete_post(post) def get_threads(self, tag=None): - if tag is None: + if tag: + threads = self.filter(parent=NO_PARENT, tags=tag) + else: threads = self.filter(parent=NO_PARENT) - else: - threads = self.filter(parent=NO_PARENT, tag=tag) threads = list(threads.order_by('-last_edit_time')) return threads diff --git a/boards/views.py b/boards/views.py --- a/boards/views.py +++ b/boards/views.py @@ -65,7 +65,7 @@ def tag(request, tag_name): """Get all tag threads (posts without a parent).""" tag = Tag.objects.get(name=tag_name) - threads = get_list_or_404(Post, tags=tag) + threads = Post.objects.get_threads(tag=tag) if request.method == 'POST': return new_post(request) diff --git a/templates/posting_general.html b/templates/posting_general.html --- a/templates/posting_general.html +++ b/templates/posting_general.html @@ -19,7 +19,7 @@ [{{ thread.pub_time }}] [{% trans "View" %}]
- {{ thread.text }}
+ {{ thread.text|truncatechars:300 }}
{% if thread.tags %} {% trans 'Tags' %}: {% for tag in thread.tags.all %}