def comment(u, cid): if current_user.is_anonymous(): abort(403) try: comic = get_comic_query(u).filter_by(id=cid).one() except NoResultFound: abort(404) form = CommentForm() if form.validate_on_submit(): if form.anonymous.data: name = "Anonymous" else: name = current_user.username post = Post(name, form.comment.data, "", None) post.thread = comic.thread image = form.datafile.file if image: post.filename = chan_filename(image) save_file(post.fp(), image) db.session.add(post) db.session.commit() return redirect(url_for_comic(comic))
def characters_modify(u, c): form = ModifyCharacterForm(prefix="modify") if form.validate_on_submit(): # Which modifications do we want to make? db.session.add(c) if form.name.data and form.name.data != c.name: c.rename(form.name.data) flash("Successfully renamed character %s!" % c.name) c.major = form.major.data if form.portrait.file: if save_file(c.fp(), form.portrait.file): flash("Successfully changed portrait for character %s!" % c.name) else: flash("Couldn't save portrait for character %s..." % c.name) if form.description.data != c.description: if form.description.data: c.description = form.description.data else: c.description = None flash("Successfully changed description for character %s!" % c.name) db.session.commit() else: flash("Couldn't validate form...") return redirect(url_for("admin.character", u=u, c=c))
def characters_create(u): form = CreateCharacterForm() if form.validate_on_submit(): character = Character(u, form.name.data) character.major = form.major.data if form.description.data: character.description = form.description.data db.session.add(character) db.session.commit() if form.portrait.data: save_file(character.fp(), form.portrait.data) flash("Successfully created character %s!" % character.name) else: flash("Couldn't validate form...") return redirect(url_for("admin.characters", u=u))
comic.description = form.description.data comic.comment = form.comment.data comic.thread = Thread(u.board, comic.title, "DCoN") if form.time.data: comic.time = form.time.data if form.index.data != -2: comic.insert(reference, before) else: comic.position = 0 db.session.add(comic) db.session.commit() save_file(comic.fp(), form.file.data) return redirect(url_for("admin.comics_modify", u=u, cid=comic.id)) return render_template("upload.html", form=form, u=u) @admin.route("/<universe:u>/comics/<int:cid>/modify", methods=("GET", "POST")) def comics_modify(u, cid): try: comic = Comic.query.filter_by(id=cid).one() except NoResultFound: abort(404) form = ModifyComicForm(u) if form.validate_on_submit():
comic.description = form.description.data comic.comment = form.comment.data comic.thread = Thread(u.board, comic.title, "DCoN") if form.time.data: comic.time = form.time.data if form.index.data != -2: comic.insert(reference, before) else: comic.position = 0 db.session.add(comic) db.session.commit() save_file(comic.fp(), form.file.file) return redirect(url_for("admin.comics_modify", u=u, cid=comic.id)) return render_template("upload.html", form=form, u=u) @admin.route("/<universe:u>/comics/<int:cid>/modify", methods=("GET", "POST")) def comics_modify(u, cid): try: comic = Comic.query.filter_by(id=cid).one() except NoResultFound: abort(404) form = ModifyComicForm(u) if form.validate_on_submit():