Skip to content

Commit

Permalink
* Allow users to search by author name.
Browse files Browse the repository at this point in the history
  • Loading branch information
bgroff committed May 24, 2018
1 parent b08c983 commit 0b07660
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion django_kala/django_kala/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,13 @@ def dispatch(self, request, *args, **kwargs):
documents = request.user.get_documents()
self.documents = documents.filter(
id__in=DocumentVersion.objects.annotate(
search=SearchVector('name', 'description')
search=SearchVector(
'name',
'description',
'user__first_name',
'user__last_name',
'user__username'
)
).filter(
search=request.GET.get('search', '')
).values_list('document_id', flat=True)
Expand Down
8 changes: 7 additions & 1 deletion django_kala/projects/views/projects/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,13 @@ def dispatch(self, request, pk, *args, **kwargs):
if 'search' in request.GET and request.GET['search'] != '':
self.documents = documents.filter(
id__in=DocumentVersion.objects.annotate(
search=SearchVector('name', 'description')
search=SearchVector(
'name',
'description',
'user__first_name',
'user__last_name',
'user__username'
)
).filter(
search=request.GET.get('search', '')
).values_list('document_id', flat=True)
Expand Down

0 comments on commit 0b07660

Please sign in to comment.