def serialize_user(user, node=None, admin=False, full=False, is_profile=False):
 fullname = user.display_full_name(node=node)
 ret = {'id': str(user._primary_key), 'registered': user.is_registered, 'surname': user.family_name, 'fullname': fullname, 'shortname': (fullname if (len(fullname) < 50) else ((fullname[:23] + '...') + fullname[(-23):])), 'gravatar_url': gravatar(user, use_ssl=True, size=settings.PROFILE_IMAGE_MEDIUM), 'active': user.is_active}
 if (node is not None):
  if admin:
   flags = {'visible': False, 'permission': 'read'}
  else:
   flags = {'visible': node.contributor_set.filter(user=user, visible=True).exists(), 'permission': reduce_permissions(node.get_permissions(user))}
  ret.update(flags)
 if user.is_registered:
  ret.update({'url': user.url, 'absolute_url': user.absolute_url, 'display_absolute_url': user.display_absolute_url, 'date_registered': user.date_registered.strftime('%Y-%m-%d')})
 if full:
  if is_profile:
   ret['emails'] = ([{'address': each, 'primary': (each.strip().lower() == user.username.strip().lower()), 'confirmed': True} for each in user.emails] + [{'address': each, 'primary': (each.strip().lower() == user.username.strip().lower()), 'confirmed': False} for each in user.unconfirmed_emails])
  if user.is_merged:
   merger = user.merged_by
   merged_by = {'id': str(merger._primary_key), 'url': merger.url, 'absolute_url': merger.absolute_url}
  else:
   merged_by = None
  ret.update({'number_projects': get_projects(user).count(), 'number_public_projects': get_public_projects(user).count(), 'activity_points': user.get_activity_points(), 'gravatar_url': gravatar(user, use_ssl=True, size=settings.PROFILE_IMAGE_LARGE), 'is_merged': user.is_merged, 'merged_by': merged_by})
 return ret

def serialize_user ( user , node = None , admin = False , full = False , is_profile = False ) : fullname = user . display_full_name ( node = node ) ret = { 'id' : str ( user . _primary_key ) , 'registered' : user . is_registered , 'surname' : user . family_name , 'fullname' : fullname , 'shortname' : ( fullname if ( len ( fullname ) < 50 ) else ( ( fullname [ : 23 ] + '...' ) + fullname [ ( - 23 ) : ] ) ) , 'gravatar_url' : gravatar ( user , use_ssl = True , size = settings . PROFILE_IMAGE_MEDIUM ) , 'active' : user . is_active } if ( node is not None ) : if admin : flags = { 'visible' : False , 'permission' : 'read' } else : flags = { 'visible' : node . contributor_set . filter ( user = user , visible = True ) . exists ( ) , 'permission' : reduce_permissions ( node . get_permissions ( user ) ) } ret . update ( flags ) if user . is_registered : ret . update ( { 'url' : user . url , 'absolute_url' : user . absolute_url , 'display_absolute_url' : user . display_absolute_url , 'date_registered' : user . date_registered . strftime ( '%Y-%m-%d' ) } ) if full : if is_profile : ret [ 'emails' ] = ( [ { 'address' : each , 'primary' : ( each . strip ( ) . lower ( ) == user . username . strip ( ) . lower ( ) ) , 'confirmed' : True } for each in user . emails ] + [ { 'address' : each , 'primary' : ( each . strip ( ) . lower ( ) == user . username . strip ( ) . lower ( ) ) , 'confirmed' : False } for each in user . unconfirmed_emails ] ) if user . is_merged : merger = user . merged_by merged_by = { 'id' : str ( merger . _primary_key ) , 'url' : merger . url , 'absolute_url' : merger . absolute_url } else : merged_by = None ret . update ( { 'number_projects' : get_projects ( user ) . count ( ) , 'number_public_projects' : get_public_projects ( user ) . count ( ) , 'activity_points' : user . get_activity_points ( ) , 'gravatar_url' : gravatar ( user , use_ssl = True , size = settings . PROFILE_IMAGE_LARGE ) , 'is_merged' : user . is_merged , 'merged_by' : merged_by } ) return ret
returns a milestones-friendly representation of a user object .