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:
Jelle van der Waa 2024-08-09 11:21:37 +02:00
parent a16fac9b95
commit 640ebd114e
No known key found for this signature in database
GPG key ID: C06086337C50773E

View file

@ -53,42 +53,44 @@
</li> </li>
{% endif %} {% endif %}
{% endif %} {% endif %}
<li> {% if request.user.is_authenticated() %}
{% if not voted %} <li>
<form action="/pkgbase/{{ pkgbase.Name }}/vote" method="post"> {% if not voted %}
<input type="submit" <form action="/pkgbase/{{ pkgbase.Name }}/vote" method="post">
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" <input type="submit"
class="button text-button" class="button text-button"
name="do_UnNotify" name="do_Vote"
value="{{ 'Disable notifications' | tr }}" value="{{ 'Vote for this package' | tr }}" />
/>
</form> </form>
{% else %} {% else %}
<form action="/pkgbase/{{ pkgbase.Name }}/notify" method="post"> <form action="/pkgbase/{{ pkgbase.Name }}/unvote" method="post">
<input type="submit" <input type="submit"
class="button text-button" class="button text-button"
name="do_Notify" name="do_UnVote"
value="{{ 'Enable notifications' | tr }}" value="{{ 'Remove vote' | tr }}" />
/>
</form> </form>
{% endif %} {% endif %}
</li> </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 %}
{% if request.user.has_credential(creds.PKGBASE_EDIT_COMAINTAINERS, approved=[pkgbase.Maintainer]) %} {% if request.user.has_credential(creds.PKGBASE_EDIT_COMAINTAINERS, approved=[pkgbase.Maintainer]) %}
<li> <li>
<a href="/pkgbase/{{ pkgbase.Name }}/comaintainers"> <a href="/pkgbase/{{ pkgbase.Name }}/comaintainers">
@ -111,11 +113,13 @@
</li> </li>
{% endif %} {% endif %}
{% endif %} {% endif %}
<li> {% if request.user.is_authenticated() %}
<a href="/pkgbase/{{ pkgbase.Name }}/request?{{ {'next': '/pkgbase/%s' | format(pkgbase.Name)} | urlencode }}"> <li>
{{ "Submit Request" | tr }} <a href="/pkgbase/{{ pkgbase.Name }}/request?{{ {'next': '/pkgbase/%s' | format(pkgbase.Name)} | urlencode }}">
</a> {{ "Submit Request" | tr }}
</li> </a>
</li>
{% endif %}
{% if request.user.has_credential(creds.PKGBASE_DELETE) %} {% if request.user.has_credential(creds.PKGBASE_DELETE) %}
<li> <li>
<a href="/pkgbase/{{ pkgbase.Name }}/delete?next=/packages"> <a href="/pkgbase/{{ pkgbase.Name }}/delete?next=/packages">