Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-wiki
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
django-wiki
Commits
aded5116
Commit
aded5116
authored
Oct 10, 2014
by
Benjamin Richter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
% fix haystack search query (request.group not set and should be list of all groups)
parent
bddeb12b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
11 deletions
+10
-11
wiki/plugins/haystack/views.py
+10
-11
No files found.
wiki/plugins/haystack/views.py
View file @
aded5116
from
haystack.backends
import
SQ
from
wiki.views.article
import
SearchView
from
wiki.views.article
import
SearchView
from
haystack.query
import
SearchQuerySet
from
haystack.query
import
SearchQuerySet
from
haystack.inputs
import
AutoQuery
from
haystack.inputs
import
AutoQuery
from
wiki.core
import
permissions
from
wiki.core
import
permissions
from
wiki
import
models
from
wiki
import
models
class
HaystackSearchView
(
SearchView
):
class
HaystackSearchView
(
SearchView
):
template_name
=
'wiki/plugins/haystack/search.html'
template_name
=
'wiki/plugins/haystack/search.html'
...
@@ -11,20 +13,18 @@ class HaystackSearchView(SearchView):
...
@@ -11,20 +13,18 @@ class HaystackSearchView(SearchView):
def
get_queryset
(
self
):
def
get_queryset
(
self
):
qs
=
SearchQuerySet
()
.
all
()
qs
=
SearchQuerySet
()
.
all
()
if
self
.
request
.
user
.
is_authenticated
():
if
self
.
request
.
user
.
is_authenticated
():
# TODO: This has a leak! It should say
:
if
not
permissions
.
can_moderate
(
models
.
URLPath
.
root
()
.
article
,
self
.
request
.
user
)
:
# group=self.request.group.id AND group_read=True
qs
=
qs
.
filter
(
if
not
permissions
.
can_moderate
(
models
.
URLPath
.
root
()
.
article
,
SQ
(
owner_id
=
self
.
request
.
user
.
id
)
|
self
.
request
.
user
):
(
qs
=
qs
.
filter_or
(
SQ
(
group_id__in
=
self
.
request
.
user
.
groups
.
values_list
(
'id'
,
flat
=
True
))
owner
=
self
.
request
.
user
.
id
,
&
SQ
(
group_read
=
True
)
group
=
self
.
request
.
group
.
id
,
)
|
other_read
=
True
SQ
(
other_read
=
True
)
)
)
else
:
else
:
qs
=
qs
.
exclude
(
other_read
=
False
)
qs
=
qs
.
exclude
(
other_read
=
False
)
qs
=
qs
.
filter
(
content
=
AutoQuery
(
self
.
query
))
qs
=
qs
.
filter
(
content
=
AutoQuery
(
self
.
query
))
qs
=
qs
.
exclude
(
other_read
=
False
)
qs
=
qs
.
load_all
()
qs
=
qs
.
load_all
()
return
qs
return
qs
\ No newline at end of file
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