Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
synnefo
Commits
88f65afa
Commit
88f65afa
authored
Aug 10, 2012
by
Sofia Papagiannaki
Browse files
avoid contacting the database if request.user is authenticated
parent
9c635ffb
Changes
1
Hide whitespace changes
Inline
Side-by-side
snf-astakos-app/astakos/im/api/__init__.py
View file @
88f65afa
...
...
@@ -146,19 +146,20 @@ def get_services(request):
@
api_method
()
def
get_menu
(
request
,
with_extra_links
=
False
,
with_signout
=
True
):
index_url
=
reverse
(
'index'
)
user
=
request
.
user
if
not
isinstance
(
user
,
AstakosUser
):
cookie
=
unquote
(
request
.
COOKIES
.
get
(
COOKIE_NAME
,
''
))
email
=
cookie
.
partition
(
'|'
)[
0
]
try
:
if
email
:
user
=
AstakosUser
.
objects
.
get
(
email
=
email
,
is_active
=
True
)
except
AstakosUser
.
DoesNotExist
:
pass
absolute
=
lambda
(
url
):
request
.
build_absolute_uri
(
url
)
l
=
[{
'url'
:
absolute
(
index_url
),
'name'
:
"Sign in"
}]
cookie
=
unquote
(
request
.
COOKIES
.
get
(
COOKIE_NAME
,
''
))
email
=
cookie
.
partition
(
'|'
)[
0
]
try
:
if
not
email
:
raise
ValueError
user
=
AstakosUser
.
objects
.
get
(
email
=
email
,
is_active
=
True
)
except
AstakosUser
.
DoesNotExist
:
pass
except
ValueError
:
pass
if
not
isinstance
(
user
,
AstakosUser
):
index_url
=
reverse
(
'index'
)
l
=
[{
'url'
:
absolute
(
index_url
),
'name'
:
"Sign in"
}]
else
:
l
=
[]
l
.
append
(
dict
(
url
=
absolute
(
reverse
(
'index'
)),
name
=
user
.
email
))
...
...
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