Exemplo n.º 1
0
def deletePost(appkey, postid, username, password, publish):
    if not verify_user(username, password):
        raise Fault("invalid_user", "Invalid username/password, " \
            "please try again.")
    post = g.conn.flog.blog.BlogPost.find_one({'slug': postid})
    post.delete()
    pass
Exemplo n.º 2
0
def getCategories(blogid, username, password):
    if not verify_user(username, password):
        raise Fault("invalid_user", "Invalid username/password, please" \
            "try again.")
    tags = filter(bool, g.conn.flog.blog.find().distinct('tags'))
    response = []
    for tag in tags:
        response.append({'description': tag})
    return response
Exemplo n.º 3
0
def newPost(blogid, username, password, content, publish):
    if not verify_user(username, password):
        raise Fault("invalid_user", "Invalid username/password, please " \
            "try again.")
    post = g.conn.flog.blog.BlogPost()
    post['title'] = unicode(content['title'])
    post['body'] = unicode(content['description'])
    if 'categories' in content.keys():
        post['tags'] = content['categories']
    post.save()
    return post['slug']
Exemplo n.º 4
0
def editPost(postid, username, password, content, publish):
    if not verify_user(username, password):
        raise Fault("invalid_user", "Invalid username/password, " \
            "please try again.")
    post = g.conn.flog.blog.BlogPost.find_one({'slug': postid})
    post['title'] = unicode(content['title'])
    post['body'] = unicode(content['description'])
    if 'categories' in content.keys():
        post['tags'] = content['categories']
    else:
        post['tags'] = []
    post.save()
    return True
Exemplo n.º 5
0
def getPost(postid, username, password):
    if not verify_user(username, password):
        raise Fault("invalid_user", "Invalid username/password, " \
            "please try again.")
    post = g.conn.flog.blog.BlogPost.find_one({'slug': postid})
    if not post:
        raise Fault("not_found", "Post not found.")
    post['tags'] = filter(bool, post['tags'])
    item = {}
    item['title'] = post['title']
    item['link'] = ''.join(['http://www.flog.com/', post['slug']])
    item['description'] = post['body']
    item['postid'] = post['slug']
    item['categories'] = post['tags']
    item['dateCreated'] = post['date_created']
    if post['draft']:
        item['draft'] = 'Yes'
    return item
Exemplo n.º 6
0
def getRecentPosts(blogid, username, password, numberOfPosts):
    if not verify_user(username, password):
        raise Fault("invalid_user", "Invalid username/password, please " \
            "try again.")
    criteria = {}
    posts = list(g.conn.flog.blog.find(criteria).sort(
        "date_created", ASCENDING))
    response = []
    for post in posts:
        item = {}
        item['title'] = post['title']
        item['link'] = ''.join(['http://www.flog.com/', post['slug']])
        item['description'] = post['body']
        item['postid'] = post['slug']
        item['categories'] = post['tags']
        item['dateCreated'] = post['date_created']
        if post['draft']:
            item['draft'] = 'Yes'
        response.append(item)
    return response