def _filter_transactions(qs, data):
 filter_mapping = {'app': 'addon_id', 'transaction_type': 'type', 'transaction_id': 'uuid', 'date_from': 'created__gte', 'date_to': 'created__lte'}
 for (form_field, db_field) in filter_mapping.iteritems():
  if data.get(form_field):
   try:
    qs = qs.filter(**{db_field: data[form_field]})
   except ValueError:
    continue
 return qs

def _filter_transactions ( qs , data ) : filter_mapping = { 'app' : 'addon_id' , 'transaction_type' : 'type' , 'transaction_id' : 'uuid' , 'date_from' : 'created__gte' , 'date_to' : 'created__lte' } for ( form_field , db_field ) in filter_mapping . iteritems ( ) : if data . get ( form_field ) : try : qs = qs . filter ( ** { db_field : data [ form_field ] } ) except ValueError : continue return qs
handle search filters and queries for transactions .