Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
05e64bb7
authored
Mar 06, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: extract search_user
parent
70fcc92b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
5 deletions
+10
-5
circle/dashboard/views.py
+10
-5
No files found.
circle/dashboard/views.py
View file @
05e64bb7
...
@@ -44,6 +44,15 @@ from dashboard.models import Favourite, Profile
...
@@ -44,6 +44,15 @@ from dashboard.models import Favourite, Profile
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
def
search_user
(
keyword
):
try
:
return
User
.
objects
.
get
(
username
=
keyword
)
except
User
.
DoesNotExist
:
return
User
.
objects
.
get
(
email
=
keyword
)
except
User
.
DoesNotExist
:
return
User
.
objects
.
get
(
profile__org_id
=
keyword
)
# github.com/django/django/blob/stable/1.6.x/django/contrib/messages/views.py
# github.com/django/django/blob/stable/1.6.x/django/contrib/messages/views.py
class
SuccessMessageMixin
(
object
):
class
SuccessMessageMixin
(
object
):
"""
"""
...
@@ -1490,11 +1499,7 @@ class TransferOwnershipView(LoginRequiredMixin, DetailView):
...
@@ -1490,11 +1499,7 @@ class TransferOwnershipView(LoginRequiredMixin, DetailView):
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
try
:
try
:
new_owner
=
User
.
objects
.
get
(
username
=
request
.
POST
[
'name'
])
new_owner
=
search_user
(
request
.
POST
[
'name'
])
except
User
.
DoesNotExist
:
new_owner
=
User
.
objects
.
get
(
email
=
request
.
POST
[
'name'
])
except
User
.
DoesNotExist
:
new_owner
=
User
.
objects
.
get
(
profile__org_id
=
request
.
POST
[
'name'
])
except
User
.
DoesNotExist
:
except
User
.
DoesNotExist
:
messages
.
error
(
request
,
_
(
'Can not find specified user.'
))
messages
.
error
(
request
,
_
(
'Can not find specified user.'
))
return
self
.
get
(
request
,
*
args
,
**
kwargs
)
return
self
.
get
(
request
,
*
args
,
**
kwargs
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment