コード例 #1
0
ファイル: controllers.py プロジェクト: seyisulu/kolore
def add_post():
    """
    Create a new post
    """
    if request.method == 'POST':

        # Create New Blog Post Object
        blog_post = BlogPost(title=request.form['title'],
                             text=request.form['text'],
                             author=users.get_current_user(),
                             url=clean_url(request.form['title']))

        # Create New Blog Post Categories
        post_categories = request.form['categories'].split(",")
        blog_post.categories = BlogCategory.add_categories(post_categories)

        # Save the new post
        blog_post.put()

        # Redirect
        sleep(1)
        return redirect(url_for('admin.posts'))
    # GET
    return render_template('blog/admin-posts-add.html',
                           categories=BlogCategory.query_all())
コード例 #2
0
ファイル: controllers.py プロジェクト: alvaroabascar/kolore
def add_post():
    """
    Create a new post
    """
    if request.method == 'POST':

        # Create New Blog Post Object
        blog_post = BlogPost(title=request.form['title'],
                             text=request.form['text'],
                             author=users.get_current_user(),
                             url=clean_url(request.form['title']))

        # Create New Blog Post Categories
        post_categories = request.form['categories'].split(",")
        blog_post.categories = BlogCategory.add_categories(post_categories)

        # Save the new post
        blog_post.put()

        # Redirect
        sleep(1)
        return redirect(url_for('admin.posts'))
    # GET
    return render_template('blog/admin-posts-add.html',
                           categories=BlogCategory.query_all())
コード例 #3
0
ファイル: controllers.py プロジェクト: gitter-badger/kolore
def edit_post(post_id):
    '''Edit posts'''
    if request.method == 'POST':

        # Retrieve the object
        blog_post = ndb.Key('BlogPost', int(post_id)).get()

        # Update the values
        blog_post.title = request.form['title']
        blog_post.text = request.form['text']
        post_categories = request.form['categories'].split(",")
        blog_post.categories = BlogCategory.add_categories(post_categories)

        # Save the new post
        blog_post.put()

        # Redirect
        time.sleep(1)
        return redirect(url_for('admin.posts'))

    return render_template('posts-edit.html',
                           post=ndb.Key('BlogPost', int(post_id)).get(),
                           categories=BlogCategory.query_all())
コード例 #4
0
ファイル: controllers.py プロジェクト: seyisulu/kolore
def edit_post(post_id):
    """Edit posts"""
    if request.method == 'POST':

        # Retrieve the object
        blog_post = ndb.Key('BlogPost', int(post_id)).get()

        # Update the values
        blog_post.title = request.form['title']
        blog_post.text = request.form['text']
        post_categories = request.form['categories'].split(",")
        blog_post.categories = BlogCategory.add_categories(post_categories)

        # Save the new post
        blog_post.put()
        logging.info("Edit post : {}".format(post_id))
        # Redirect
        sleep(1)

        return redirect(url_for('admin.posts'))
    return render_template('blog/admin-posts-edit.html',
                           post=ndb.Key(BlogPost, int(post_id)).get(),
                           categories=BlogCategory.query_all())