14
14
ITEMS_PER_FEED = getattr(settings, 'ITEMS_PER_FEED', 20)
16
17
class BaseNoticeFeed(Feed):
17
19
def item_id(self, notification):
18
return "http://%s%s" % (
20
return 'http://%s%s' % (
19
21
Site.objects.get_current().domain,
20
22
notification.get_absolute_url(),
23
25
def item_title(self, notification):
24
26
return striptags(notification.message)
26
28
def item_updated(self, notification):
27
29
return notification.added
29
31
def item_published(self, notification):
30
32
return notification.added
32
34
def item_content(self, notification):
33
return {"type" : "html", }, linebreaks(escape(notification.message))
35
return {'type': 'html', }, linebreaks(escape(notification.message))
35
37
def item_links(self, notification):
36
return [{"href" : self.item_id(notification)}]
38
return [{'href': self.item_id(notification)}]
38
40
def item_authors(self, notification):
39
return [{"name" : notification.user.username}]
41
return [{'name': notification.user.username}]
41
44
class NoticeUserFeed(BaseNoticeFeed):
42
46
def get_object(self, params):
43
47
return get_object_or_404(User, username=params[0].lower())
45
49
def feed_id(self, user):
46
return "http://%s%s" % (
47
Site.objects.get_current().domain,
48
reverse('notification_feed_for_user'),
50
return 'http://%s%s' % (
51
Site.objects.get_current().domain,
52
reverse('notification_feed_for_user'),
51
55
def feed_title(self, user):
52
56
return _('Notices Feed')
61
65
return qs.latest('added').added
63
67
def feed_links(self, user):
64
complete_url = "http://%s%s" % (
65
Site.objects.get_current().domain,
66
reverse('notification_notices'),
68
complete_url = 'http://%s%s' % (
69
Site.objects.get_current().domain,
70
reverse('notification_notices'),
68
72
return ({'href': complete_url},)
70
74
def items(self, user):
71
return Notice.objects.notices_for(user).order_by("-added")[:ITEMS_PER_FEED]
75
return Notice.objects.notices_for(user).order_by('-added')[:ITEMS_PER_FEED]