def edit_step(step_id, recipe_id, order_no, instructions): step = models.Step.query.filter(models.Step.id == step_id, models.Step.recipe_id == recipe_id).one() step.recipe_id = recipe_id step.order_no = order_no step.instructions = instructions db.session.commit() step_schema = models.StepSchema() step_tuple = collections.namedtuple('StepData', ['id', 'data']) result = step_tuple(id=step.id, data=step_schema.dump(step).data) return result
def get_steps(recipe_id): steps_schema = models.StepSchema(many=True) steps = models.Step.query.all() return steps_schema.dump(steps).data
def get_step(recipe_id, step_id): step_schema = models.StepSchema() step = models.Step.query.filter(models.Step.recipe_id == recipe_id, models.Step.id == step_id).one() return step_schema.dump(step).data