~widelands-dev/widelands-website/django_staticfiles

« back to all changes in this revision

Viewing changes to wiki/feeds.py

  • Committer: franku
  • Author(s): GunChleoc
  • Date: 2016-12-13 18:30:38 UTC
  • mfrom: (438.1.6 pyformat_util)
  • Revision ID: somal@arcor.de-20161213183038-5cgmvfh2fkgmoc1s
adding a script to run pyformat over the code base

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
from django.utils.feedgenerator import Atom1Feed, Rss201rev2Feed
4
4
 
5
5
# Validated through http://validator.w3.org/feed/
 
6
 
 
7
 
6
8
class RssHistoryFeed(Feed):
7
9
 
8
10
    feed_type = Rss201rev2Feed
11
13
    link = '/wiki/feeds/rss/'
12
14
    title_template = 'wiki/feeds/history_title.html'
13
15
    description_template = 'wiki/feeds/history_description.html'
14
 
    
 
16
 
15
17
    def items(self):
16
18
        return ChangeSet.objects.order_by('-modified')[:30]
17
19
 
18
20
    def item_pubdate(self, item):
19
 
        """
20
 
        Return the item's pubdate. It's this modified date
 
21
        """Return the item's pubdate.
 
22
 
 
23
        It's this modified date
 
24
 
21
25
        """
22
26
        return item.modified
23
27
 
24
28
    def item_author_name(self, item):
25
 
        """
26
 
        Takes the object returned by items(), and returns the feeds's
27
 
        auhor's name as a Python string
28
 
        """
 
29
        """Takes the object returned by items(), and returns the feeds's
 
30
        auhor's name as a Python string."""
29
31
        if item.is_anonymous_change():
30
32
            return 'Anonymous'
31
33
        return item.editor.username
32
 
    
 
34
 
33
35
# Validated through http://validator.w3.org/feed/
 
36
 
 
37
 
34
38
class AtomHistoryFeed(RssHistoryFeed):
35
39
 
36
40
    feed_type = Atom1Feed
39
43
 
40
44
    def item_updateddate(self, item):
41
45
        return item.modified
42
 
    
 
46
 
43
47
# Validated through http://validator.w3.org/feed/
 
48
 
 
49
 
44
50
class RssArticleHistoryFeed(Feed):
45
51
    feed_type = Rss201rev2Feed
46
52
    title_template = u'wiki/feeds/history_title.html'
50
56
        return Article.objects.get(title=kwargs['title'])
51
57
 
52
58
    def title(self, item):
53
 
        return "History for: %s " % item.title
 
59
        return 'History for: %s ' % item.title
54
60
 
55
61
    def link(self, item):
56
62
        if not item:
58
64
        return item.get_absolute_url()
59
65
 
60
66
    def description(self, item):
61
 
        return "Recent changes in %s" % item.title
 
67
        return 'Recent changes in %s' % item.title
62
68
 
63
69
    def items(self, item):
64
70
        return ChangeSet.objects.filter(article__id__exact=item.id).order_by('-modified')[:30]
65
71
 
66
72
    def item_pubdate(self, item):
67
 
        """
68
 
        Returns the modified date
69
 
        """
 
73
        """Returns the modified date."""
70
74
        return item.modified
71
 
    
 
75
 
72
76
# Validated through http://validator.w3.org/feed/
 
77
 
 
78
 
73
79
class AtomArticleHistoryFeed(RssArticleHistoryFeed):
74
80
    feed_type = Atom1Feed
75
81
 
76
82
    def subtitle(self, item):
77
 
        return "Recent changes in %s" % item.title
 
83
        return 'Recent changes in %s' % item.title
78
84
 
79
85
    def item_updateddate(self, item):
80
86
        return item.modified
81
87
 
82
88
    def item_author_name(self, item):
83
 
        """
84
 
        Takes the object returned by items(), and returns the feeds's
85
 
        auhor's name as a Python string
86
 
        """
 
89
        """Takes the object returned by items(), and returns the feeds's
 
90
        auhor's name as a Python string."""
87
91
        if item.is_anonymous_change():
88
92
            return 'Anonymous'
89
 
        return item.editor.username
 
 
b'\\ No newline at end of file'
 
93
        return item.editor.username