Skip to content

Commit

Permalink
Refactor is_unavailable functions
Browse files Browse the repository at this point in the history
Refs. TS-2276
  • Loading branch information
Roffenlund committed Feb 14, 2025
1 parent 84e320b commit 8eb9d31
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
7 changes: 2 additions & 5 deletions django/thunderstore/repository/models/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,11 @@ def update_listing(self, has_nsfw_content, categories, community):
listing.save(update_fields=("has_nsfw_content",))

def is_unavailable(self, community) -> bool:
if self.is_effectively_active is False:
if not self.is_effectively_active:
return True

listing = self.get_package_listing(community)
if listing is None:
return True

return listing.is_unavailable
return listing is None or listing.is_unavailable

@cached_property
def has_wiki(self) -> bool:
Expand Down
5 changes: 1 addition & 4 deletions django/thunderstore/repository/models/package_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,7 @@ def get_page_url(self, community_identifier: str) -> str:
)

def is_unavailable(self, community) -> bool:
unavailable = self.package.is_unavailable(community)
if unavailable:
return True
return self.is_active is False
return self.package.is_unavailable(community) or not self.is_active

@cached_property
def is_removed(self):
Expand Down

0 comments on commit 8eb9d31

Please sign in to comment.