def recommendBook(): if 'admin' not in current_user.roles or not session['ids_list']: flash(u'Bu sayfaya erişim izniniz yok.', 'warning') return redirect(url_for('index')) form = RecommendBookForm(request.form) if form.validate_on_submit(): ids = session['ids_list'] for user_id in ids: dao.associateBookWithUser(form.book.data, user_id, Status.recommended) dao.commit() #session['ids_list'] = None flash(u'Kitap önerme tamamlandı.', 'info') return render_template('recommend_book.html', form=form)
def addBookToUser(): book_id = request.args.get("book_id") status = request.args.get("status") assoc = dao.findUserBook(current_user.id, book_id) if assoc is not None and assoc.status == Status.removed: dao.updateAssocStatus(book_id, current_user.id, None, status) dao.commit() else: if dao.associateBookWithUser(book_id, current_user.id, status): dao.commit() else: flash("Bu kitap zaten listenizde!", 'warning') return redirect(url_for('index'))