Reuse online accounts query on contact page

This commit is contained in:
Jake Howard 2022-08-20 12:19:54 +01:00
parent 94efdfb1cc
commit adc6002217
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -44,14 +44,18 @@ class ContactPage(BaseContentPage):
def show_reading_time(self) -> bool:
return False
@cached_property
def online_accounts(self) -> models.QuerySet:
return OnlineAccount.objects.all().order_by("name")
@cached_property
def table_of_contents(self) -> list[TocEntry]:
return [
TocEntry(account.name, account.slug, 0, [])
for account in OnlineAccount.objects.all().order_by("name")
for account in self.online_accounts
]
def get_context(self, request: HttpRequest) -> dict:
context = super().get_context(request)
context["accounts"] = OnlineAccount.objects.all().order_by("name")
context["accounts"] = self.online_accounts
return context