def create_new_stage(stage_data): '''Create a new stage. Creates a new stage from the passed stage_data and returns the created stage object. ''' properties = stage_data.pop('properties', []) stage = Stage.create(**stage_data) for property in properties: property.update({'stage_id': stage.id}) StageProperty.create(**property) return stage
def insert_a_stage(name='foo', send_notifs=False, post_opportunities=False): stage = Stage.create(**{ 'name': name, 'send_notifs': send_notifs, 'post_opportunities': post_opportunities }) properties = [ dict(stage_id=stage.id, key='foo', value='bar'), dict(stage_id=stage.id, key='baz', value='qux') ] for property in properties: StageProperty.create(**property) return stage
def insert_a_stage(name='foo', send_notifs=False, post_opportunities=False): stage = Stage.create( **{ 'name': name, 'send_notifs': send_notifs, 'post_opportunities': post_opportunities }) properties = [ dict(stage_id=stage.id, key='foo', value='bar'), dict(stage_id=stage.id, key='baz', value='qux') ] for property in properties: StageProperty.create(**property) return stage