Handle search errors

This commit is contained in:
Ivan Habunek 2020-02-04 11:42:53 +01:00 committed by Drew DeVault
parent 7f9f1d0f66
commit e885f90876
2 changed files with 10 additions and 3 deletions

View File

@ -77,8 +77,12 @@ def return_tracker(tracker, access, **kwargs):
.options(subqueryload(Ticket.submitter))
.order_by(Ticket.updated.desc()))
terms = request.args.get("search")
tickets = apply_search(tickets, terms, tracker, current_user)
try:
terms = request.args.get("search")
tickets = apply_search(tickets, terms, tracker, current_user)
except ValueError as e:
kwargs["search_error"] = str(e)
tickets, pagination = paginate_query(tickets, results_per_page=25)
# Find which tickets were seen by the user since last update

View File

@ -154,11 +154,14 @@
name="search"
type="text"
placeholder="Search tickets... status:closed label:label order:updated submitter:me"
class="form-control"
class="form-control{% if search_error %} is-invalid{% endif %}"
{% if not another %}
autofocus
{% endif %}
value="{{ search if search else "" }}" />
{% if search_error %}
<div class="invalid-feedback">{{ search_error }}</div>
{% endif %}
</form>
{% if len(tickets) %}
<div class="ticket-list">