SciPost Code Repository
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SciPost
Manage
Activity
Members
Labels
Plan
Issues
118
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SciPost
SciPost
Commits
bc49ec1c
Commit
bc49ec1c
authored
1 year ago
by
George Katsikas
Browse files
Options
Downloads
Patches
Plain Diff
add multi word capability to profile searching
parent
10c9a5a4
No related branches found
No related tags found
1 merge request
!44
Add multi word capability to profile searching
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scipost_django/profiles/views.py
+16
-9
16 additions, 9 deletions
scipost_django/profiles/views.py
with
16 additions
and
9 deletions
scipost_django/profiles/views.py
+
16
−
9
View file @
bc49ec1c
...
@@ -2,6 +2,7 @@ __copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)"
...
@@ -2,6 +2,7 @@ __copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)"
__license__
=
"
AGPL v3
"
__license__
=
"
AGPL v3
"
from
functools
import
reduce
from
django.contrib
import
messages
from
django.contrib
import
messages
from
django.contrib.auth.mixins
import
UserPassesTestMixin
from
django.contrib.auth.mixins
import
UserPassesTestMixin
from
django.urls
import
reverse
,
reverse_lazy
from
django.urls
import
reverse
,
reverse_lazy
...
@@ -51,12 +52,18 @@ class ProfileAutocompleteView(autocomplete.Select2QuerySetView):
...
@@ -51,12 +52,18 @@ class ProfileAutocompleteView(autocomplete.Select2QuerySetView):
return
None
return
None
qs
=
Profile
.
objects
.
all
()
qs
=
Profile
.
objects
.
all
()
if
self
.
q
:
if
self
.
q
:
qs
=
qs
.
filter
(
# Iteratively filter by each word in the query
Q
(
first_name__icontains
=
self
.
q
)
qs
=
reduce
(
|
Q
(
last_name__icontains
=
self
.
q
)
lambda
qs
,
q
:
qs
.
filter
(
|
Q
(
emails__email__icontains
=
self
.
q
)
Q
(
first_name__icontains
=
q
)
|
Q
(
orcid_id__icontains
=
self
.
q
)
|
Q
(
last_name__icontains
=
q
)
).
distinct
()
|
Q
(
emails__email__icontains
=
q
)
|
Q
(
orcid_id__icontains
=
q
)
).
distinct
(),
self
.
q
.
split
(),
qs
,
)
return
qs
return
qs
...
@@ -368,9 +375,9 @@ def _hx_profile_specialties(request, profile_id):
...
@@ -368,9 +375,9 @@ def _hx_profile_specialties(request, profile_id):
elif
request
.
POST
.
get
(
"
action
"
)
==
"
remove
"
:
elif
request
.
POST
.
get
(
"
action
"
)
==
"
remove
"
:
profile
.
specialties
.
remove
(
specialty
)
profile
.
specialties
.
remove
(
specialty
)
current_spec_slugs
=
[
s
.
slug
for
s
in
profile
.
specialties
.
all
()]
current_spec_slugs
=
[
s
.
slug
for
s
in
profile
.
specialties
.
all
()]
other_specialties
=
Specialty
.
objects
.
filter
(
other_specialties
=
Specialty
.
objects
.
filter
(
acad_field
=
profile
.
acad_field
).
exclude
(
acad_field
=
profile
.
acad_field
slug__in
=
profile
.
specialties
.
values_list
(
"
slug
"
)
)
.
exclude
(
slug__in
=
profile
.
specialties
.
values_list
(
"
slug
"
))
)
context
=
{
context
=
{
"
profile
"
:
profile
,
"
profile
"
:
profile
,
"
other_specialties
"
:
other_specialties
,
"
other_specialties
"
:
other_specialties
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment