Skip to content

Commit

Permalink
Merge pull request #975 from thunderstore-io/package-manage-perm
Browse files Browse the repository at this point in the history
Show management panel to community moderators
  • Loading branch information
MythicManiac authored Dec 22, 2023
2 parents c5a9281 + ddf748e commit 6e1ddfc
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions django/thunderstore/repository/views/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,23 +482,35 @@ def get_object(self, *args, **kwargs) -> PackageListing:

@property
def can_manage(self):
return any(
(
self.can_manage_deprecation,
self.can_manage_categories,
self.can_unlist,
)
)

@cached_property
def can_manage_deprecation(self):
return self.object.package.can_user_manage_deprecation(self.request.user)

@property
def can_manage_categories(self) -> bool:
return self.can_manage and check_validity(
return check_validity(
lambda: self.object.ensure_update_categories_permission(self.request.user)
)

@property
@cached_property
def can_deprecate(self):
return self.can_manage and self.object.package.is_deprecated is False
return (
self.can_manage_deprecation and self.object.package.is_deprecated is False
)

@property
@cached_property
def can_undeprecate(self):
return self.can_manage and self.object.package.is_deprecated is True
return self.can_manage_deprecation and self.object.package.is_deprecated is True

@property
@cached_property
def can_unlist(self):
return self.request.user.is_superuser

Expand Down

0 comments on commit 6e1ddfc

Please sign in to comment.