Skip to content

Commit

Permalink
move DatePage properties to actual cached_property on class (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuadavidthomas authored Jan 26, 2024
1 parent 4510b26 commit 9b500a9
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/django_twc_toolbox/paginator.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,15 @@ def __init__(
super().__init__(object_list, number, paginator)
self.start_date = start_date
self.end_date = end_date
self.min_date = min([start_date, end_date])
self.max_date = max([start_date, end_date])
self.date_range = (self.min_date, self.max_date)

@cached_property
def min_date(self) -> datetime.datetime:
return min([self.start_date, self.end_date])

@cached_property
def max_date(self) -> datetime.datetime:
return max([self.start_date, self.end_date])

@cached_property
def date_range(self) -> tuple[datetime.datetime, datetime.datetime]:
return (self.min_date, self.max_date)

0 comments on commit 9b500a9

Please sign in to comment.