mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
fix: allow co-maintainers to [un]pin comments on a package
Closes #279 Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
35e7486ea3
commit
708ade4dbf
6 changed files with 47 additions and 8 deletions
|
@ -52,3 +52,11 @@ class PackageComment(Base):
|
|||
|
||||
if self.RenderedComment is None:
|
||||
self.RenderedComment = str()
|
||||
|
||||
def maintainers(self):
|
||||
return list(filter(
|
||||
lambda e: e is not None,
|
||||
[self.PackageBase.Maintainer] + [
|
||||
c.User for c in self.PackageBase.comaintainers
|
||||
]
|
||||
))
|
||||
|
|
|
@ -25,9 +25,11 @@ def make_context(request: Request, pkgbase: PackageBase) -> Dict[str, Any]:
|
|||
context["git_clone_uri_anon"] = config.get("options", "git_clone_uri_anon")
|
||||
context["git_clone_uri_priv"] = config.get("options", "git_clone_uri_priv")
|
||||
context["pkgbase"] = pkgbase
|
||||
context["comaintainers"] = pkgbase.comaintainers.order_by(
|
||||
PackageComaintainer.Priority.asc()
|
||||
).all()
|
||||
context["comaintainers"] = [
|
||||
c.User for c in pkgbase.comaintainers.order_by(
|
||||
PackageComaintainer.Priority.asc()
|
||||
).all()
|
||||
]
|
||||
context["packages_count"] = pkgbase.packages.count()
|
||||
context["keywords"] = pkgbase.keywords
|
||||
context["comments"] = pkgbase.comments.order_by(
|
||||
|
|
|
@ -318,7 +318,7 @@ async def pkgbase_comment_pin(request: Request, name: str, id: int,
|
|||
comment = get_pkgbase_comment(pkgbase, id)
|
||||
|
||||
has_cred = request.user.has_credential(creds.COMMENT_PIN,
|
||||
approved=[pkgbase.Maintainer])
|
||||
approved=comment.maintainers())
|
||||
if not has_cred:
|
||||
_ = l10n.get_translator_for_request(request)
|
||||
raise HTTPException(
|
||||
|
@ -353,7 +353,7 @@ async def pkgbase_comment_unpin(request: Request, name: str, id: int,
|
|||
comment = get_pkgbase_comment(pkgbase, id)
|
||||
|
||||
has_cred = request.user.has_credential(creds.COMMENT_PIN,
|
||||
approved=[pkgbase.Maintainer])
|
||||
approved=comment.maintainers())
|
||||
if not has_cred:
|
||||
_ = l10n.get_translator_for_request(request)
|
||||
raise HTTPException(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue