feat(FastAPI): add /pkgbase/{name}/comaintainers (get, post)

Changes from PHP:

- Form action now points to `/pkgbase/{name}/comaintainers`.
- When an error occurs, users are sent back to
  `/pkgbase/{name}/comaintainers` with an error at the top of the page.
  (PHP used to send people to /pkgbase/, which ended up at a blank
  search page).

Closes: https://gitlab.archlinux.org/archlinux/aurweb/-/issues/51

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2021-09-16 19:42:09 -07:00
parent 2efd254974
commit 4d191b51f9
No known key found for this signature in database
GPG key ID: F7E46DED420788F3
4 changed files with 295 additions and 2 deletions

View file

@ -117,9 +117,9 @@
{% endif %}
</form>
{% if is_maintainer %}
{% if request.user.has_credential('CRED_PKGBASE_EDIT_COMAINTAINERS', approved=[pkgbase.Maintainer]) %}
<li>
<a href="/pkgbase/{{ result.Name }}/comaintainers/">
<a href="/pkgbase/{{ pkgbase.Name }}/comaintainers/">
{{ "Manage Co-Maintainers" | tr }}
</a>
</li>

View file

@ -0,0 +1,40 @@
{% extends "partials/layout.html" %}
{% block pageContent %}
{% if errors %}
<ul class="errorlist">
{% for error in errors %}
<li>{{ error | tr }}</li>
{% endfor %}
</ul>
{% endif %}
<div class="box">
<h2>{{ "Manage Co-maintainers" | tr }}:</h2>
<p>
{{
"Use this form to add co-maintainers for %s%s%s "
"(one user name per line):"
| tr | format("<strong>", pkgbase.Name, "</strong>")
| safe
}}
</p>
<form action="/pkgbase/{{ pkgbase.Name }}/comaintainers" method="post">
<fieldset>
<p>
<label for="id_users">{{ "Users" | tr }}:</label>
<textarea id="id_users" name="users"
rows="5" cols="50">{{ "\n".join(comaintainers) }}</textarea>
</p>
<p>
<button class="button" type="submit">
{{ "Save" | tr }}
</button>
</p>
</fieldset>
</form>
</div>
{% endblock %}