#NEWLINE# def get_request_information( ) : #NEWLINE# #INDENT# '\n    Returns a dictionary of contextual information about the user at the time of logging.\n\n    Returns:\n        The dictionary.\n    ' #NEWLINE# information = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if has_request_context ( ) : #NEWLINE# #INDENT# information [ 'request' ] = { #NEWLINE# #INDENT# 'api_endpoint_method' : request . method , #NEWLINE# 'api_endpoint' : request . path , #NEWLINE# 'ip' : request . remote_addr , #NEWLINE# 'platform' : request . user_agent . platform , #NEWLINE# 'browser' : request . user_agent . browser , #NEWLINE# 'browser_version' : request . user_agent . version , #NEWLINE# 'user_agent' : request . user_agent . string , #NEWLINE# #UNINDENT# } #NEWLINE# if api . auth . is_logged_in ( ) : #NEWLINE# #INDENT# user = api . user . get_user ( ) #NEWLINE# team = api . user . get_team ( ) #NEWLINE# groups = api . team . get_groups ( ) #NEWLINE# information [ 'user' ] = { #NEWLINE# #INDENT# 'username' : user [ 'username' ] , #NEWLINE# 'email' : team [ 'email' ] , #NEWLINE# 'team_name' : team [ 'team_name' ] , #NEWLINE# 'school' : team [ 'school' ] , #NEWLINE# 'groups' : [ group [ 'name' ] for group in groups ] , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# #UNINDENT# return information