def set_plan_item(pk): user_id = flask.session['user_id'] plan = Plan.fetchone(pk=pk, user_id=user_id, is_enable=1) if not plan: raise error.PlanNoteFound() kinds = NoteKind.fetchall( user_id=user_id, is_enable=1, order=NoteKind.create_at.desc()) return flask.render_template('plan_set_item.html', plan=plan, kinds=kinds)
def set_plan_item_quantity(plan_id, kind_id): user_id = flask.session['user_id'] plan = Plan.fetchone(pk=plan_id, user_id=user_id, is_enable=1) if not plan: raise error.PlanNoteFound() kind = NoteKind.fetchone(pk=kind_id, user_id=user_id, is_enable=1) if not kind: raise error.KindNotExistError() return flask.render_template('plan_set_quantity.html', plan=plan, kind=kind)
def create_kind_api(): name = flask.request.form.get('name') user_id = flask.session['user_id'] note_kind = NoteKind.fetchone(name=name, user_id=user_id) if note_kind: raise error.KindExistError() note_kind = NoteKind() note_kind.name = name note_kind.user_id = user_id note_kind.save() return {'pk': note_kind.pk}
def create_note_api(): kind_id = flask.request.form.get('kind_id') quantity = flask.request.form.get('quantity') content = flask.request.form.get('content') user_id = int(flask.session['user_id']) # Check kind owner note_kind = NoteKind.fetchone(pk=kind_id, user_id=user_id) if not note_kind: raise error.KindNotExistError() note = Note() note.kind_id = kind_id note.user_id = user_id note.content = content note.quantity = quantity note.save() return {'pk': note.pk}
def get_kinds(): user_id = int(flask.session['user_id']) records = NoteKind.fetchall(user_id=user_id) return {'kinds': records}
def create_note(pk): note_kind = NoteKind.fetchone(pk=pk, user_id=flask.session['user_id']) if not note_kind: raise error.KindNotExistError() return flask.render_template('note_create.html', kind=note_kind)