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
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
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']
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
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
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