Verified Commit beed64e0 authored by Kevin Morris's avatar Kevin Morris
Browse files

fix(fastapi): persist package request form inputs



Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
parent b4092fe7
...@@ -18,7 +18,7 @@ from aurweb.packages.search import PackageSearch ...@@ -18,7 +18,7 @@ from aurweb.packages.search import PackageSearch
from aurweb.packages.util import get_pkg_or_base, get_pkgbase_comment, query_notified, query_voted from aurweb.packages.util import get_pkg_or_base, get_pkgbase_comment, query_notified, query_voted
from aurweb.scripts import notify, popupdate from aurweb.scripts import notify, popupdate
from aurweb.scripts.rendercomment import update_comment_render from aurweb.scripts.rendercomment import update_comment_render
from aurweb.templates import make_context, render_raw_template, render_template from aurweb.templates import make_context, make_variable_context, render_raw_template, render_template
router = APIRouter() router = APIRouter()
...@@ -636,7 +636,7 @@ async def requests(request: Request, ...@@ -636,7 +636,7 @@ async def requests(request: Request,
@router.get("/pkgbase/{name}/request") @router.get("/pkgbase/{name}/request")
@auth_required(True, redirect="/pkgbase/{name}") @auth_required(True, redirect="/pkgbase/{name}")
async def package_request(request: Request, name: str): async def package_request(request: Request, name: str):
context = make_context(request, "Submit Request") context = await make_variable_context(request, "Submit Request")
pkgbase = db.query(models.PackageBase).filter( pkgbase = db.query(models.PackageBase).filter(
models.PackageBase.Name == name).first() models.PackageBase.Name == name).first()
...@@ -657,7 +657,7 @@ async def pkgbase_request_post(request: Request, name: str, ...@@ -657,7 +657,7 @@ async def pkgbase_request_post(request: Request, name: str,
pkgbase = get_pkg_or_base(name, models.PackageBase) pkgbase = get_pkg_or_base(name, models.PackageBase)
# Create our render context. # Create our render context.
context = make_context(request, "Submit Request") context = await make_variable_context(request, "Submit Request")
context["pkgbase"] = pkgbase context["pkgbase"] = pkgbase
if type not in {"deletion", "merge", "orphan"}: if type not in {"deletion", "merge", "orphan"}:
# In the case that someone crafted a POST request with an invalid # In the case that someone crafted a POST request with an invalid
......
...@@ -30,9 +30,21 @@ ...@@ -30,9 +30,21 @@
<p> <p>
<label for="id_type">{{ "Request type" | tr }}:</label> <label for="id_type">{{ "Request type" | tr }}:</label>
<select id="id_type" name="type"> <select id="id_type" name="type">
<option value="deletion">{{ "Deletion" | tr }}</option> <option value="deletion"
<option value="merge">{{ "Merge" | tr }}</option> {% if type == "deletion" %}
<option value="orphan">{{ "Orphan" | tr }}</option> selected
{% endif %}
>{{ "Deletion" | tr }}</option>
<option value="merge"
{% if type == "merge" %}
selected
{% endif %}
>{{ "Merge" | tr }}</option>
<option value="orphan"
{% if type == "orphan" %}
selected
{% endif %}
>{{ "Orphan" | tr }}</option>
</select> </select>
</p> </p>
...@@ -44,13 +56,13 @@ ...@@ -44,13 +56,13 @@
<p id="merge_section" style="display: none"> <p id="merge_section" style="display: none">
<label for="id_merge_into">{{ "Merge into" | tr }}:</label> <label for="id_merge_into">{{ "Merge into" | tr }}:</label>
<input id="id_merge_into" type="text" name="merge_into" <input id="id_merge_into" type="text" name="merge_into"
autocomplete="off" /> autocomplete="off" value="{{ merge_into or '' }}" />
</p> </p>
<p> <p>
<label for="id_comments">{{ "Comments" | tr }}:</label> <label for="id_comments">{{ "Comments" | tr }}:</label>
<textarea id="id_comments" name="comments" <textarea id="id_comments" name="comments"
rows="5" cols="50"></textarea> rows="5" cols="50">{{ comments or '' }}</textarea>
</p> </p>
<p id="deletion_hint"> <p id="deletion_hint">
......
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