diff --git a/hubsrht/blueprints/users.py b/hubsrht/blueprints/users.py index 8617ecf..0528a20 100644 --- a/hubsrht/blueprints/users.py +++ b/hubsrht/blueprints/users.py @@ -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) diff --git a/hubsrht/templates/projects.html b/hubsrht/templates/projects.html index ad43d8d..5c50c87 100644 --- a/hubsrht/templates/projects.html +++ b/hubsrht/templates/projects.html @@ -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 %}
{{ search_error }}
{% endif %}