예제 #1
0
def book_return():
    log_id = request.args.get('log_id')
    book_id = request.args.get('book_id')
    the_log = None
    if log_id:
        the_log = Log.query.get(log_id)
    if book_id:
        the_log = Log.query.filter_by(user_id=current_user.id, book_id=book_id).first()
    if log is None:
        flash(u'没有找到这条记录', 'warning')
    else:
        result, message = current_user.return_book(the_log)
        flash(message, 'success' if result else 'danger')
        db.session.commit()
    return redirect(request.args.get('next') or url_for('book.detail', book_id=log_id))
예제 #2
0
def book_return():
    log_id = request.args.get('log_id')
    book_id = request.args.get('book_id')
    the_log = None
    if log_id:
        the_log = Log.query.get(log_id)
    if book_id:
        the_log = Log.query.filter_by(user_id=current_user.id, book_id=book_id).first()
    if log is None:
        flash(u'Did not find this record', 'warning')
    else:
        result, message = current_user.return_book(the_log)
        flash(message, 'success' if result else 'danger')
        db.session.commit()
    return redirect(request.args.get('next') or url_for('book.detail', book_id=log_id))
예제 #3
0
def book_return():
    log_id = request.args.get('log_id')
    book_id = request.args.get('book_id')
    the_log = None
    if log_id:
        the_log = Log.query.get(log_id)
    if book_id:
        the_log = Log.query.filter_by(user_id=current_user.id,
                                      book_id=book_id).first()
    if log is None:
        flash(u'Não tem este registro!!', 'Aviso')
    else:
        result, message = current_user.return_book(the_log)
        flash(message, 'Sucesso' if result else 'Perigo')
        db.session.commit()
    return redirect(
        request.args.get('next') or url_for('book.detail', book_id=log_id))