Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
djangoldp-account
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
djangoldp-packages
djangoldp-account
Commits
e80ee9d9
Commit
e80ee9d9
authored
6 years ago
by
Jean-Baptiste
Browse files
Options
Downloads
Patches
Plain Diff
update: auto-add nested field for user from other packages
parent
ee62888b
No related branches found
No related tags found
1 merge request
!6
Resolve "Allow third party package to add nested fields to the user"
Pipeline
#373
passed
6 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
djangoldp_account/settings.py
+7
-1
7 additions, 1 deletion
djangoldp_account/settings.py
djangoldp_account/urls.py
+18
-0
18 additions, 0 deletions
djangoldp_account/urls.py
with
25 additions
and
1 deletion
djangoldp_account/settings.py
+
7
−
1
View file @
e80ee9d9
from
django.urls
import
reverse_lazy
from
django.conf
import
settings
from
django.conf
import
settings
from
django.urls
import
reverse_lazy
def
userinfo
(
claims
,
user
):
def
userinfo
(
claims
,
user
):
# Populate claims dict.
# Populate claims dict.
...
@@ -7,3 +8,8 @@ def userinfo(claims, user):
...
@@ -7,3 +8,8 @@ def userinfo(claims, user):
claims
[
'
email
'
]
=
user
.
email
claims
[
'
email
'
]
=
user
.
email
claims
[
'
website
'
]
=
'
{0}{1}
'
.
format
(
settings
.
BASE_URL
,
reverse_lazy
(
'
user-detail
'
,
kwargs
=
{
'
pk
'
:
user
.
pk
}))
claims
[
'
website
'
]
=
'
{0}{1}
'
.
format
(
settings
.
BASE_URL
,
reverse_lazy
(
'
user-detail
'
,
kwargs
=
{
'
pk
'
:
user
.
pk
}))
return
claims
return
claims
USER_FIELDS
=
[
'
@id
'
,
'
first_name
'
,
'
groups
'
,
'
last_name
'
,
'
username
'
,
'
email
'
,
'
profile
'
,
'
account
'
,
'
ldnotification_set
'
,
'
chatProfile
'
]
USER_NESTED_FIELDS
=
[
'
account
'
,
'
profile
'
,
'
groups
'
,
'
ldnotification_set
'
,
'
chatProfile
'
]
This diff is collapsed.
Click to expand it.
djangoldp_account/urls.py
+
18
−
0
View file @
e80ee9d9
"""
djangoldp project URL Configuration
"""
"""
djangoldp project URL Configuration
"""
from
importlib
import
import_module
from
django.conf
import
settings
from
django.conf.urls
import
url
,
include
from
django.conf.urls
import
url
,
include
from
django.contrib.auth.models
import
Group
from
djangoldp.views
import
LDPViewSet
from
djangoldp.views
import
LDPViewSet
from
.models
import
ChatProfile
,
Account
,
ChatConfig
from
.models
import
ChatProfile
,
Account
,
ChatConfig
from
.views
import
userinfocustom
from
.views
import
userinfocustom
djangoldp_modules
=
list
(
filter
(
lambda
app
:
app
.
startswith
(
'
djangoldp_
'
),
settings
.
INSTALLED_APPS
))
user_fields
=
[]
user_nested_fields
=
[]
for
dldp_module
in
djangoldp_modules
:
try
:
user_fields
+=
import_module
(
dldp_module
+
'
.settings
'
).
USER_FIELDS
user_nested_fields
+=
import_module
(
dldp_module
+
'
.settings
'
).
USER_NESTED_FIELDS
except
:
pass
urlpatterns
=
[
urlpatterns
=
[
url
(
r
'
^groups/
'
,
LDPViewSet
.
urls
(
model
=
Group
,
fields
=
[
'
@id
'
,
'
name
'
,
'
user_set
'
])),
url
(
r
'
^users/
'
,
LDPViewSet
.
urls
(
model
=
settings
.
AUTH_USER_MODEL
,
fields
=
user_fields
,
permission_classes
=
[],
nested_fields
=
user_nested_fields
)),
url
(
r
'
^accounts/
'
,
include
(
'
django.contrib.auth.urls
'
)),
url
(
r
'
^accounts/
'
,
LDPViewSet
.
urls
(
model
=
Account
)),
url
(
r
'
^accounts/
'
,
LDPViewSet
.
urls
(
model
=
Account
)),
url
(
r
'
^chat-profile/
'
,
LDPViewSet
.
urls
(
model
=
ChatProfile
)),
url
(
r
'
^chat-profile/
'
,
LDPViewSet
.
urls
(
model
=
ChatProfile
)),
url
(
r
'
^chat-config/
'
,
LDPViewSet
.
urls
(
model
=
ChatConfig
)),
url
(
r
'
^chat-config/
'
,
LDPViewSet
.
urls
(
model
=
ChatConfig
)),
...
...
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