~widelands-dev/widelands-website/django_staticfiles

« back to all changes in this revision

Viewing changes to news/feeds.py

  • Committer: franku
  • Date: 2016-07-02 12:38:06 UTC
  • mfrom: (404.2.56 widelands)
  • Revision ID: somal@arcor.de-20160702123806-q69u3d48s1prrxds
merged the django1_8 branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from django.contrib.syndication.feeds import FeedDoesNotExist
 
1
from django.contrib.syndication.views import Feed, FeedDoesNotExist
2
2
from django.core.exceptions import ObjectDoesNotExist
3
 
from django.contrib.sites.models import Site
4
 
from django.contrib.syndication.feeds import Feed
5
3
from django.core.urlresolvers import reverse
6
 
from widelands.news.models import Post, Category
7
 
 
8
 
 
 
4
from news.models import Post, Category
 
5
 
 
6
# Validated through http://validator.w3.org/feed/
9
7
class NewsPostsFeed(Feed):
10
 
    title = 'Widelands news posts feed'
 
8
    # RSS Feed
 
9
    title = 'Widelands news feed'
11
10
    description = 'The news section from the widelands.org homepage'
12
 
    title_template = 'feeds/posts_title.html'
13
 
    description_template = 'feeds/posts_description.html'
 
11
    title_template = 'news/feeds/posts_title.html'
 
12
    description_template = 'news/feeds/posts_description.html'
 
13
 
 
14
    def items(self):
 
15
        return Post.objects.published()[:10]
14
16
 
15
17
    def link(self):
16
18
        return reverse('news_index')
17
19
 
18
 
    def items(self):
19
 
        return Post.objects.published()[:10]
20
 
 
21
 
    def item_pubdate(self, obj):
22
 
        return obj.publish
23
 
 
24
 
 
 
20
    def item_pubdate(self, item):
 
21
        return item.publish
 
22
 
 
23
# Currently not used / not checked for compatibility for django 1.8
25
24
class NewsPostsByCategory(Feed):
26
25
    title = 'Widelands.org posts category feed'
27
26
 
30
29
            raise ObjectDoesNotExist
31
30
        return Category.objects.get(slug__exact=bits[0])
32
31
 
33
 
    def link(self, obj):
34
 
        if not obj:
 
32
    def link(self, item):
 
33
        if not item:
35
34
            raise FeedDoesNotExist
36
 
        return obj.get_absolute_url()
37
 
 
38
 
    def description(self, obj):
39
 
        return "Posts recently categorized as %s" % obj.title
40
 
 
41
 
    def items(self, obj):
42
 
        return obj.post_set.published()[:10]
 
35
        return item.get_absolute_url()
 
36
 
 
37
    def description(self, item):
 
38
        return "Posts recently categorized as %s" % item.title
 
39
 
 
40
    def items(self, item):
 
41
        return item.post_set.published()[:10]