def view(id): try: note = Note.get(id=id) if note is not None: return render_template('note.html', note=note, users=User.all(sortby=User.name), books=Book.all(sortby=Book.title), notation=NOTATION) else: raise('note not found') except: flash('Not found note', 'warning') return redirect(url_for('notes'))
def update(id): note = Note.get(id=id) if note is not None: note.idbook = request.form['idbook'] note.iduser = request.form['iduser'] note.note = request.form['note'] note.description = request.form['description'] note.checked = getBool.get(request.form.get('checked','off'),False) note.save() flash('Note is saved', 'success') return redirect(url_for('note.view_note', id=note.id)) else: flash('Note doesn\'t exist','error') return redirect(url_for('note.notes'))
def delete(id): note = Note.get(id=id) if note is not None: note.remove() flash('Note is deleted','error') return redirect(url_for('note.notes'))