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
659b0f6c
Commit
659b0f6c
authored
3 years ago
by
Tore.Brede
Browse files
Options
Downloads
Patches
Plain Diff
GREG-27: Adding more information in person listing
parent
ab5ae854
No related branches found
Branches containing commit
No related tags found
1 merge request
!31
GREG-27: Adding more information in person listing
Pipeline
#91276
passed
3 years ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
greg/api/serializers/person.py
+44
-19
44 additions, 19 deletions
greg/api/serializers/person.py
greg/migrations/0002_auto_20210827_1437.py
+24
-0
24 additions, 0 deletions
greg/migrations/0002_auto_20210827_1437.py
greg/models.py
+2
-2
2 additions, 2 deletions
greg/models.py
with
70 additions
and
21 deletions
greg/api/serializers/person.py
+
44
−
19
View file @
659b0f6c
from
rest_framework
import
serializers
from
greg.models
import
Person
,
PersonRole
,
Role
,
PersonIdentity
class
PersonSerializer
(
serializers
.
ModelSerializer
):
class
Meta
:
model
=
Person
fields
=
[
"
id
"
,
"
first_name
"
,
"
last_name
"
,
"
date_of_birth
"
,
"
email
"
,
"
mobile_phone
"
,
"
email_verified_date
"
,
"
mobile_phone
"
,
"
mobile_phone_verified_date
"
,
"
registration_completed_date
"
,
"
token
"
,
]
from
greg.models
import
Person
,
PersonRole
,
Role
,
PersonIdentity
,
PersonConsent
,
Consent
class
PersonRoleSerializer
(
serializers
.
ModelSerializer
):
...
...
@@ -57,3 +39,46 @@ class PersonIdentitySerializer(serializers.ModelSerializer):
.
filter
(
value__like
=
value
)
.
exists
()
)
class
ConsentSerializerBrief
(
serializers
.
ModelSerializer
):
class
Meta
:
model
=
Consent
fields
=
[
"
type
"
,
"
valid_from
"
,
"
user_allowed_to_change
"
,
]
class
PersonConsentSerializerBrief
(
serializers
.
ModelSerializer
):
consent
=
ConsentSerializerBrief
(
read_only
=
True
)
class
Meta
:
model
=
PersonConsent
fields
=
[
"
consent
"
,
"
consent_given_at
"
]
class
PersonSerializer
(
serializers
.
ModelSerializer
):
identities
=
PersonIdentitySerializer
(
many
=
True
,
read_only
=
True
)
person_roles
=
PersonRoleSerializer
(
many
=
True
,
read_only
=
True
)
person_consent
=
PersonConsentSerializerBrief
(
many
=
True
,
read_only
=
True
)
class
Meta
:
model
=
Person
fields
=
[
"
id
"
,
"
first_name
"
,
"
last_name
"
,
"
date_of_birth
"
,
"
email
"
,
"
mobile_phone
"
,
"
email_verified_date
"
,
"
mobile_phone
"
,
"
mobile_phone_verified_date
"
,
"
registration_completed_date
"
,
"
token
"
,
"
identities
"
,
"
person_roles
"
,
"
person_consent
"
,
]
This diff is collapsed.
Click to expand it.
greg/migrations/0002_auto_20210827_1437.py
0 → 100644
+
24
−
0
View file @
659b0f6c
# Generated by Django 3.2.5 on 2021-08-27 14:37
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'
greg
'
,
'
0001_initial
'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'
personconsent
'
,
name
=
'
consent
'
,
field
=
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
PROTECT
,
related_name
=
'
person_consent
'
,
to
=
'
greg.consent
'
),
),
migrations
.
AlterField
(
model_name
=
'
personconsent
'
,
name
=
'
person
'
,
field
=
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'
person_consent
'
,
to
=
'
greg.person
'
),
),
]
This diff is collapsed.
Click to expand it.
greg/models.py
+
2
−
2
View file @
659b0f6c
...
...
@@ -273,10 +273,10 @@ class PersonConsent(BaseModel):
"""
person
=
models
.
ForeignKey
(
"
Person
"
,
on_delete
=
models
.
CASCADE
,
related_name
=
"
link_
person_consent
"
"
Person
"
,
on_delete
=
models
.
CASCADE
,
related_name
=
"
person_consent
"
)
consent
=
models
.
ForeignKey
(
"
Consent
"
,
on_delete
=
models
.
PROTECT
,
related_name
=
"
link_
person_consent
"
"
Consent
"
,
on_delete
=
models
.
PROTECT
,
related_name
=
"
person_consent
"
)
# If the date is blank it means the person has not given consent yet
consent_given_at
=
models
.
DateField
(
null
=
True
)
...
...
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