示例#1
0
文件: __init__.py 项目: Ardroid/spm
def add_comment(key, author, content):
  comment = Content(title=content["title"], content=content["content"], author=author)
  update = Content.get(key, bucket="spm_posts")
  update.comments.append(comment)
  comment.save(bucket="spm_comments")
  update.save(bucket="spm_posts")
  return comment
示例#2
0
文件: __init__.py 项目: Ardroid/spm
def post_update(author, content):
  update = Content(title=content["title"], content=content["content"], author=author)
  update.save(bucket="spm_posts")
  return update
示例#3
0
文件: __init__.py 项目: Ardroid/spm
def del_comment(key, content):
  comment = Content.get(key, bucket="spm_comments")
  comment.delete()
示例#4
0
文件: __init__.py 项目: Ardroid/spm
def edit_comment(key, content):
  comment = Content.get(key, bucket="spm_comments")
  comment.title = content["title"]
  comment.content = content["content"]
  comment.save(bucket="spm_comments")
  return comment
示例#5
0
文件: __init__.py 项目: Ardroid/spm
def del_update(key):
  update = Content.get(key, bucket="spm_posts")
  for comment in update.comments:
    comment.delete()

  update.delete()
示例#6
0
文件: __init__.py 项目: Ardroid/spm
def edit_update(key, content):
  update = Content.get(key, bucket="spm_posts")
  update.title = content["title"]
  update.content = content["content"]
  update.save(bucket="spm_posts")
  return update
示例#7
0
文件: projects.py 项目: shuhaowu/spm
def get_wall_post(key):
  return Content.get(key, bucket="spm_wallposts")
示例#8
0
文件: projects.py 项目: shuhaowu/spm
def get_all_posts_from_project(key):
  post_queries = Content.indexLookup("project_bin", key, bucket="spm_wallposts")
  posts = []
  for post in post_queries.run():
    posts.append(wall_post_to_display_json(post))
  return sorted(posts, key=lambda x: x["pubdate"])[:50] # TODO: pagination? lol? delete old items? wut
示例#9
0
文件: projects.py 项目: shuhaowu/spm
def add_wall_post(key, content, user):
  post = Content(title=content, author=user)
  post.addIndex("project_bin", key)
  post.save(bucket="spm_wallposts")
  return post