Skip to content
Snippets Groups Projects
Commit b2a71661 authored by Andreas Ellewsen's avatar Andreas Ellewsen
Browse files

Merge branch 'bugfix/userinfo-noperson' into 'master'

Make userinfo work if user has no person info

See merge request !95
parents f64c7ab2 b36d0cb5
No related branches found
No related tags found
1 merge request!95Make userinfo work if user has no person info
Pipeline #96124 passed
......@@ -52,7 +52,6 @@ class UserInfoView(APIView):
"person_id": person_id,
}
person = user_profile.person
roles = person.roles
if person:
content.update(
{
......@@ -62,27 +61,28 @@ class UserInfoView(APIView):
"mobile_phone": person.mobile_phone,
}
)
if roles:
content.update(
{
"roles": [
{
"ou_name_nb": role.orgunit_id.name_nb,
"ou_name_en": role.orgunit_id.name_en,
"role_name_nb": role.type.name_nb,
"role_name_en": role.type.name_en,
"start": role.start_date,
"end": role.end_date,
"comments": role.comments,
"sponsor": {
"first_name": role.sponsor_id.first_name,
"last_name": role.sponsor_id.last_name,
},
}
for role in roles.all()
],
}
)
roles = person.roles
if roles:
content.update(
{
"roles": [
{
"ou_name_nb": role.orgunit_id.name_nb,
"ou_name_en": role.orgunit_id.name_en,
"role_name_nb": role.type.name_nb,
"role_name_en": role.type.name_en,
"start": role.start_date,
"end": role.end_date,
"comments": role.comments,
"sponsor": {
"first_name": role.sponsor_id.first_name,
"last_name": role.sponsor_id.last_name,
},
}
for role in roles.all()
],
}
)
return Response(content)
# Invitation cookie, allow access
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment