ad = Ad.objects.using(database).get(id=ad_id) except: print "[ERROR] Invalid ad: %s" % ad_id continue d = Deal() d.creator = user_profile d.owner = business_profile d.ad = ad if status == 'done': status = 'completed' elif status == 'aborted': status = 'canceled' d.state = status d.created = ts_to_datetime(created) d.updated = ts_to_datetime(updated) d.last_reminder = ts_to_datetime(last_reminder) d.manual_processing = int(manual_processing) d.commission = commission d.payed_to_agent = int(is_payed_to_agent) d.agent_commission = agent_commission d.cancel_reason = reason d.price = end_price if not bid: bid = 0.00 d.bid = bid