mirror of https://git.sr.ht/~sircmpwn/hub.sr.ht
Test for & display invalid search errors on profile page, too
I was there indeed
This commit is contained in:
parent
134c1f27d6
commit
df5ddcc3cb
|
@ -55,11 +55,15 @@ def projects_GET(owner):
|
||||||
projects = projects.filter(Project.visibility == Visibility.public)
|
projects = projects.filter(Project.visibility == Visibility.public)
|
||||||
|
|
||||||
search = request.args.get("search")
|
search = request.args.get("search")
|
||||||
|
search_error = None
|
||||||
if search:
|
if search:
|
||||||
projects = search_by(projects, search,
|
try:
|
||||||
[Project.name, Project.description])
|
projects = search_by(projects, search,
|
||||||
|
[Project.name, Project.description])
|
||||||
|
except ValueError as e:
|
||||||
|
search_error = str(e)
|
||||||
|
|
||||||
projects, pagination = paginate_query(projects)
|
projects, pagination = paginate_query(projects)
|
||||||
|
|
||||||
return render_template("projects.html", user=owner, projects=projects,
|
return render_template("projects.html", user=owner, projects=projects,
|
||||||
search=search, **pagination)
|
search=search, search_error=search_error, **pagination)
|
||||||
|
|
|
@ -35,8 +35,8 @@
|
||||||
name="search"
|
name="search"
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Search {{user.canonical_name}}'s projects"
|
placeholder="Search {{user.canonical_name}}'s projects"
|
||||||
class="form-control"
|
class="form-control {% if search_error %}is-invalid{% endif %}"
|
||||||
value="{{search if search else ""}}" />
|
value="{{search or ""}}" />
|
||||||
{% if search_error %}
|
{% if search_error %}
|
||||||
<div class="invalid-feedback">{{ search_error }}</div>
|
<div class="invalid-feedback">{{ search_error }}</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
Loading…
Reference in New Issue