diff options
| author | Bobby <[email protected]> | 2024-12-15 19:11:48 -0500 |
|---|---|---|
| committer | Bobby <[email protected]> | 2024-12-15 19:11:48 -0500 |
| commit | 8bb529d5eefec11360e7aacb287120d6427793bd (patch) | |
| tree | 356d0690288513eee99abedafd3cf0929a3f27a3 /internal | |
| parent | 12c92bf4d74f3717b1eafe1737e671a2b8bda02e (diff) | |
| download | thatcomputerscientist-8bb529d5eefec11360e7aacb287120d6427793bd.tar.xz thatcomputerscientist-8bb529d5eefec11360e7aacb287120d6427793bd.zip | |
user stats
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/weblog_utilities.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/internal/weblog_utilities.py b/internal/weblog_utilities.py index a6eede4b..db4fc5d5 100644 --- a/internal/weblog_utilities.py +++ b/internal/weblog_utilities.py @@ -1,6 +1,8 @@ from apps.blog.models import Post, Comment from bs4 import BeautifulSoup +AUTHOR_USERNAME = "bobby" + def add_excerpt(post, lang="en"): if lang == "ja": @@ -14,7 +16,6 @@ def add_excerpt(post, lang="en"): if len(excerpt) >= 1000: break - print(excerpt) return excerpt @@ -23,8 +24,10 @@ def add_num_comments(post): return num_comments -def recent_weblogs(lang="en"): - recent_posts = Post.objects.filter(is_public=True).order_by("-date")[:5] +def recent_weblogs(lang="en", amount=3): + recent_posts = Post.objects.filter( + is_public=True, author__username=AUTHOR_USERNAME + ).order_by("-date")[:amount] for post in recent_posts: post.excerpt = add_excerpt(post, lang) post.num_comments = add_num_comments(post) |
