Add tests for org list view queryset fields

This commit is contained in:
Joakim Hellsén 2026-04-12 05:14:40 +02:00
commit 3c18b26e9c
Signed by: Joakim Hellsén
SSH key fingerprint: SHA256:/9h/CsExpFp+PRhsfA0xznFx2CGfTT5R/kpuFfUgEQk
3 changed files with 53 additions and 5 deletions

View file

@ -70,6 +70,11 @@ class Organization(auto_prefetch.Model):
"""Return a string representation of the organization."""
return self.name or self.twitch_id
@classmethod
def for_list_view(cls) -> models.QuerySet[Organization]:
"""Return organizations with only fields needed by the org list page."""
return cls.objects.only("twitch_id", "name").order_by("name")
def feed_description(self: Organization) -> str:
"""Return a description of the organization for RSS feeds."""
name: str = self.name or "Unknown Organization"