~widelands-dev/widelands-website/django_staticfiles

« back to all changes in this revision

Viewing changes to pybb/feeds.py

  • Committer: franku
  • Date: 2018-05-09 06:02:44 UTC
  • mto: This revision was merged to the branch mainline in revision 496.
  • Revision ID: somal@arcor.de-20180509060244-8r2c7h1a81b4plod
added __init__.py's

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
from django.core.exceptions import ObjectDoesNotExist
4
4
from django.utils.feedgenerator import Atom1Feed
5
5
from pybb.models import Post, Topic, Forum
6
 
from django.conf import settings
7
6
 
8
7
 
9
8
class PybbFeed(Feed):
56
55
    title_template = 'pybb/feeds/posts_title.html'
57
56
    description_template = 'pybb/feeds/posts_description.html'
58
57
 
59
 
    all_objects = Post.objects.exclude(topic__in=Post.hidden_topics.all()).filter(hidden=False)
 
58
    all_objects = Post.objects.filter(hidden=False)
60
59
 
61
60
    def items_for_object(self, obj):
62
 
        return Post.objects.exclude(topic__in=Post.hidden_topics.all()).filter(hidden=False, topic__forum=obj).order_by('-created')[:15]
 
61
        return Post.objects.filter(hidden=False, topic__forum=obj).order_by('-created')[:15]
 
62
 
 
63
    def item_author_name(self, item):
 
64
        """Takes the object returned by get_object and returns the feeds's
 
65
        auhor's name as a Python string."""
 
66
        return item.user.username
63
67
 
64
68
# Validated through http://validator.w3.org/feed/
65
69
 
74
78
 
75
79
    def items_for_object(self, item):
76
80
        return Topic.objects.exclude(posts__hidden=True).filter(forum=item).order_by('-created')[:15]
 
81
 
 
82
    def item_author_name(self, item):
 
83
        """Takes the object returned by get_object and returns the feeds's
 
84
        auhor's name as a Python string."""
 
85
        return item.user.username