mirror of
https://github.com/ajurna/cbwebreader.git
synced 2025-12-06 06:17:17 +00:00
added type annotation to feed.
change date strftime to something more human.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import uuid
|
||||
|
||||
from django.contrib.syndication.views import Feed
|
||||
from django.http import HttpRequest
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.utils.http import urlsafe_base64_decode, urlsafe_base64_encode
|
||||
|
||||
@@ -12,19 +13,19 @@ class RecentComics(Feed):
|
||||
link = "/comics/"
|
||||
description = "Recently added Comics"
|
||||
|
||||
def get_object(self, request, user_selector, *args, **kwargs):
|
||||
def get_object(self, request: HttpRequest, user_selector: str) -> UserMisc:
|
||||
user_selector = uuid.UUID(bytes=urlsafe_base64_decode(user_selector))
|
||||
return get_object_or_404(UserMisc, feed_id=user_selector)
|
||||
|
||||
def items(self):
|
||||
def items(self) -> ComicBook:
|
||||
return ComicBook.objects.order_by('-date_added')[:10]
|
||||
|
||||
def item_title(self, item: ComicBook):
|
||||
def item_title(self, item: ComicBook) -> str:
|
||||
return item.file_name
|
||||
|
||||
def item_description(self, item: ComicBook):
|
||||
return item.date_added.isoformat()
|
||||
def item_description(self, item: ComicBook) -> str:
|
||||
return item.date_added.strftime('%a, %e %b %Y %H:%M')
|
||||
|
||||
# item_link is only needed if NewsItem has no get_absolute_url method.
|
||||
def item_link(self, item: ComicBook):
|
||||
def item_link(self, item: ComicBook) -> str:
|
||||
return '/comic/read/{0}/0/'.format(urlsafe_base64_encode(item.selector.bytes).decode())
|
||||
|
||||
Reference in New Issue
Block a user