Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
itminedu
synnefo
Commits
e54d3f1e
Commit
e54d3f1e
authored
Jul 08, 2016
by
Filippos Giannakos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
admin: Fix broken tests
parent
f910dc2b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
3 deletions
+17
-3
snf-admin-app/synnefo_admin/admin/resources/projects/utils.py
...admin-app/synnefo_admin/admin/resources/projects/utils.py
+9
-2
snf-admin-app/synnefo_admin/admin/resources/users/utils.py
snf-admin-app/synnefo_admin/admin/resources/users/utils.py
+8
-1
No files found.
snf-admin-app/synnefo_admin/admin/resources/projects/utils.py
View file @
e54d3f1e
...
...
@@ -37,9 +37,16 @@ def get_actual_owner(inst):
def
get_project_or_404
(
query
,
for_update
=
False
):
project_obj
=
Project
.
objects
.
select_for_update
()
if
for_update
\
else
Project
.
objects
if
isinstance
(
query
,
basestring
):
q
=
Q
(
id
=
int
(
query
))
if
query
.
isdigit
()
else
Q
(
uuid
=
query
)
elif
isinstance
(
query
,
int
)
or
isinstance
(
query
,
long
):
q
=
Q
(
id
=
int
(
query
))
else
:
raise
TypeError
(
"Unexpected type of query"
)
try
:
return
project_obj
.
get
(
Q
(
id
=
int
(
query
))
if
query
.
isdigit
()
else
Q
(
uuid
=
query
))
return
project_obj
.
get
(
q
)
except
ObjectDoesNotExist
:
raise
AdminHttp404
(
"No Project was found that matches this query: %s
\n
"
%
query
)
...
...
snf-admin-app/synnefo_admin/admin/resources/users/utils.py
View file @
e54d3f1e
...
...
@@ -42,7 +42,14 @@ def get_user_or_404(query, for_update=False):
"""
usr_obj
=
AstakosUser
.
objects
.
select_for_update
()
if
for_update
\
else
AstakosUser
.
objects
q
=
Q
(
id
=
int
(
query
))
if
query
.
isdigit
()
else
Q
(
uuid
=
query
)
|
Q
(
email
=
query
)
if
isinstance
(
query
,
basestring
):
q
=
Q
(
id
=
int
(
query
))
if
query
.
isdigit
()
else
Q
(
uuid
=
query
)
|
Q
(
email
=
query
)
elif
isinstance
(
query
,
int
)
or
isinstance
(
query
,
long
):
q
=
Q
(
id
=
int
(
query
))
else
:
raise
TypeError
(
"Unexpected type of query"
)
try
:
return
usr_obj
.
get
(
q
)
except
ObjectDoesNotExist
:
...
...
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