Exemplo n.º 1
0
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'))
Exemplo n.º 2
0
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')
Exemplo n.º 3
0
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))
Exemplo n.º 4
0
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'))
Exemplo n.º 5
0
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'))
Exemplo n.º 6
0
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
Exemplo n.º 7
0
def listing():
    return render_template("notes.html", notes=sorted(Note.all(), key=lambda note: note.book.idext))
Exemplo n.º 8
0
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'))
Exemplo n.º 9
0
def new():
    return render_template('note.html', note=Note(), users=User.all(sortby=User.name), books=Book.all(sortby=Book.title), notation=NOTATION)