Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
AE
Sith
Commits
347caa3b
Commit
347caa3b
authored
Dec 07, 2018
by
Sli
Committed by
Skia
Dec 13, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
forum and core: fix error 500 when query is empty on search
parent
65a0b7b2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
1 deletion
+5
-1
core/views/site.py
core/views/site.py
+2
-0
forum/templates/forum/search.jinja
forum/templates/forum/search.jinja
+1
-1
forum/views.py
forum/views.py
+2
-0
No files found.
core/views/site.py
View file @
347caa3b
...
...
@@ -71,6 +71,8 @@ def notification(request, notif_id):
def
search_user
(
query
,
as_json
=
False
):
if
query
==
""
:
return
[]
res
=
SearchQuerySet
().
models
(
User
).
autocomplete
(
auto
=
query
)[:
20
]
return
[
r
.
object
for
r
in
res
]
...
...
forum/templates/forum/search.jinja
View file @
347caa3b
...
...
@@ -4,9 +4,9 @@
{%
block
content
%}
<div
id=
"forum"
>
{{
display_search_bar
()
}}
{%
if
object_list
|
length
!=
0
%}
<br>
{{
display_search_bar
()
}}
<div
class=
"search-results"
>
{%
for
m
in
object_list
%}
{{
display_message
(
m
,
user
)
}}
...
...
forum/views.py
View file @
347caa3b
...
...
@@ -54,6 +54,8 @@ class ForumSearchView(ListView):
def
get_queryset
(
self
):
query
=
self
.
request
.
GET
.
get
(
"query"
,
""
)
if
query
==
""
:
return
[]
queryset
=
SearchQuerySet
().
models
(
ForumMessage
).
autocomplete
(
auto
=
query
)[:
100
]
return
[
r
.
object
for
r
in
queryset
if
can_view
(
r
.
object
.
topic
,
self
.
request
.
user
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment