parameters: (analyst)
return_statement: return {'success': True, 'results': results}
docstring: Get all favorites for a user.
  
      :param analyst: The username.
      :type analyst: str
      :returns: dict with keys "success" (boolean) and "results" (string)
docstring_summary: Get all favorites for a user.
docstring_tokens: Get all favorites for a user .
function: def get_favorites(analyst):
      """
      Get all favorites for a user.
  
      :param analyst: The username.
      :type analyst: str
      :returns: dict with keys "success" (boolean) and "results" (string)
      """
  
      user = CRITsUser.objects(username=analyst).first()
      if not user:
          return {'success': False, 'message': '<div id="favorites_results">Could not find user.</div>'}
  
      favorites = user.favorites.to_dict()
      if not favorites:
          return {'success': True, 'message': '<div id="favorites_results">You have no favorites.</div>'}
  
      field_dict = {
          'Actor': 'name',
          'Backdoor': 'name',
          'Campaign': 'name',
          'Certificate': 'filename',
          'Comment': 'object_id',
          'Domain': 'domain',
          'Email': 'id',
          'Event': 'title',
          'Exploit': 'name',
          'Indicator': 'id',
          'IP': 'ip',
          'PCAP': 'filename',
          'RawData': 'title',
          'Sample': 'filename',
          'Screenshot': 'id',
          'Signature': 'title',
          'Target': 'email_address'
      }
  
      results = '''
                <table>
                    <tbody>
                '''
  
      for type_, attr in field_dict.iteritems():
          if type_ in favorites:
              ids = [ObjectId(s) for s in favorites[type_]]
              objs = class_from_type(type_).objects(id__in=ids).only(attr)
              for obj in objs:
                  obj_attr = getattr(obj, attr)
                  results += '<tr><td>%s</td><td><a href="%s">%s</a></td>' % (type_,
                      reverse('crits-core-views-details',
                               args=(type_, str(obj.id))),
                      obj_attr)
                  results += '<td><span class="ui-icon ui-icon-trash remove_favorite favorites_icon_active" '
                  results += 'data-type="%s" data-id="%s"></span></td><td width="5px"></td></tr>' % (type_, str(obj.id))
      results += '</tbody></table>'
  
      return {'success': True, 'results': results}
function_tokens: def get_favorites ( analyst ) : user = CRITsUser . objects ( username = analyst ) . first ( ) if not user : return { 'success' : False , 'message' : '<div id="favorites_results">Could not find user.</div>' } favorites = user . favorites . to_dict ( ) if not favorites : return { 'success' : True , 'message' : '<div id="favorites_results">You have no favorites.</div>' } field_dict = { 'Actor' : 'name' , 'Backdoor' : 'name' , 'Campaign' : 'name' , 'Certificate' : 'filename' , 'Comment' : 'object_id' , 'Domain' : 'domain' , 'Email' : 'id' , 'Event' : 'title' , 'Exploit' : 'name' , 'Indicator' : 'id' , 'IP' : 'ip' , 'PCAP' : 'filename' , 'RawData' : 'title' , 'Sample' : 'filename' , 'Screenshot' : 'id' , 'Signature' : 'title' , 'Target' : 'email_address' } results = '''
                <table>
                    <tbody>
                ''' for type_ , attr in field_dict . iteritems ( ) : if type_ in favorites : ids = [ ObjectId ( s ) for s in favorites [ type_ ] ] objs = class_from_type ( type_ ) . objects ( id__in = ids ) . only ( attr ) for obj in objs : obj_attr = getattr ( obj , attr ) results += '<tr><td>%s</td><td><a href="%s">%s</a></td>' % ( type_ , reverse ( 'crits-core-views-details' , args = ( type_ , str ( obj . id ) ) ) , obj_attr ) results += '<td><span class="ui-icon ui-icon-trash remove_favorite favorites_icon_active" ' results += 'data-type="%s" data-id="%s"></span></td><td width="5px"></td></tr>' % ( type_ , str ( obj . id ) ) results += '</tbody></table>' return { 'success' : True , 'results' : results }