Merge branch 'main' into book-series-v1
This commit is contained in:
commit
1d909ee8e1
13 changed files with 335 additions and 9 deletions
|
@ -138,7 +138,12 @@ from .outbox import Outbox
|
|||
from .reading import ReadThrough, delete_readthrough, delete_progressupdate
|
||||
from .reading import ReadingStatus
|
||||
from .report import Report
|
||||
from .rss_feed import RssFeed
|
||||
from .rss_feed import (
|
||||
RssFeed,
|
||||
RssReviewsOnlyFeed,
|
||||
RssQuotesOnlyFeed,
|
||||
RssCommentsOnlyFeed,
|
||||
)
|
||||
from .search import Search
|
||||
from .setup import InstanceConfig, CreateAdmin
|
||||
from .status import CreateStatus, EditStatus, DeleteStatus, update_progress
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
from django.contrib.syndication.views import Feed
|
||||
from django.template.loader import get_template
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from ..models import Review, Quotation, Comment
|
||||
|
||||
from .helpers import get_user_from_username
|
||||
|
||||
|
@ -42,3 +43,117 @@ class RssFeed(Feed):
|
|||
def item_link(self, item):
|
||||
"""link to the status"""
|
||||
return item.local_path
|
||||
|
||||
|
||||
class RssReviewsOnlyFeed(Feed):
|
||||
"""serialize user's reviews in rss feed"""
|
||||
|
||||
description_template = "rss/content.html"
|
||||
|
||||
def item_title(self, item):
|
||||
"""render the item title"""
|
||||
if hasattr(item, "pure_name") and item.pure_name:
|
||||
return item.pure_name
|
||||
title_template = get_template("snippets/status/header_content.html")
|
||||
title = title_template.render({"status": item})
|
||||
template = get_template("rss/title.html")
|
||||
return template.render({"user": item.user, "item_title": title}).strip()
|
||||
|
||||
def get_object(self, request, username): # pylint: disable=arguments-differ
|
||||
"""the user who's posts get serialized"""
|
||||
return get_user_from_username(request.user, username)
|
||||
|
||||
def link(self, obj):
|
||||
"""link to the user's profile"""
|
||||
return obj.local_path
|
||||
|
||||
def title(self, obj):
|
||||
"""title of the rss feed entry"""
|
||||
return _(f"Reviews from {obj.display_name}")
|
||||
|
||||
def items(self, obj):
|
||||
"""the user's activity feed"""
|
||||
return Review.objects.filter(
|
||||
user=obj,
|
||||
privacy__in=["public", "unlisted"],
|
||||
)[:10]
|
||||
|
||||
def item_link(self, item):
|
||||
"""link to the status"""
|
||||
return item.local_path
|
||||
|
||||
|
||||
class RssQuotesOnlyFeed(Feed):
|
||||
"""serialize user's quotes in rss feed"""
|
||||
|
||||
description_template = "rss/content.html"
|
||||
|
||||
def item_title(self, item):
|
||||
"""render the item title"""
|
||||
if hasattr(item, "pure_name") and item.pure_name:
|
||||
return item.pure_name
|
||||
title_template = get_template("snippets/status/header_content.html")
|
||||
title = title_template.render({"status": item})
|
||||
template = get_template("rss/title.html")
|
||||
return template.render({"user": item.user, "item_title": title}).strip()
|
||||
|
||||
def get_object(self, request, username): # pylint: disable=arguments-differ
|
||||
"""the user who's posts get serialized"""
|
||||
return get_user_from_username(request.user, username)
|
||||
|
||||
def link(self, obj):
|
||||
"""link to the user's profile"""
|
||||
return obj.local_path
|
||||
|
||||
def title(self, obj):
|
||||
"""title of the rss feed entry"""
|
||||
return _(f"Quotes from {obj.display_name}")
|
||||
|
||||
def items(self, obj):
|
||||
"""the user's activity feed"""
|
||||
return Quotation.objects.filter(
|
||||
user=obj,
|
||||
privacy__in=["public", "unlisted"],
|
||||
)[:10]
|
||||
|
||||
def item_link(self, item):
|
||||
"""link to the status"""
|
||||
return item.local_path
|
||||
|
||||
|
||||
class RssCommentsOnlyFeed(Feed):
|
||||
"""serialize user's quotes in rss feed"""
|
||||
|
||||
description_template = "rss/content.html"
|
||||
|
||||
def item_title(self, item):
|
||||
"""render the item title"""
|
||||
if hasattr(item, "pure_name") and item.pure_name:
|
||||
return item.pure_name
|
||||
title_template = get_template("snippets/status/header_content.html")
|
||||
title = title_template.render({"status": item})
|
||||
template = get_template("rss/title.html")
|
||||
return template.render({"user": item.user, "item_title": title}).strip()
|
||||
|
||||
def get_object(self, request, username): # pylint: disable=arguments-differ
|
||||
"""the user who's posts get serialized"""
|
||||
return get_user_from_username(request.user, username)
|
||||
|
||||
def link(self, obj):
|
||||
"""link to the user's profile"""
|
||||
return obj.local_path
|
||||
|
||||
def title(self, obj):
|
||||
"""title of the rss feed entry"""
|
||||
return _(f"Comments from {obj.display_name}")
|
||||
|
||||
def items(self, obj):
|
||||
"""the user's activity feed"""
|
||||
return Comment.objects.filter(
|
||||
user=obj,
|
||||
privacy__in=["public", "unlisted"],
|
||||
)[:10]
|
||||
|
||||
def item_link(self, item):
|
||||
"""link to the status"""
|
||||
return item.local_path
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue