예제 #1
0
def blog_edit(blog_id):
    """Takes a blog id and edits that blog"""

    blog = UserBlog()
    child_blog = blog.get_blog(blog_id)

    if not child_blog:
        abort(404)

    form = BlogForm(
        obj=child_blog
    )  # populate the blog form with details from the child blog object

    if form.validate_on_submit():

        blog_data = _get_updated_data(form, child_blog)

        if blog_data:
            child_blog.update_blog(data=blog_data)
            Message.display_to_gui_screen(
                "You have successfully updated your blog.")
            return redirect(
                url_for("blogs_app.my_blog", blog_id=child_blog.child_blog_id))

    return render_template("blogs/blog.html",
                           form=form,
                           child_blog=child_blog,
                           edit_blog=True)
예제 #2
0
def blog_delete(blog_id):
    """Deletes a blog using its blog_id"""

    blog = UserBlog()
    child_blog = blog.get_blog(blog_id)
    child_blog.delete_blog()
    Message.display_to_gui_screen("One of your blogs was deleted successfully")
    return redirect(url_for("blogs_app.blog"))
예제 #3
0
def _get_blog(blog_id):
    """"""
    blog = UserBlog()
    return blog.get_blog(blog_id)