summaryrefslogtreecommitdiff
path: root/pgcommitfest/commitfest/feeds.py
blob: 969de699faad5b7772aa9bc8be36dd3643b05def (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from django.contrib.syndication.views import Feed


class ActivityFeed(Feed):
    title = description = 'Commitfest Activity Log'
    link = 'https://commitfest.postgresql.org/'

    def __init__(self, activity, cf, *args, **kwargs):
        super(ActivityFeed, self).__init__(*args, **kwargs)
        self.activity = activity
        if cf:
            self.cfid = cf.id
            self.title = self.description = 'PostgreSQL Commitfest {0} Activity Log'.format(cf.name)
        else:
            self.cfid = None

    def items(self):
        return self.activity

    def item_title(self, item):
        if self.cfid:
            return item['name']
        else:
            return '{cfname}: {name}'.format(**item)

    def item_description(self, item):
        if self.cfid:
            return "<div>Patch: {name}</div><div>User: {by}</div>\n<div>{what}</div>".format(**item)
        else:
            return "<div>Commitfest: {cfname}</div><div>Patch: {name}</div><div>User: {by}</div><div>{what}</div>".format(**item)

    def item_link(self, item):
        if self.cfid:
            return 'https://commitfest.postgresql.org/{cfid}/{patchid}/'.format(cfid=self.cfid, **item)
        else:
            return 'https://commitfest.postgresql.org/{cfid}/{patchid}/'.format(**item)

    def item_pubdate(self, item):
        return item['date']