mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
fix(templates): hide non-actionable links when not logged in
A non-logged in user cannot vote/enable notifications or submit a request so hide these links.
This commit is contained in:
parent
a16fac9b95
commit
d393ed2352
2 changed files with 73 additions and 66 deletions
|
@ -24,71 +24,73 @@
|
|||
{{ "Search wiki" | tr }}
|
||||
</a>
|
||||
</li>
|
||||
{% if not out_of_date %}
|
||||
{% if request.user.is_authenticated() %}
|
||||
{% if not out_of_date %}
|
||||
<li>
|
||||
<a href="/pkgbase/{{ pkgbase.Name }}/flag">
|
||||
{{ "Flag package out-of-date" | tr }}
|
||||
</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li>
|
||||
<span class="flagged">
|
||||
<a href="/pkgbase/{{ pkgbase.Name }}/flag-comment">
|
||||
{{
|
||||
"Flagged out-of-date (%s)"
|
||||
| tr | format(date_strftime(pkgbase.OutOfDateTS, "%Y-%m-%d"))
|
||||
}}
|
||||
</a>
|
||||
</span>
|
||||
</li>
|
||||
{% if request.user.has_credential(creds.PKGBASE_UNFLAG, approved=unflaggers) %}
|
||||
<li>
|
||||
<form action="/pkgbase/{{ pkgbase.Name }}/unflag" method="post">
|
||||
<input class="button text-button"
|
||||
type="submit"
|
||||
name="do_UnFlag"
|
||||
value="{{ 'Unflag package' | tr }}"
|
||||
/>
|
||||
</form>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<li>
|
||||
<a href="/pkgbase/{{ pkgbase.Name }}/flag">
|
||||
{{ "Flag package out-of-date" | tr }}
|
||||
</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li>
|
||||
<span class="flagged">
|
||||
<a href="/pkgbase/{{ pkgbase.Name }}/flag-comment">
|
||||
{{
|
||||
"Flagged out-of-date (%s)"
|
||||
| tr | format(date_strftime(pkgbase.OutOfDateTS, "%Y-%m-%d"))
|
||||
}}
|
||||
</a>
|
||||
</span>
|
||||
</li>
|
||||
{% if request.user.has_credential(creds.PKGBASE_UNFLAG, approved=unflaggers) %}
|
||||
<li>
|
||||
<form action="/pkgbase/{{ pkgbase.Name }}/unflag" method="post">
|
||||
<input class="button text-button"
|
||||
type="submit"
|
||||
name="do_UnFlag"
|
||||
value="{{ 'Unflag package' | tr }}"
|
||||
/>
|
||||
{% if not voted %}
|
||||
<form action="/pkgbase/{{ pkgbase.Name }}/vote" method="post">
|
||||
<input type="submit"
|
||||
class="button text-button"
|
||||
name="do_Vote"
|
||||
value="{{ 'Vote for this package' | tr }}" />
|
||||
</form>
|
||||
{% else %}
|
||||
<form action="/pkgbase/{{ pkgbase.Name }}/unvote" method="post">
|
||||
<input type="submit"
|
||||
class="button text-button"
|
||||
name="do_UnVote"
|
||||
value="{{ 'Remove vote' | tr }}" />
|
||||
</form>
|
||||
{% endif %}
|
||||
</li>
|
||||
<li>
|
||||
{% if notified %}
|
||||
<form action="/pkgbase/{{ pkgbase.Name }}/unnotify" method="post">
|
||||
<input type="submit"
|
||||
class="button text-button"
|
||||
name="do_UnNotify"
|
||||
value="{{ 'Disable notifications' | tr }}"
|
||||
/>
|
||||
</form>
|
||||
{% else %}
|
||||
<form action="/pkgbase/{{ pkgbase.Name }}/notify" method="post">
|
||||
<input type="submit"
|
||||
class="button text-button"
|
||||
name="do_Notify"
|
||||
value="{{ 'Enable notifications' | tr }}"
|
||||
/>
|
||||
</form>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<li>
|
||||
{% if not voted %}
|
||||
<form action="/pkgbase/{{ pkgbase.Name }}/vote" method="post">
|
||||
<input type="submit"
|
||||
class="button text-button"
|
||||
name="do_Vote"
|
||||
value="{{ 'Vote for this package' | tr }}" />
|
||||
</form>
|
||||
{% else %}
|
||||
<form action="/pkgbase/{{ pkgbase.Name }}/unvote" method="post">
|
||||
<input type="submit"
|
||||
class="button text-button"
|
||||
name="do_UnVote"
|
||||
value="{{ 'Remove vote' | tr }}" />
|
||||
</form>
|
||||
{% endif %}
|
||||
</li>
|
||||
<li>
|
||||
{% if notified %}
|
||||
<form action="/pkgbase/{{ pkgbase.Name }}/unnotify" method="post">
|
||||
<input type="submit"
|
||||
class="button text-button"
|
||||
name="do_UnNotify"
|
||||
value="{{ 'Disable notifications' | tr }}"
|
||||
/>
|
||||
</form>
|
||||
{% else %}
|
||||
<form action="/pkgbase/{{ pkgbase.Name }}/notify" method="post">
|
||||
<input type="submit"
|
||||
class="button text-button"
|
||||
name="do_Notify"
|
||||
value="{{ 'Enable notifications' | tr }}"
|
||||
/>
|
||||
</form>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% if request.user.has_credential(creds.PKGBASE_EDIT_COMAINTAINERS, approved=[pkgbase.Maintainer]) %}
|
||||
<li>
|
||||
<a href="/pkgbase/{{ pkgbase.Name }}/comaintainers">
|
||||
|
@ -111,11 +113,13 @@
|
|||
</li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<li>
|
||||
<a href="/pkgbase/{{ pkgbase.Name }}/request?{{ {'next': '/pkgbase/%s' | format(pkgbase.Name)} | urlencode }}">
|
||||
{{ "Submit Request" | tr }}
|
||||
</a>
|
||||
</li>
|
||||
{% if request.user.is_authenticated() %}
|
||||
<li>
|
||||
<a href="/pkgbase/{{ pkgbase.Name }}/request?{{ {'next': '/pkgbase/%s' | format(pkgbase.Name)} | urlencode }}">
|
||||
{{ "Submit Request" | tr }}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if request.user.has_credential(creds.PKGBASE_DELETE) %}
|
||||
<li>
|
||||
<a href="/pkgbase/{{ pkgbase.Name }}/delete?next=/packages">
|
||||
|
|
|
@ -507,7 +507,9 @@ def test_package_requests_display(
|
|||
client: TestClient, user: User, package: Package, pkgreq: PackageRequest
|
||||
):
|
||||
# Test that a single request displays "1 pending request".
|
||||
cookies = {"AURSID": user.login(Request(), "testPassword")}
|
||||
with client as request:
|
||||
request.cookies = cookies
|
||||
resp = request.get(package_endpoint(package))
|
||||
assert resp.status_code == int(HTTPStatus.OK)
|
||||
|
||||
|
@ -530,6 +532,7 @@ def test_package_requests_display(
|
|||
|
||||
# Test that a two requests display "2 pending requests".
|
||||
with client as request:
|
||||
request.cookies = cookies
|
||||
resp = request.get(package_endpoint(package))
|
||||
assert resp.status_code == int(HTTPStatus.OK)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue