#NEWLINE# def add_contributor_json( user , current_user = None ) : #NEWLINE# #INDENT# '\n    Generate a dictionary representation of a user, optionally including # projects shared with `current_user`\n\n    :param User user: The user object to serialize\n    :param User current_user : The user object for a different user, to calculate number of projects in common\n    :return dict: A dict representing the serialized user data\n    ' #NEWLINE# if current_user : #NEWLINE# #INDENT# n_projects_in_common = current_user . n_projects_in_common ( current_user ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# n_projects_in_common = 0 #NEWLINE# #UNINDENT# current_employment = None #NEWLINE# education = None #NEWLINE# if user . jobs : #NEWLINE# #INDENT# current_employment = user . jobs [ 0 ] [ 'institution' ] #NEWLINE# #UNINDENT# if user . schools : #NEWLINE# #INDENT# education = user . schools [ 0 ] [ 'institution' ] #NEWLINE# #UNINDENT# return { #NEWLINE# #INDENT# 'fullname' : user . fullname , #NEWLINE# 'email' : user . username , #NEWLINE# 'id' : user . _primary_key , #NEWLINE# 'employment' : current_employment , #NEWLINE# 'education' : education , #NEWLINE# 'n_projects_in_common' : n_projects_in_common , #NEWLINE# 'registered' : user . is_registered , #NEWLINE# 'active' : user . is_active , #NEWLINE# 'gravatar_url' : gravatar ( user , use_ssl = True , size = settings . PROFILE_IMAGE_MEDIUM ) , #NEWLINE# 'profile_url' : user . profile_url , #NEWLINE# #UNINDENT# }