#NEWLINE# def find_auto_discounts( product ) : #NEWLINE# #INDENT# if ( not ( type ( product ) in ( types . ListType , types . TupleType ) ) ) : #NEWLINE# #INDENT# product = ( product , ) #NEWLINE# #UNINDENT# today = datetime . date . today ( ) #NEWLINE# discs = Discount . objects . filter ( automatic = True , active = True , startDate__lte = today , endDate__gt = discs ) #NEWLINE# return discs . filter ( ( Q ( valid_products__in = product ) | Q ( allValid = True ) ) ) . order_by ( '-percentage' )