def archive_note(pk): try: note = Note.get(Note.id == pk) except Note.DoesNotExist: abort(404) note.delete_instance() return redirect(url_for('homepage'))
def archive_note(pk): try: note = Note.get(Note.id == pk) except Note.DoesNotExist: abort(404) note.archived = True note.save() return jsonify({'success': True})
def delete_note(pk): try: note = Note.get(Note.id == pk) except Note.DoesNotExist: abort(404) note.delete_instance() note.save() return redirect(url_for('homepage'))
def edit_note(nid): try: note = Note.get(Note.id == nid) except Note.DoesNotExist: flask.abort(404) categories = utils.categories(nid=nid) return flask.render_template("edit.html", note=note, categories=categories)
def archive_note(pk): try: note = Note.get(Note.id == pk) except Note.DoesNotExist: abort(404) note.archived = True note.save() return redirect(url_for('homepage'))
def archive_note(pk): user = get_current_user() try: note = Note.get(Note.id == pk, Note.user==user) except Note.DoesNotExist: abort(404) note.archived = True note.save() return jsonify({'success': True})
def delete_note(nid): try: note = Note.get(Note.id == nid) except Note.DoesNotExist: flask.abort(404) note.delete_instance() if FTSNote.select().where(FTSNote.docid == note.id).exists(): FTSNote.get(FTSNote.docid == note.id).delete_instance() return flask.redirect(flask.url_for("index"))
def edit_note(pk): try: note = Note.get(Note.id == pk) except Note.DoesNotExist: abort(404) if request.method == 'POST': if request.form.get('content'): note.content = request.form.get('content') note.save() flash('Entry edited') return redirect(url_for('homepage')) return render_template('edit.html', note=note)
def update_note(pk): if request.method == 'POST': if request.form.get('updated_parts'): query = Note.update(content=request.form['updated_parts']).where( Note.id == pk) query.execute() return redirect(url_for('homepage')) try: note = Note.get(Note.id == pk) except Note.DoesNotExist: abort(404) return render_template('update.html', note=note)
def save_note(nid): form = dict(flask.request.form) title = form.pop("note-title", [""]) content = form.pop("note-content", [""]) form.pop("categories-input") categories = form Note.update( title=title[0], content=content[0], ).where(Note.id == nid).execute() FTSNote.store_note(Note.get(Note.id == nid)) NoteCategory.delete().where(NoteCategory.note == nid).execute() for category in list(categories): cid = int(re.match("category:([0-9]*)", category).group(1)) NoteCategory.create(note=nid, category=cid) return flask.redirect(flask.url_for("index"))