mirror of
https://git.sr.ht/~sircmpwn/hub.sr.ht
synced 2024-09-12 21:30:36 +02:00
Test for & display invalid search errors on profile page, too
I was there indeed
This commit is contained in:
parent
134c1f27d6
commit
df5ddcc3cb
2 changed files with 9 additions and 5 deletions
|
@ -55,11 +55,15 @@ def projects_GET(owner):
|
|||
projects = projects.filter(Project.visibility == Visibility.public)
|
||||
|
||||
search = request.args.get("search")
|
||||
search_error = None
|
||||
if search:
|
||||
projects = search_by(projects, search,
|
||||
[Project.name, Project.description])
|
||||
try:
|
||||
projects = search_by(projects, search,
|
||||
[Project.name, Project.description])
|
||||
except ValueError as e:
|
||||
search_error = str(e)
|
||||
|
||||
projects, pagination = paginate_query(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"
|
||||
type="text"
|
||||
placeholder="Search {{user.canonical_name}}'s projects"
|
||||
class="form-control"
|
||||
value="{{search if search else ""}}" />
|
||||
class="form-control {% if search_error %}is-invalid{% endif %}"
|
||||
value="{{search or ""}}" />
|
||||
{% if search_error %}
|
||||
<div class="invalid-feedback">{{ search_error }}</div>
|
||||
{% endif %}
|
||||
|
|
Loading…
Reference in a new issue