Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
greg
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
it-bott-integrasjoner
greg
Commits
a5916895
Commit
a5916895
authored
2 years ago
by
pka065
Browse files
Options
Downloads
Patches
Plain Diff
Change name of field with person ID + add serializer for output in swagger
parent
64c870c0
No related branches found
No related tags found
1 merge request
!348
GREG-292: search for person via v1-api
Pipeline
#161344
passed
2 years ago
Stage: venv update
Stage: tests and linting
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
greg/api/serializers/person.py
+15
-0
15 additions, 0 deletions
greg/api/serializers/person.py
greg/api/views/person.py
+2
-0
2 additions, 0 deletions
greg/api/views/person.py
search_tools/person_search.py
+6
-2
6 additions, 2 deletions
search_tools/person_search.py
with
23 additions
and
2 deletions
greg/api/serializers/person.py
+
15
−
0
View file @
a5916895
...
...
@@ -24,3 +24,18 @@ class PersonSerializer(serializers.ModelSerializer):
"
roles
"
,
"
consents
"
,
]
class
PersonSearchSerializer
(
serializers
.
ModelSerializer
):
person_id
=
serializers
.
CharField
(
source
=
"
id
"
)
first
=
serializers
.
CharField
(
source
=
"
first_name
"
)
last
=
serializers
.
CharField
(
source
=
"
last_name
"
)
class
Meta
:
model
=
Person
fields
=
[
"
person_id
"
,
"
first
"
,
"
last
"
,
"
date_of_birth
"
,
]
This diff is collapsed.
Click to expand it.
greg/api/views/person.py
+
2
−
0
View file @
a5916895
...
...
@@ -15,6 +15,7 @@ from greg.api.pagination import PrimaryKeyCursorPagination
from
greg.api.serializers.consent
import
ConsentSerializerBrief
from
greg.api.serializers.person
import
(
PersonSerializer
,
PersonSearchSerializer
,
IdentitySerializer
,
)
from
greg.api.serializers.role
import
RoleSerializer
,
RoleWriteSerializer
...
...
@@ -63,6 +64,7 @@ class PersonSearchSet(viewsets.ModelViewSet):
"""
Search for persons using name, email, phone number and birth date
"""
permission_classes
=
(
permissions
.
IsAdminUser
,)
serializer_class
=
PersonSearchSerializer
def
list
(
self
,
request
,
*
args
,
**
kwargs
):
if
"
q
"
not
in
self
.
request
.
query_params
:
...
...
This diff is collapsed.
Click to expand it.
search_tools/person_search.py
+
6
−
2
View file @
a5916895
...
...
@@ -3,6 +3,10 @@ from greg.models import Identity, Person
def
person_by_string_query
(
request
):
search
=
request
.
query_params
[
"
q
"
]
if
"
gregui
"
in
request
.
version
:
id_field_name
=
"
pid
"
else
:
id_field_name
=
"
person_id
"
split_search
=
search
.
split
()
words_joined
=
"
|
"
.
join
(
map
(
str
,
split_search
))
...
...
@@ -22,7 +26,7 @@ def person_by_string_query(request):
for
person
in
persons
:
hits
.
append
(
{
"
pid
"
:
person
.
id
,
id_field_name
:
person
.
id
,
"
first
"
:
person
.
first_name
,
"
last
"
:
person
.
last_name
,
"
date_of_birth
"
:
person
.
date_of_birth
,
...
...
@@ -49,7 +53,7 @@ def person_by_string_query(request):
hits
.
append
(
{
"
pid
"
:
identity
.
person_id
,
id_field_name
:
identity
.
person_id
,
"
first
"
:
identity
.
person
.
first_name
,
"
last
"
:
identity
.
person
.
last_name
,
"
value
"
:
identity
.
value
,
...
...
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