def POST(self, arg): data = web.input() postImage = data.post_Img postTitle = data.post_Name postCaption = data.post_Caption postArticle = data.post_Article postAuthor = user.id postTemp = data.temp nodeId = data.nodeID #入库 postModel.newPost(postImage, postTitle, postCaption, postArticle, postAuthor, postTemp, nodeId) #得到最新创建的post thisPost = postModel.getThisPostByUserId(postAuthor) node = nodeModel.getNodeByNodeId(nodeId) nodeAuthor = users.get_user_by_id(node.node_author) #判断是不是在自己创建的话题中发布片段 if nodeAuthor.id != int(postAuthor): #如果开启了邮件提醒,给此片段所属话题的作者发送邮件 person = users.get_profile_by_user_id(node.node_author) if person.has_key('email_subscribe') and person.email_subscribe == 1 and nodeAuthor.email: email_templates.someone_creat_new_post(user, nodeAuthor, node, thisPost) print '=== email send ==' #插入提醒 notification.new_notification(node.node_author, user.id, thisPost.id, nodeId, tp=4) return '{"post_id":'+ str(thisPost.id)+ ',"status":"y"}'
def GET(self, arg, p=1): node = nodeModel.getNodeByNodeId(arg) if node: timestrf = misc.timestrf page = int(p) perpage = 10 offset = (page - 1) * perpage node_author_info = users.get_user_by_id(node.node_author) postList = postModel.getPostListByNodeIdSortByScore(arg, offset, perpage).list() a = [] for post in postList: a += str(post.postAuthor).split() authors = [] for i in xrange(len(a)): authors += users.get_users_by_id(a[i]) #得到权限 if user.is_logged: per = users.get_permission_by_douid(user.douban_id) rights = per[0].rights #得到提醒 notification_results, notification_num = notification.get_unread_notification(user.id) #得到@提醒 notification_mention_results, mention_num= notification.get_unread_metion_notifition(user.id) #链表 得到提醒的详细id\名称等 ntf_posts = [] ntf_users = [] mtf_posts = [] mtf_users = [] ntf_list = notification_results.list() mtf_list = notification_mention_results.list() for x in xrange(len(ntf_list)): ntf_posts += postModel.getPostsByPostId(ntf_list[x].pid) ntf_users += users.get_users_by_id(ntf_list[x].uid) for x in xrange(len(mtf_list)): mtf_posts += postModel.getPostsByPostId(mtf_list[x].pid) mtf_users += users.get_users_by_id(mtf_list[x].uid) ntf_list = ntf_list + mtf_list ntf_posts = ntf_posts + mtf_posts ntf_users = ntf_users + mtf_users notification_num = notification_num+mention_num else: rights = 0 notification_results = None notification_num = None ntf_list = None ntf_posts = None ntf_users = None return view.base(view.node_show(timestrf, rights, node, postList, node_author_info, user, authors, sort='interesting'), user, siteName, rights, ntf_list, notification_num, ntf_posts, ntf_users) else: raise web.notfound()
def GET(self, nodeId): date = datetime.datetime.today().strftime( "%a, %d %b %Y %H:%M:%S +0200") node = nodeModel.getNodeByNodeId(nodeId) posts = list( db.select("_post", order="id DESC", limit=10, vars=dict(nodeId=nodeId), where='nodeId = $nodeId')) authors = [] for i in xrange(len(posts)): authors += users.get_users_by_id(posts[i].postAuthor) nodes = [] for i in xrange(len(posts)): nodes += nodeModel.getNodesByNodeId(posts[i].nodeId) feed_url = "http://www.biubiubiubiu.com/'+ nodeId +'feed" ishome = False web.header('Content-Type', 'application/xml') return view.feed_index(node, posts, date, authors, nodes, feed_url, ishome)
def POST(self): s = web.input() x = s.d nid = s.nid #安全起见,判断是不是话题作者本人 if nid != 'new' and user.id == nodeModel.getNodeByNodeId( nid).node_author: #删除硬盘中的图片文件 homedir = os.getcwd() imgPath = homedir + x os.remove(imgPath) nodeImg = imgPath print 'Image Deleted' #更新数据库 nodeModel.nodeUpdate(nid, nodeImg=None) success = "s" return success #new 是创建新话题时,那时没有nid elif nid == 'new': #更新数据库 nodeModel.nodeUpdate(nid, nodeImg=None) success = "s" return success
def GET(self, arg): per = users.get_permission_by_douid(user.douban_id) rights = per[0].rights if rights > 0: #权限判断 node = nodeModel.getNodeByNodeId(arg) if node: return view.base(view.post_new(arg, node, user), user, siteName, rights, ntf_list=None, notification_num=None, ntf_posts=None, ntf_users=None) else: raise web.notfound() else: raise web.notfound()
def POST(self): s = web.input() x = s.d nid = s.nid if user.id == nodeModel.getNodeByNodeId(nid).node_author: #删除硬盘中的图片文件 homedir = os.getcwd() imgPath = homedir + x os.remove(imgPath) nodeImg = imgPath print 'Image Deleted' #更新数据库 nodeModel.nodeUpdate(nid, nodeImg=None) success = "s" return success
def GET(self, nodeId): date = datetime.datetime.today().strftime("%a, %d %b %Y %H:%M:%S +0200") node = nodeModel.getNodeByNodeId(nodeId) posts = list(db.select("_post", order="id DESC", limit=10, vars=dict(nodeId=nodeId), where='nodeId = $nodeId')) authors = [] for i in xrange(len(posts)): authors += users.get_users_by_id(posts[i].postAuthor) nodes = [] for i in xrange(len(posts)): nodes += nodeModel.getNodesByNodeId(posts[i].nodeId) feed_url="http://www.biubiubiubiu.com/'+ nodeId +'feed" ishome = False web.header('Content-Type', 'application/xml') return view.feed_index(node, posts, date, authors, nodes, feed_url, ishome)
def POST(self, arg): data = web.input() postImage = data.post_Img postTitle = data.post_Name postCaption = data.post_Caption postArticle = data.post_Article postAuthor = user.id postTemp = data.temp nodeId = data.nodeID #入库 postModel.newPost(postImage, postTitle, postCaption, postArticle, postAuthor, postTemp, nodeId) #得到最新创建的post thisPost = postModel.getThisPostByUserId(postAuthor) node = nodeModel.getNodeByNodeId(nodeId) nodeAuthor = users.get_user_by_id(node.node_author) #判断是不是在自己创建的话题中发布片段 if nodeAuthor.id != int(postAuthor): #如果开启了邮件提醒,给此片段所属话题的作者发送邮件 person = users.get_profile_by_user_id(node.node_author) if person.has_key( 'email_subscribe' ) and person.email_subscribe == 1 and nodeAuthor.email: email_templates.someone_creat_new_post(user, nodeAuthor, node, thisPost) print '=== email send ==' #插入提醒 notification.new_notification(node.node_author, user.id, thisPost.id, nodeId, tp=4) return '{"post_id":' + str(thisPost.id) + ',"status":"y"}'
def POST(self): s = web.input() x = s.d nid = s.nid #安全起见,判断是不是话题作者本人 if nid != 'new' and user.id == nodeModel.getNodeByNodeId(nid).node_author: #删除硬盘中的图片文件 homedir = os.getcwd() imgPath = homedir + x os.remove(imgPath) nodeImg = imgPath print 'Image Deleted' #更新数据库 nodeModel.nodeUpdate(nid, nodeImg=None) success = "s" return success #new 是创建新话题时,那时没有nid elif nid == 'new': #更新数据库 nodeModel.nodeUpdate(nid, nodeImg=None) success = "s" return success
def GET(self, arg, ntf_type=''): #ntf_type为提醒类型,用来让用户从提醒页面访问片段页面时可以看到对应提醒 post = postModel.getPostByPostId(arg) if post: post_author_info = users.get_user_by_id(post.postAuthor) node = nodeModel.getNodeByNodeId(post.nodeId) timestrf = misc.timestrf likers = postModel.get_voters_by_pid(post.id) likers_list = [] for i in xrange(len(likers)): likers_list += users.get_users_by_id(likers[i].uid) comments = postModel.get_comments_by_pid(post.id).list() commenters = [] for i in xrange(len(comments)): commenters += users.get_users_by_id(comments[i].uid) #是否登录, if user.is_logged: per = users.get_permission_by_douid(user.douban_id) rights = per[0].rights #是否投过票 is_voted = postModel.is_voted(arg, user.id) #得到提醒 notification_results, notification_num = notification.get_unread_notification( user.id) #得到@提醒 notification_mention_results, mention_num = notification.get_unread_metion_notifition( user.id) #链表 得到提醒的详细id\名称等 ntf_posts = [] ntf_users = [] mtf_posts = [] mtf_users = [] ntf_list = notification_results.list() mtf_list = notification_mention_results.list() for x in xrange(len(ntf_list)): ntf_posts += postModel.getPostsByPostId(ntf_list[x].pid) ntf_users += users.get_users_by_id(ntf_list[x].uid) for x in xrange(len(mtf_list)): mtf_posts += postModel.getPostsByPostId(mtf_list[x].pid) mtf_users += users.get_users_by_id(mtf_list[x].uid) #获取提醒页面传过来的提醒类型参数 ntf_type = web.input(ntf_type='').ntf_type ntf_list = ntf_list + mtf_list ntf_posts = ntf_posts + mtf_posts ntf_users = ntf_users + mtf_users notification_num = notification_num + mention_num else: rights = 0 is_voted = None notification_results = None notification_num = None ntf_list = None ntf_posts = None ntf_users = None return view.base( view.post_single(rights, node, post, post_author_info, user, timestrf, likers_list, comments, commenters, ntf_type, is_voted, misc), user, siteName, rights, ntf_list, notification_num, ntf_posts, ntf_users) else: raise web.notfound()
def GET(self, arg, ntf_type=''): #ntf_type为提醒类型,用来让用户从提醒页面访问片段页面时可以看到对应提醒 post = postModel.getPostByPostId(arg) if post: post_author_info = users.get_user_by_id(post.postAuthor) node = nodeModel.getNodeByNodeId(post.nodeId) timestrf = misc.timestrf likers = postModel.get_voters_by_pid(post.id) likers_list = [] for i in xrange(len(likers)): likers_list += users.get_users_by_id(likers[i].uid) comments = postModel.get_comments_by_pid(post.id).list() commenters = [] for i in xrange(len(comments)): commenters += users.get_users_by_id(comments[i].uid) #是否登录, if user.is_logged: per = users.get_permission_by_douid(user.douban_id) rights = per[0].rights #是否投过票 is_voted = postModel.is_voted(arg, user.id) #得到提醒 notification_results, notification_num = notification.get_unread_notification(user.id) #得到@提醒 notification_mention_results, mention_num= notification.get_unread_metion_notifition(user.id) #链表 得到提醒的详细id\名称等 ntf_posts = [] ntf_users = [] mtf_posts = [] mtf_users = [] ntf_list = notification_results.list() mtf_list = notification_mention_results.list() for x in xrange(len(ntf_list)): ntf_posts += postModel.getPostsByPostId(ntf_list[x].pid) ntf_users += users.get_users_by_id(ntf_list[x].uid) for x in xrange(len(mtf_list)): mtf_posts += postModel.getPostsByPostId(mtf_list[x].pid) mtf_users += users.get_users_by_id(mtf_list[x].uid) #获取提醒页面传过来的提醒类型参数 ntf_type = web.input(ntf_type='').ntf_type ntf_list = ntf_list + mtf_list ntf_posts = ntf_posts + mtf_posts ntf_users = ntf_users + mtf_users notification_num = notification_num+mention_num else: rights = 0 is_voted = None notification_results = None notification_num = None ntf_list = None ntf_posts = None ntf_users = None return view.base(view.post_single(rights, node, post, post_author_info, user, timestrf, likers_list, comments, commenters, ntf_type, is_voted, misc), user, siteName, rights, ntf_list, notification_num, ntf_posts, ntf_users) else: raise web.notfound()
def GET(self): rec_nodes = admin.get_rec_nodes() nodeList = [] for i in xrange(len(rec_nodes)): nodeList += nodeModel.getNodesByNodeId(rec_nodes[i].nid) a = [] for node in nodeList: a += str(node.node_author).split() authors = [] for i in xrange(len(a)): authors += users.get_users_by_id(a[i]) #得到最新的那个post lastest_posts = [] for i in xrange(len(nodeList)): #如果没有,去取node的创建时间 if postModel.getRecentOnePostsInNode(nodeList[i].id): lastest_posts += str(time.mktime(postModel.getRecentOnePostsInNode(nodeList[i].id).creation_ts.timetuple())).split() else: lastest_posts += str(time.mktime(nodeModel.getNodeByNodeId(nodeList[i].id).creation_ts.timetuple())).split() #得到当前用户的权限 if user.is_logged: per = users.get_permission_by_douid(user.douban_id) rights = per[0].rights if users.is_user_exist_in_apply_log(user.douban_id): #如果申请记录表中有此用户记录: apply_log = users.get_log_result(user.douban_id) else: apply_log = {} #得到提醒 notification_results, notification_num = notification.get_unread_notification(user.id) #得到@提醒 notification_mention_results, mention_num= notification.get_unread_metion_notifition(user.id) #链表 得到提醒的详细id\名称等 ntf_posts = [] ntf_users = [] mtf_posts = [] mtf_users = [] ntf_list = notification_results.list() mtf_list = notification_mention_results.list() for x in xrange(len(ntf_list)): ntf_posts += postModel.getPostsByPostId(ntf_list[x].pid) ntf_users += users.get_users_by_id(ntf_list[x].uid) for x in xrange(len(mtf_list)): mtf_posts += postModel.getPostsByPostId(mtf_list[x].pid) mtf_users += users.get_users_by_id(mtf_list[x].uid) ntf_list = ntf_list + mtf_list ntf_posts = ntf_posts + mtf_posts ntf_users = ntf_users + mtf_users notification_num = notification_num+mention_num else: rights = None notification_results = None notification_num = None ntf_list = None ntf_posts = None ntf_users = None apply_log = {} return view.base(view.recommend_nodes(nodeList, authors, user, rights, apply_log, lastest_posts, datetime), user, siteName, rights, ntf_list, notification_num, ntf_posts, ntf_users)
def GET(self): rec_nodes = admin.get_rec_nodes() nodeList = [] for i in xrange(len(rec_nodes)): nodeList += nodeModel.getNodesByNodeId(rec_nodes[i].nid) a = [] for node in nodeList: a += str(node.node_author).split() authors = [] for i in xrange(len(a)): authors += users.get_users_by_id(a[i]) #得到最新的那个post lastest_posts = [] for i in xrange(len(nodeList)): #如果没有,去取node的创建时间 if postModel.getRecentOnePostsInNode(nodeList[i].id): lastest_posts += str( time.mktime( postModel.getRecentOnePostsInNode( nodeList[i].id).creation_ts.timetuple())).split() else: lastest_posts += str( time.mktime( nodeModel.getNodeByNodeId( nodeList[i].id).creation_ts.timetuple())).split() #得到当前用户的权限 if user.is_logged: per = users.get_permission_by_douid(user.douban_id) rights = per[0].rights if users.is_user_exist_in_apply_log( user.douban_id): #如果申请记录表中有此用户记录: apply_log = users.get_log_result(user.douban_id) else: apply_log = {} #得到提醒 notification_results, notification_num = notification.get_unread_notification( user.id) #得到@提醒 notification_mention_results, mention_num = notification.get_unread_metion_notifition( user.id) #链表 得到提醒的详细id\名称等 ntf_posts = [] ntf_users = [] mtf_posts = [] mtf_users = [] ntf_list = notification_results.list() mtf_list = notification_mention_results.list() for x in xrange(len(ntf_list)): ntf_posts += postModel.getPostsByPostId(ntf_list[x].pid) ntf_users += users.get_users_by_id(ntf_list[x].uid) for x in xrange(len(mtf_list)): mtf_posts += postModel.getPostsByPostId(mtf_list[x].pid) mtf_users += users.get_users_by_id(mtf_list[x].uid) ntf_list = ntf_list + mtf_list ntf_posts = ntf_posts + mtf_posts ntf_users = ntf_users + mtf_users notification_num = notification_num + mention_num else: rights = None notification_results = None notification_num = None ntf_list = None ntf_posts = None ntf_users = None apply_log = {} return view.base( view.recommend_nodes(nodeList, authors, user, rights, apply_log, lastest_posts, datetime), user, siteName, rights, ntf_list, notification_num, ntf_posts, ntf_users)