def order_history(user, **kwargs):
 course_org_filter = (kwargs['course_org_filter'] if ('course_org_filter' in kwargs) else None)
 org_filter_out_set = (kwargs['org_filter_out_set'] if ('org_filter_out_set' in kwargs) else [])
 order_history_list = []
 purchased_order_items = OrderItem.objects.filter(user=user, status='purchased').select_subclasses().order_by('-fulfilled_time')
 for order_item in purchased_order_items:
  if (order_item.order.id not in [item['order_id'] for item in order_history_list]):
   order_item_course_id = getattr(order_item, 'course_id', None)
   if order_item_course_id:
    if ((course_org_filter and (course_org_filter == order_item_course_id.org)) or ((course_org_filter is None) and (order_item_course_id.org not in org_filter_out_set))):
     order_history_list.append({'order_id': order_item.order.id, 'receipt_url': reverse('shoppingcart.views.show_receipt', kwargs={'ordernum': order_item.order.id}), 'order_date': ModuleI18nService().strftime(order_item.order.purchase_time, 'SHORT_DATE')})
 return order_history_list

def order_history ( user , ** kwargs ) : course_org_filter = ( kwargs [ 'course_org_filter' ] if ( 'course_org_filter' in kwargs ) else None ) org_filter_out_set = ( kwargs [ 'org_filter_out_set' ] if ( 'org_filter_out_set' in kwargs ) else [ ] ) order_history_list = [ ] purchased_order_items = OrderItem . objects . filter ( user = user , status = 'purchased' ) . select_subclasses ( ) . order_by ( '-fulfilled_time' ) for order_item in purchased_order_items : if ( order_item . order . id not in [ item [ 'order_id' ] for item in order_history_list ] ) : order_item_course_id = getattr ( order_item , 'course_id' , None ) if order_item_course_id : if ( ( course_org_filter and ( course_org_filter == order_item_course_id . org ) ) or ( ( course_org_filter is None ) and ( order_item_course_id . org not in org_filter_out_set ) ) ) : order_history_list . append ( { 'order_id' : order_item . order . id , 'receipt_url' : reverse ( 'shoppingcart.views.show_receipt' , kwargs = { 'ordernum' : order_item . order . id } ) , 'order_date' : ModuleI18nService ( ) . strftime ( order_item . order . purchase_time , 'SHORT_DATE' ) } ) return order_history_list
display a list of the currently logged-in users past orders .