2021-03-08 08:49:10 -08:00
|
|
|
""" serialize user's posts in rss feed """
|
2021-01-20 17:15:15 -05:00
|
|
|
|
|
|
|
from django.contrib.syndication.views import Feed
|
2021-03-22 19:17:46 -07:00
|
|
|
from .helpers import get_user_from_username, privacy_filter
|
2021-01-20 17:15:15 -05:00
|
|
|
|
2021-01-29 09:28:00 -08:00
|
|
|
# pylint: disable=no-self-use, unused-argument
|
2021-01-20 17:15:15 -05:00
|
|
|
class RssFeed(Feed):
|
2021-04-26 09:15:42 -07:00
|
|
|
"""serialize user's posts in rss feed"""
|
2021-03-08 08:49:10 -08:00
|
|
|
|
2021-05-20 16:12:24 -07:00
|
|
|
description_template = "rss/content.html"
|
|
|
|
title_template = "rss/title.html"
|
2021-01-20 17:15:15 -05:00
|
|
|
|
2021-06-18 14:12:56 -07:00
|
|
|
def get_object(self, request, username): # pylint: disable=arguments-differ
|
2021-04-26 09:15:42 -07:00
|
|
|
"""the user who's posts get serialized"""
|
2021-02-23 13:12:50 -08:00
|
|
|
return get_user_from_username(request.user, username)
|
2021-01-20 17:15:15 -05:00
|
|
|
|
|
|
|
def link(self, obj):
|
2021-04-26 09:15:42 -07:00
|
|
|
"""link to the user's profile"""
|
2021-01-20 17:15:15 -05:00
|
|
|
return obj.local_path
|
|
|
|
|
|
|
|
def title(self, obj):
|
2021-04-26 09:15:42 -07:00
|
|
|
"""title of the rss feed entry"""
|
2021-03-08 08:49:10 -08:00
|
|
|
return f"Status updates from {obj.display_name}"
|
2021-01-20 17:15:15 -05:00
|
|
|
|
|
|
|
def items(self, obj):
|
2021-04-26 09:15:42 -07:00
|
|
|
"""the user's activity feed"""
|
2021-03-22 19:17:46 -07:00
|
|
|
return privacy_filter(
|
2021-02-24 12:35:43 -08:00
|
|
|
obj,
|
2021-03-22 19:17:46 -07:00
|
|
|
obj.status_set.select_subclasses(),
|
|
|
|
privacy_levels=["public", "unlisted"],
|
2021-02-24 12:35:43 -08:00
|
|
|
)
|
2021-01-29 09:28:00 -08:00
|
|
|
|
2021-01-20 17:15:15 -05:00
|
|
|
def item_link(self, item):
|
2021-04-26 09:15:42 -07:00
|
|
|
"""link to the status"""
|
2021-01-20 17:15:15 -05:00
|
|
|
return item.local_path
|