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 purge(): current_app.logger.info('backup %s' % current_app.config["SQLALCHEMY_DATABASE_URI"][10:]) now = datetime.datetime.now().strftime("%Y%m%d%H%M%S") copyfile(current_app.config["SQLALCHEMY_DATABASE_URI"][10:], current_app.config["SQLALCHEMY_DATABASE_URI"][10:] + '.' + now) notes = Note.all() for note in notes: note.remove() books = Book.all() for book in books: book.remove() return redirect('/up')
def create(): idbook = request.form['idbook'] iduser = request.form['iduser'] note = Note.query.filter_by(idbook=idbook, iduser=iduser).first() if note is None: note = Note(idbook=idbook, iduser=iduser) note.checked = getBool.get(request.form.get('checked','off'),False) note.note = request.form['note'] note.description = request.form['description'] note.save() flash('Note is created', 'success') return redirect(url_for('note.view_note', id=note.id))
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 wizardnotecreate(): idbook = request.form['idbook'] iduser = request.form['iduser'] note = Note.query.filter_by(idbook=idbook, iduser=iduser).first() if note is None: note = Note(idbook=idbook, iduser=iduser) note.note = request.form['note'] note.description = request.form['description'] note.save() flash('Note is created', 'success') return redirect(url_for('home'))
def create_user_note(db: Session, note: NoteCreate): db_item = Note(**note.dict()) db.add(db_item) db.commit() db.refresh(db_item) return db_item
def listing(): return render_template("notes.html", notes=sorted(Note.all(), key=lambda note: note.book.idext))
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'))
def new(): return render_template('note.html', note=Note(), users=User.all(sortby=User.name), books=Book.all(sortby=Book.title), notation=NOTATION)