change(FastAPI): depend on auth_required redirect for pkgbase actions

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2021-10-07 00:39:25 -07:00
parent 8bc1fab74d
commit dc11a88ed3
No known key found for this signature in database
GPG key ID: F7E46DED420788F3

View file

@ -23,99 +23,68 @@
{{ "Search wiki" | tr }} {{ "Search wiki" | tr }}
</a> </a>
</li> </li>
{% if not request.user.is_authenticated() %} {% if not out_of_date %}
{% if not out_of_date %}
<li> <li>
<a href="/pkgbase/{{ result.Name }}/flag/"> <a href="/pkgbase/{{ result.Name }}/flag/">
{{ "Flag package out-of-date" | tr }} {{ "Flag package out-of-date" | tr }}
</a> </a>
</li> </li>
{% else %}
<li>
<span class="flagged">
{% set ood_ts = result.OutOfDateTS | dt | as_timezone(timezone) %}
{{
"Flagged out-of-date (%s)"
| tr | format(ood_ts.strftime("%Y-%m-%d"))
}}
</span>
</li>
{% endif %}
<li>
<a href="/login?next={{ request.url.path | quote_plus }}">
{{ "Vote for this package" | tr }}
</a>
</li>
<li>
<a href="/login?next={{ request.url.path | quote_plus }}">
{{ "Enable notifications" | tr }}
</a>
</li>
{% else %} {% else %}
{% if not out_of_date %} <li>
<li> <span class="flagged">
<a href="/pkgbase/{{ result.Name }}/flag/"> {% set ood_ts = result.OutOfDateTS | dt | as_timezone(timezone) %}
{{ "Flag package out-of-date" | tr }} {{
</a> "Flagged out-of-date (%s)"
</li> | tr | format(ood_ts.strftime("%Y-%m-%d"))
{% else %} }}
<li> </span>
<span class="flagged"> </li>
{% set ood_ts = result.OutOfDateTS | dt | as_timezone(timezone) %} <li>
{{ <form action="/pkgbase/{{ result.Name }}/unflag" method="post">
"Flagged out-of-date (%s)" <input class="button text-button"
| tr | format(ood_ts.strftime("%Y-%m-%d")) type="submit"
}} name="do_UnFlag"
</span> value="{{ 'Unflag package' | tr }}"
</li> />
<li> </form>
<form action="/pkgbase/{{ result.Name }}/unflag" method="post"> </li>
<input class="button text-button" {% endif %}
type="submit" <li>
name="do_UnFlag" {% if not voted %}
value="{{ 'Unflag package' | tr }}" <form action="/pkgbase/{{ result.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/{{ result.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/{{ result.Name }}/unnotify/" method="post">
<input type="submit"
class="button text-button"
name="do_UnNotify"
value="{{ 'Disable notifications' | tr }}"
/> />
</form> </form>
</li> {% else %}
{% endif %} <form action="/pkgbase/{{ result.Name }}/notify/" method="post">
<li>
{% if not voted %}
<form action="/pkgbase/{{ result.Name }}/vote/" method="post">
<input type="submit" <input type="submit"
class="button text-button" class="button text-button"
name="do_Vote" name="do_Notify"
value="{{ 'Vote for this package' | tr }}" /> value="{{ 'Enable notifications' | tr }}"
/>
</form> </form>
{% else %} {% endif %}
<form action="/pkgbase/{{ result.Name }}/unvote/" method="post"> </li>
<input type="submit"
class="button text-button"
name="do_UnVote"
value="{{ 'Remove vote' | tr }}" />
</form>
{% endif %}
</li>
<li>
{% if notified %}
<form action="/pkgbase/{{ result.Name }}/unnotify/" method="post">
<input type="submit"
class="button text-button"
name="do_UnNotify"
value="{{ 'Disable notifications' | tr }}"
/>
</form>
{% else %}
<form action="/pkgbase/{{ result.Name }}/notify/" method="post">
<input type="submit"
class="button text-button"
name="do_Notify"
value="{{ 'Enable notifications' | tr }}"
/>
</form>
{% endif %}
</li>
{% endif %}
</form> </form>
{% if request.user.has_credential('CRED_PKGBASE_EDIT_COMAINTAINERS', approved=[pkgbase.Maintainer]) %} {% if request.user.has_credential('CRED_PKGBASE_EDIT_COMAINTAINERS', approved=[pkgbase.Maintainer]) %}
<li> <li>