Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hypha
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
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
ots
hypha
Commits
2ec460f3
"opentech/public/git@code.librehq.com:ots/hypha.git" did not exist on "c7f4acb055a9c34426cb76985a97f73940d741f8"
Commit
2ec460f3
authored
7 years ago
by
Todd Dembrey
Browse files
Options
Downloads
Patches
Plain Diff
Make the User model more like the other models
parent
eabe983c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
opentech/apply/funds/models.py
+1
-1
1 addition, 1 deletion
opentech/apply/funds/models.py
opentech/apply/users/models.py
+12
-13
12 additions, 13 deletions
opentech/apply/users/models.py
with
13 additions
and
14 deletions
opentech/apply/funds/models.py
+
1
−
1
View file @
2ec460f3
...
...
@@ -69,7 +69,7 @@ class SubmittableStreamForm(AbstractStreamForm):
User
=
get_user_model
()
email
=
cleaned_data
.
get
(
'
email
'
)
full_name
=
cleaned_data
.
get
(
'
full_name
'
)
user
=
User
.
get_or_create
_new
(
user
=
User
.
objects
.
get_or_create
(
email
=
email
,
defaults
=
{
'
full_name
'
:
full_name
}
)
...
...
This diff is collapsed.
Click to expand it.
opentech/apply/users/models.py
+
12
−
13
View file @
2ec460f3
from
django.db
import
models
from
django.contrib.auth.models
import
AbstractUser
from
django.contrib.auth.models
import
AbstractUser
,
BaseUserManager
from
.utils
import
send_activation_email
class
UserManager
(
BaseUserManager
):
def
get_or_create
(
self
,
defaults
,
**
kwargs
):
defaults
.
update
(
is_active
=
False
)
user
,
created
=
super
().
get_or_create
(
defaults
=
defaults
,
**
kwargs
)
if
created
:
send_activation_email
(
user
)
return
user
class
User
(
AbstractUser
):
full_name
=
models
.
CharField
(
verbose_name
=
'
Full name
'
,
max_length
=
255
,
blank
=
True
)
objects
=
UserManager
()
class
Meta
:
unique_together
=
(
'
email
'
,)
...
...
@@ -18,15 +29,3 @@ class User(AbstractUser):
return
self
.
full_name
.
strip
()
return
super
().
get_full_name
()
def
get_user_by_email
(
self
,
email
):
email_field
=
getattr
(
self
,
'
EMAIL_FIELD
'
,
'
email
'
)
return
self
.
objects
.
filter
(
**
{
email_field
+
'
__iexact
'
:
email
})
@classmethod
def
get_or_create_new
(
cls
,
defaults
,
**
kwargs
):
defaults
.
update
(
is_active
=
False
)
user
,
created
=
cls
.
objects
.
get_or_create
(
defaults
=
defaults
,
**
kwargs
)
if
created
:
send_activation_email
(
user
)
return
user
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