Verified Commit 4eca3a8b authored by Leonidas Spyropoulos's avatar Leonidas Spyropoulos
Browse files

fix: hide Unflag package from non-maintainers

Add jinja2.ext.do extention to allow jinja statements to not print
'None'
https://jinja.palletsprojects.com/en/3.0.x/templates/#expression-statement

Closes: #364

Signed-off-by: Leonidas Spyropoulos's avatarLeonidas Spyropoulos <artafinde@archlinux.org>
parent 4ddd1dec
Pipeline #19026 passed with stages
in 3 minutes and 2 seconds
......@@ -38,8 +38,8 @@ def pkgbase_unnotify_instance(request: Request, pkgbase: PackageBase) -> None:
def pkgbase_unflag_instance(request: Request, pkgbase: PackageBase) -> None:
has_cred = request.user.has_credential(
creds.PKGBASE_UNFLAG, approved=[pkgbase.Flagger, pkgbase.Maintainer])
has_cred = request.user.has_credential(creds.PKGBASE_UNFLAG, approved=[
pkgbase.Flagger, pkgbase.Maintainer] + [c.User for c in pkgbase.comaintainers])
if has_cred:
with db.begin():
pkgbase.OutOfDateTS = None
......
......@@ -18,7 +18,7 @@ from aurweb import cookies, l10n, time
_loader = jinja2.FileSystemLoader(os.path.join(
aurweb.config.get("options", "aurwebdir"), "templates"))
_env = jinja2.Environment(loader=_loader, autoescape=True,
extensions=["jinja2.ext.i18n"])
extensions=["jinja2.ext.i18n", "jinja2.ext.do"])
def register_filter(name: str) -> Callable:
......
......@@ -41,6 +41,14 @@
</a>
</span>
</li>
{% set unflaggers = [] %}
{% do unflaggers.append(pkgbase.Maintainer) %}
{% if comaintainers %}
{% for co in comaintainers %}
{% do unflaggers.append(co) %}
{% endfor %}
{% endif %}
{% if request.user.has_credential(creds.PKGBASE_UNFLAG, approved=unflaggers) %}
<li>
<form action="/pkgbase/{{ pkgbase.Name }}/unflag" method="post">
<input class="button text-button"
......@@ -50,6 +58,7 @@
/>
</form>
</li>
{% endif %}
{% endif %}
<li>
{% if not voted %}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment