def editSummary(assoc_id): assoc = dao.getObject(assoc_id, UserBook) if assoc is None or assoc not in current_user.book_assocs or assoc.status != Status.have_read or assoc.summary == None: flash(u'Var olmayan bir özeti güncelleyemezsiniz!', 'warning') return redirect(request.referrer or url_for('index')) form = WriteSummaryForm(request.form) if form.validate_on_submit(): assoc.summary.text = form.summary.data assoc.summary.time_last_modified = datetime.now() dao.commit() flash(u'Özet güncellendi!', 'info') return redirect(url_for('bookPage', book_id=assoc.book.id)) elif request.method == 'GET': form.summary.data = assoc.summary.text return render_template('write_summary.html', form=form)
def writeSummary(assoc_id): assoc = dao.getObject(assoc_id, UserBook) if assoc is None or assoc not in current_user.book_assocs or assoc.status != Status.have_read or assoc.summary != None: flash(u'Sadece okumuş olduğunuz kitaplar hakkında birer adet özet yazabilirsiniz!', 'warning') return redirect(request.referrer or url_for('index')) form = WriteSummaryForm(request.form) if form.validate_on_submit(): summary = Summary( text = form.summary.data, time_created = datetime.now(), time_last_modified = None, userbook = assoc ) dao.addObject(summary) dao.commit() flash(u'Özet yazıldı!', 'info') return redirect(url_for('bookPage', book_id=assoc.book.id)) return render_template('write_summary.html', form=form)