Esempio n. 1
0
def delete_comment(id=None):
    form = DeleteCommentForm()

    post_id = request.args.get("id")
    if form.validate_on_submit():
        comment = Comment.query.get(id)
        if checkph(comment.hash_password, form.password.data):
            post = Post.query.get(post_id)
            post.total_comments -= 1
            db.session.delete(comment)
            db.session.commit()

            return redirect(url_for('routes.view', id=post_id))
            # Ahora debería guardar el catalogo del negocio en la db
        else:
            return redirect(
                url_for('routes.output', msg="""Contraseña errónea, bro."""))

    return render_template('user/delete.html', form=form)