diff --git a/aurweb/config.py b/aurweb/config.py index 7bd7abd4..2a865b9b 100644 --- a/aurweb/config.py +++ b/aurweb/config.py @@ -6,7 +6,7 @@ from typing import Any # Publicly visible version of aurweb. This is used to display # aurweb versioning in the footer and must be maintained. # Todo: Make this dynamic/automated. -AURWEB_VERSION = "v6.0.11" +AURWEB_VERSION = "v6.0.13" _parser = None diff --git a/aurweb/models/package_comment.py b/aurweb/models/package_comment.py index 2a529c9c..7ab1f218 100644 --- a/aurweb/models/package_comment.py +++ b/aurweb/models/package_comment.py @@ -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 + ] + )) diff --git a/aurweb/pkgbase/util.py b/aurweb/pkgbase/util.py index fbfcd869..18af3df0 100644 --- a/aurweb/pkgbase/util.py +++ b/aurweb/pkgbase/util.py @@ -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( diff --git a/aurweb/routers/pkgbase.py b/aurweb/routers/pkgbase.py index cd35a7f8..845c6372 100644 --- a/aurweb/routers/pkgbase.py +++ b/aurweb/routers/pkgbase.py @@ -39,14 +39,17 @@ async def pkgbase(request: Request, name: str) -> Response: # Get the PackageBase. pkgbase = get_pkg_or_base(name, PackageBase) - # If this is not a split package, redirect to /packages/{name}. - if pkgbase.packages.count() == 1: - return RedirectResponse(f"/packages/{name}", + # Redirect to /packages if there's only one related Package + # and its name matches its PackageBase. + packages = pkgbase.packages.all() + pkg = packages[0] + if len(packages) == 1 and pkg.Name == pkgbase.Name: + return RedirectResponse(f"/packages/{pkg.Name}", status_code=int(HTTPStatus.SEE_OTHER)) # Add our base information. context = pkgbaseutil.make_context(request, pkgbase) - context["packages"] = pkgbase.packages.all() + context["packages"] = packages return render_template(request, "pkgbase/index.html", context) @@ -318,7 +321,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 +356,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( diff --git a/aurweb/scripts/rendercomment.py b/aurweb/scripts/rendercomment.py index 2af5384e..87f8b89f 100755 --- a/aurweb/scripts/rendercomment.py +++ b/aurweb/scripts/rendercomment.py @@ -2,6 +2,7 @@ import sys +from urllib.parse import quote_plus from xml.etree.ElementTree import Element import bleach @@ -72,13 +73,16 @@ class GitCommitsInlineProcessor(markdown.inlinepatterns.InlineProcessor): def handleMatch(self, m, data): oid = m.group(1) if oid not in self._repo: - # Unkwown OID; preserve the orginal text. + # Unknown OID; preserve the orginal text. return (None, None, None) el = Element('a') commit_uri = aurweb.config.get("options", "commit_uri") prefixlen = util.git_search(self._repo, oid) - el.set('href', commit_uri % (self._head, oid[:prefixlen])) + el.set('href', commit_uri % ( + quote_plus(self._head), + quote_plus(oid[:prefixlen]) + )) el.text = markdown.util.AtomicString(oid[:prefixlen]) return (el, m.start(0), m.end(0)) diff --git a/pyproject.toml b/pyproject.toml index 5afa6d6c..6ba0ff52 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ # [tool.poetry] name = "aurweb" -version = "v6.0.11" +version = "v6.0.13" license = "GPL-2.0-only" description = "Source code for the Arch User Repository's website" homepage = "https://aur.archlinux.org" diff --git a/templates/partials/comment_actions.html b/templates/partials/comment_actions.html index 78c4cc22..bf6103d7 100644 --- a/templates/partials/comment_actions.html +++ b/templates/partials/comment_actions.html @@ -47,13 +47,13 @@ {% endif %} - {% if request.user.has_credential(creds.COMMENT_PIN, approved=[comment.PackageBase.Maintainer]) %} + {% if request.user.has_credential(creds.COMMENT_PIN, approved=comment.maintainers()) %} {% if comment.PinnedTS %}