def get_promo(country_code, programming_language, gold_project=False, gold_user=False):
 promo_queryset = SupporterPromo.objects.filter(live=True, display_type='doc')
 filtered_promos = []
 for obj in promo_queryset:
  if (obj.programming_language and (not show_to_programming_language(obj, programming_language))):
   continue
  if (country_code and (not show_to_geo(obj, country_code))):
   continue
  filtered_promos.append(obj)
 promo_obj = choose_promo(filtered_promos)
 if (not promo_obj):
  house_promo = SupporterPromo.objects.filter(live=True, name='house').order_by('?')
  if house_promo.exists():
   promo_obj = house_promo.first()
 if gold_user:
  gold_promo = SupporterPromo.objects.filter(live=True, name='gold-user')
  if gold_promo.exists():
   promo_obj = gold_promo.first()
 if gold_project:
  gold_promo = SupporterPromo.objects.filter(live=True, name='gold-project')
  if gold_promo.exists():
   promo_obj = gold_promo.first()
 return promo_obj

def get_promo ( country_code , programming_language , gold_project = False , gold_user = False ) : promo_queryset = SupporterPromo . objects . filter ( live = True , display_type = 'doc' ) filtered_promos = [ ] for obj in promo_queryset : if ( obj . programming_language and ( not show_to_programming_language ( obj , programming_language ) ) ) : continue if ( country_code and ( not show_to_geo ( obj , country_code ) ) ) : continue filtered_promos . append ( obj ) promo_obj = choose_promo ( filtered_promos ) if ( not promo_obj ) : house_promo = SupporterPromo . objects . filter ( live = True , name = 'house' ) . order_by ( '?' ) if house_promo . exists ( ) : promo_obj = house_promo . first ( ) if gold_user : gold_promo = SupporterPromo . objects . filter ( live = True , name = 'gold-user' ) if gold_promo . exists ( ) : promo_obj = gold_promo . first ( ) if gold_project : gold_promo = SupporterPromo . objects . filter ( live = True , name = 'gold-project' ) if gold_promo . exists ( ) : promo_obj = gold_promo . first ( ) return promo_obj
get a proper promo .