Skip to content

Commit

Permalink
fix: update naive datetime, remove staticmethod
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobCoffee committed Sep 16, 2024
1 parent eca7c50 commit ac115f1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions downloads/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,15 @@ def item_link(self, item: Release) -> str:
"""Return the URL to the release page on python.org."""
return reverse("downloads:download_release_detail", args=[item.slug])

def item_pubdate(self, item: Release) -> datetime:
def item_pubdate(self, item: Release) -> datetime | None:
"""Return the release date as the item publication date."""
return timezone.make_aware(item.release_date) if item.release_date else None
if item.release_date:
if timezone.is_naive(item.release_date):
return timezone.make_aware(item.release_date)
return item.release_date
return None

@staticmethod
def item_guid(item: Release) -> str:
def item_guid(self, item: Release) -> str:
"""Return a unique ID for the item based on DB record."""
return str(item.pk)

Expand Down

0 comments on commit ac115f1

Please sign in to comment.