Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
djangoldp-profile
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-profile
Commits
8c69657d
Verified
Commit
8c69657d
authored
5 years ago
by
Jean-Baptiste Pasquier
Browse files
Options
Downloads
Patches
Plain Diff
update: slugify & updated for abstract model
parent
8780041d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!12
update: slugify & updated for abstract model
Pipeline
#1283
passed
5 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
djangoldp_profile/migrations/0001_initial.py
+3
-2
3 additions, 2 deletions
djangoldp_profile/migrations/0001_initial.py
djangoldp_profile/models.py
+8
-3
8 additions, 3 deletions
djangoldp_profile/models.py
with
11 additions
and
5 deletions
djangoldp_profile/migrations/0001_initial.py
+
3
−
2
View file @
8c69657d
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-0
8-28 12:01
# Generated by Django 1.11.20 on 2019-0
9-12 18:55
from
__future__
import
unicode_literals
from
django.conf
import
settings
...
...
@@ -20,12 +20,13 @@ class Migration(migrations.Migration):
name
=
'
Profile
'
,
fields
=
[
(
'
id
'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'
ID
'
)),
(
'
slug
'
,
models
.
SlugField
(
unique
=
True
)),
(
'
available
'
,
models
.
NullBooleanField
()),
(
'
bio
'
,
models
.
CharField
(
blank
=
True
,
max_length
=
150
)),
(
'
city
'
,
models
.
CharField
(
blank
=
True
,
max_length
=
255
)),
(
'
phone
'
,
models
.
CharField
(
blank
=
True
,
max_length
=
255
)),
(
'
website
'
,
models
.
URLField
(
blank
=
True
)),
(
'
user
'
,
models
.
OneToOneField
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
settings
.
AUTH_USER_MODEL
)),
(
'
user
'
,
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'
profile
'
,
to
=
settings
.
AUTH_USER_MODEL
)),
],
),
]
This diff is collapsed.
Click to expand it.
djangoldp_profile/models.py
+
8
−
3
View file @
8c69657d
...
...
@@ -8,7 +8,8 @@ from djangoldp.models import Model
class
Profile
(
Model
):
user
=
models
.
OneToOneField
(
settings
.
AUTH_USER_MODEL
,
on_delete
=
models
.
CASCADE
)
user
=
models
.
ForeignKey
(
settings
.
AUTH_USER_MODEL
,
related_name
=
'
profile
'
,
on_delete
=
models
.
CASCADE
)
slug
=
models
.
SlugField
(
unique
=
True
)
available
=
models
.
NullBooleanField
(
blank
=
True
)
bio
=
models
.
CharField
(
max_length
=
150
,
blank
=
True
)
city
=
models
.
CharField
(
max_length
=
255
,
blank
=
True
)
...
...
@@ -35,6 +36,10 @@ class Profile(Model):
@receiver
(
post_save
,
sender
=
settings
.
AUTH_USER_MODEL
)
def
create_user_profile
(
sender
,
instance
,
created
,
**
kwargs
):
if
created
:
Profile
.
objects
.
create
(
user
=
instance
)
Profile
.
objects
.
create
(
user
=
instance
,
slug
=
instance
.
username
)
else
:
instance
.
profile
.
save
()
try
:
instance
.
profile
.
slug
=
instance
.
username
instance
.
profile
.
save
()
except
:
pass
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