mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-29 04:51:11 +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 """
|
""" template filters """
|
||||||
|
import datetime
|
||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
from django import template
|
from django import template
|
||||||
|
@ -55,7 +56,7 @@ def get_boosted(boost: models.Boost) -> Any:
|
||||||
|
|
||||||
|
|
||||||
@register.filter(name="published_date")
|
@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"""
|
"""less verbose combo of humanize filters"""
|
||||||
if not date:
|
if not date:
|
||||||
return ""
|
return ""
|
||||||
|
|
|
@ -93,7 +93,7 @@ def get_book_cover_thumbnail(
|
||||||
|
|
||||||
|
|
||||||
@register.filter(name="get_isni_bio")
|
@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"""
|
"""Returns the isni bio string if an existing author has an isni listed"""
|
||||||
auth_isni = re.sub(r"\D", "", str(author.isni))
|
auth_isni = re.sub(r"\D", "", str(author.isni))
|
||||||
if len(existing) == 0:
|
if len(existing) == 0:
|
||||||
|
|
Loading…
Reference in a new issue