in pulseapi/users/views.py [0:0]
def userstatus(request, **kwargs):
"""
Get the login status associated with a session. If the
status is "logged in", also include the user name and
user email. NOTE: these values should never be persistently
cached by applications, for obvious reasons.
"""
username = False
profileid = False
customname = False
email = False
user = request.user
loggedin = user.is_authenticated
# A user is a moderator if they are in the moderator group
# or if they are a superuser, because superusers can do anything.
moderator = user.groups.filter(name='moderator')
is_moderator = len(moderator) > 0
if is_moderator is False:
is_moderator = user.is_superuser
if loggedin:
username = user.name
profileid = user.profile.id
customname = user.profile.custom_name
email = user.email
return render(request, 'users/userstatus.json', {
'username': username,
'profileid': profileid,
'customname': customname,
'email': email,
'loggedin': loggedin,
'moderator': is_moderator,
}, content_type="application/json")