def post(self, *args): did = self.get_argument('did') _id = self.get_argument('cid') try: Comment.del_comment(did, _id) except Exception as e: print str(e)
def get(self): # OAth2 for douban KEY = conf['douban_app_key'] SECRET = conf['douban_app_secret'] CALLBACK = conf['url'] + '/dback' SCOPE = 'douban_basic_common,community_basic_user,community_basic_note' client = DoubanClient(KEY, SECRET, CALLBACK, SCOPE) douban_login = client.authorize_url # OAth2 for sina_weibo APP_KEY = conf['weibo_app_key'] APP_SECRET = conf['weibo_app_secret'] CALLBACK_URL = conf['url'] + '/wback' weibo_client = APIClient(app_key=APP_KEY, app_secret=APP_SECRET, redirect_uri=CALLBACK_URL) weibo_login = weibo_client.get_authorize_url() # statistics diary_count = Diary.get_diary_count() last_diary = Diary.get_last_diary() first_diary = Diary.get_first_diary() comment_count = Comment.get_comment_count() usr = tornado.escape.xhtml_escape(self.current_user) site_start = Admin.find_by_username(usr).get('site_start') self.render('Admin/dashboard.html', douban_login=douban_login, diary_count=diary_count, last_diary=last_diary, first_diary=first_diary, site_start=site_start, comment_count=comment_count, weibo_login=weibo_login )
def post(self, *args): try: did = self.get_argument('did') user = self.get_argument('username') email = self.get_argument('email') comment = self.get_argument('comment') except Exception as e: print str(e) Comment.save(did, user, email, comment) self.set_secure_cookie("guest_name", user) self.set_secure_cookie("guest_email", email) try: send_mail(conf['email'], conf['title']+'收到了新的评论, 请查收', comment, did, user) self.write('success') except Exception as e: print str(e)
def post(self, *args): did = self.get_argument('did') cid = self.get_argument('cid') receiver = self.get_argument('email') title = self.get_argument('title') content = self.get_argument('content') user = self.get_argument('user') try: Comment.reply(did, cid, content) except Exception as e: print str(e) try: send_mail(receiver, u'您评论的文章《'+title+u'》收到了来自博主的回复, 请查收', content, did, user) self.write('success') except Exception as e: print str(e)
def get(self, page): try: comments = Comment.get(page) except Exception as e: print str(e) number = comments.count(with_limit_and_skip=True) if number == 15: next_page = True elif number < 1: self.send_error(404) return else: next_page = False self.render('Admin/Comment/index.html', comments=comments, page=page, next_page=next_page)