def schedule_create(schedule_values): db_utils.validate_schedule_values(schedule_values) # make a copy so we can remove 'schedule_metadata' # without affecting the caller values = schedule_values.copy() metadata = None session = get_session() schedule_ref = models.Schedule() if 'schedule_metadata' in values: metadata = values['schedule_metadata'] _set_schedule_metadata(schedule_ref, metadata) del values['schedule_metadata'] schedule_ref.update(values) schedule_ref.save(session=session) return _schedule_get_by_id(schedule_ref['id'])
def schedule_create(schedule_values): db_utils.validate_schedule_values(schedule_values) values = copy.deepcopy(schedule_values) schedule = {} metadata = [] if 'schedule_metadata' in values: metadata = values['schedule_metadata'] del values['schedule_metadata'] schedule.update(values) schedule.update(_gen_base_attributes()) schedule = _schedule_create(schedule) for metadatum in metadata: schedule_meta_create(schedule['id'], metadatum) return schedule_get_by_id(schedule['id'])
def schedule_create(schedule_values): db_utils.validate_schedule_values(schedule_values) values = copy.deepcopy(schedule_values) schedule = {} metadata = [] if 'schedule_metadata' in values: metadata = values['schedule_metadata'] del values['schedule_metadata'] schedule.update(values) item_id = values.get('id') schedule.update(_gen_base_attributes(item_id=item_id)) schedule = _schedule_create(schedule) for metadatum in metadata: schedule_meta_create(schedule['id'], metadatum) return schedule_get_by_id(schedule['id'])