mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Merge branch 'master' into live
This commit is contained in:
commit
10c8433e62
10 changed files with 66 additions and 20 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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))
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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 %}
|
||||
<form class="pin-comment-form"
|
||||
method="post"
|
||||
action="/pkgbase/{{ comment.PackageBase.Name }}/comments/{{ comment.ID }}/unpin"
|
||||
>
|
||||
<fieldset style="display:inline;">
|
||||
<fieldset style="display: inline;">
|
||||
<input type="hidden" name="next" value="{{ request.url.path }}" />
|
||||
<input type="image"
|
||||
class="pin-comment"
|
||||
|
|
|
@ -6,21 +6,21 @@
|
|||
<h4>{{ "Package Actions" | tr }}</h4>
|
||||
<ul class="small">
|
||||
<li>
|
||||
<a href="/cgit/aur.git/tree/PKGBUILD?h={{ pkgbase.Name }}">
|
||||
<a href="{{ config.get('options', 'source_file_uri') | format("PKGBUILD", pkgbase.Name | quote_plus) }}">
|
||||
{{ "View PKGBUILD" | tr }}
|
||||
</a>
|
||||
/
|
||||
<a href="/cgit/aur.git/log/?h={{ pkgbase.Name }}">
|
||||
<a href="{{ config.get('options', 'log_uri') | format(pkgbase.Name | quote_plus) }}">
|
||||
{{ "View Changes" | tr }}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/cgit/aur.git/snapshot/{{ pkgbase.Name }}.tar.gz">
|
||||
<a href="{{ config.get('options', 'snapshot_uri') | format(pkgbase.Name | quote_plus) }}">
|
||||
{{ "Download snapshot" | tr }}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://wiki.archlinux.org/title/Special:Search?search={{ pkgbase.Name }}">
|
||||
<a href="https://wiki.archlinux.org/title/Special:Search?{{ { 'search': pkgbase.Name } | urlencode }}">
|
||||
{{ "Search wiki" | tr }}
|
||||
</a>
|
||||
</li>
|
||||
|
|
|
@ -114,7 +114,7 @@
|
|||
</a>
|
||||
{% set len = comaintainers | length %}
|
||||
{% if comaintainers %}
|
||||
({% for co in comaintainers %}<a href="{{ co.User | account_url }}">{{ co.User }}</a>{% if loop.index < len %}, {% endif %}{% endfor %})
|
||||
({% for co in comaintainers %}<a href="{{ co | account_url }}">{{ co }}</a>{% if loop.index < len %}, {% endif %}{% endfor %})
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{{ pkgbase.Maintainer.Username | default("None" | tr) }}
|
||||
|
|
|
@ -534,6 +534,35 @@ def test_pkgbase_comment_undelete_not_found(client: TestClient,
|
|||
assert resp.status_code == int(HTTPStatus.NOT_FOUND)
|
||||
|
||||
|
||||
def test_pkgbase_comment_pin_as_co(client: TestClient, package: Package,
|
||||
comment: PackageComment):
|
||||
comaint = create_user("comaint1")
|
||||
|
||||
with db.begin():
|
||||
db.create(PackageComaintainer, PackageBase=package.PackageBase,
|
||||
User=comaint, Priority=1)
|
||||
|
||||
# Pin the comment.
|
||||
pkgbasename = package.PackageBase.Name
|
||||
endpoint = f"/pkgbase/{pkgbasename}/comments/{comment.ID}/pin"
|
||||
cookies = {"AURSID": comaint.login(Request(), "testPassword")}
|
||||
with client as request:
|
||||
resp = request.post(endpoint, cookies=cookies)
|
||||
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
|
||||
|
||||
# Assert that PinnedTS got set.
|
||||
assert comment.PinnedTS > 0
|
||||
|
||||
# Unpin the comment we just pinned.
|
||||
endpoint = f"/pkgbase/{pkgbasename}/comments/{comment.ID}/unpin"
|
||||
with client as request:
|
||||
resp = request.post(endpoint, cookies=cookies)
|
||||
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
|
||||
|
||||
# Let's assert that PinnedTS was unset.
|
||||
assert comment.PinnedTS == 0
|
||||
|
||||
|
||||
def test_pkgbase_comment_pin(client: TestClient,
|
||||
maintainer: User,
|
||||
package: Package,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue