Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
djangoldp
Manage
Activity
Members
Labels
Plan
Issues
99
Issue boards
Milestones
Wiki
Code
Merge requests
5
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
Commits
a0aa469e
Commit
a0aa469e
authored
5 years ago
by
Jean-Baptiste
Browse files
Options
Downloads
Patches
Plain Diff
update: use settings.AUTH_USER_MODEL
parent
5b5ad3bb
No related branches found
No related tags found
No related merge requests found
Pipeline
#896
failed with stage
Stage: test
in 1 minute and 22 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
djangoldp/factories.py
+2
-2
2 additions, 2 deletions
djangoldp/factories.py
djangoldp/views.py
+1
-2
1 addition, 2 deletions
djangoldp/views.py
with
3 additions
and
4 deletions
djangoldp/factories.py
+
2
−
2
View file @
a0aa469e
import
factory
from
django.con
trib.auth.models
import
U
se
r
from
django.con
f
import
se
ttings
from
django.db.models.signals
import
post_save
@factory.django.mute_signals
(
post_save
)
class
UserFactory
(
factory
.
django
.
DjangoModelFactory
):
class
Meta
:
model
=
U
se
r
model
=
se
ttings
.
AUTH_USER_MODEL
username
=
factory
.
Faker
(
'
user_name
'
)
first_name
=
factory
.
Faker
(
'
first_name
'
)
...
...
This diff is collapsed.
Click to expand it.
djangoldp/views.py
+
1
−
2
View file @
a0aa469e
from
django.apps
import
apps
from
django.conf
import
settings
from
django.conf.urls
import
url
,
include
from
django.contrib.auth.models
import
User
from
django.core.exceptions
import
FieldDoesNotExist
from
django.core.urlresolvers
import
get_resolver
from
django.db.utils
import
OperationalError
,
ProgrammingError
...
...
@@ -120,7 +119,7 @@ class LDPViewSet(LDPViewSetGenerator):
return
type
(
LDPSerializer
)(
model_name
+
'
Serializer
'
,
(
LDPSerializer
,),
{
'
Meta
'
:
meta_class
})
def
perform_create
(
self
,
serializer
,
**
kwargs
):
if
hasattr
(
self
.
model
.
_meta
,
'
auto_author
'
)
and
isinstance
(
self
.
request
.
user
,
U
se
r
):
if
hasattr
(
self
.
model
.
_meta
,
'
auto_author
'
)
and
isinstance
(
self
.
request
.
user
,
se
ttings
.
AUTH_USER_MODEL
):
kwargs
[
self
.
model
.
_meta
.
auto_author
]
=
self
.
request
.
user
serializer
.
save
(
**
kwargs
)
...
...
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