print "[ERROR] Invalid user: %s" % user_id continue user_profile = user.get_userprofile() business_profile = BusinessProfile.objects.using(database).get(id=user_profile.active_profile_id) try: 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)