-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: per-user RSS feed * fix formatting * Code cleanup * Fix formatting * Remove redundant code
- Loading branch information
1 parent
6bfca56
commit 7f41ee7
Showing
4 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from django.shortcuts import get_object_or_404 | ||
|
||
from posts.rss import NewPostsRss | ||
from posts.models.post import Post | ||
from users.models.user import User | ||
|
||
|
||
class UserPostsRss(NewPostsRss): | ||
def get_object(self, _, user_slug=None): | ||
return get_object_or_404(User, slug=user_slug) | ||
|
||
def link(self, user): | ||
return f"/user/{user.slug}/posts.rss" | ||
|
||
def title(self, user): | ||
return f"Вастрик.Клуб: Посты {user.slug}" | ||
|
||
def items(self, user): | ||
return Post.visible_objects()\ | ||
.filter(is_approved_by_moderator=True)\ | ||
.filter(author=user) \ | ||
.exclude(type=Post.TYPE_INTRO)\ | ||
.order_by("-published_at", "-created_at")[:self.limit] |