mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-25 11:01:12 +00:00
Better typing for get_published_date() and get_isni_bio()
This commit is contained in:
parent
e2d8ae7157
commit
4852f7ff1e
2 changed files with 3 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
|||
""" template filters """
|
||||
import datetime
|
||||
from typing import Any, Optional
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from django import template
|
||||
|
@ -55,7 +56,7 @@ def get_boosted(boost: models.Boost) -> Any:
|
|||
|
||||
|
||||
@register.filter(name="published_date")
|
||||
def get_published_date(date: str) -> Any:
|
||||
def get_published_date(date: datetime.datetime) -> str | None:
|
||||
"""less verbose combo of humanize filters"""
|
||||
if not date:
|
||||
return ""
|
||||
|
|
|
@ -93,7 +93,7 @@ def get_book_cover_thumbnail(
|
|||
|
||||
|
||||
@register.filter(name="get_isni_bio")
|
||||
def get_isni_bio(existing: int, author: Author) -> str:
|
||||
def get_isni_bio(existing: list[str], author: Author) -> str:
|
||||
"""Returns the isni bio string if an existing author has an isni listed"""
|
||||
auth_isni = re.sub(r"\D", "", str(author.isni))
|
||||
if len(existing) == 0:
|
||||
|
|
Loading…
Reference in a new issue