Пример #1
0
 def do_something(self):
     try:
         flag = self.check_request_type('get')
         if not flag:
             raise Exception('Request type error')
         is_admin = self.check_admin()
         urls = self.get_url_parts()
         #print urls
         groupcode, pagenum = self.get_url_values(urls)
         if not groupcode.isdigit():
             groupcode = None
         page = int(pagenum)
         '''获取笔记组信息'''
         group_infos = MysqlHandler.select_group_info(is_admin)
         skip = ShowBlogNum * (page - 1)
         '''`CategoryCode`,`Subject`,`FileName`,`AddTime`,`Id`,`Views`'''
         '''获取笔记索引列表信息'''
         blogs_info = MysqlHandler.select_blogs_info(
             groupcode, skip, is_admin)
         blogs_index = self.get_blog_index(blogs_info)
         allnum = MysqlHandler.get_group_num(groupcode)
         pagenum = int(math.ceil(float(allnum) / ShowBlogNum))
         self.render('index.html',
                     GroupInfos=group_infos,
                     BlogIndexs=blogs_index,
                     IsAdmin=is_admin,
                     AllPageNum=pagenum,
                     NowPage=page,
                     GroupCode=groupcode)
     except:
         get_err_msg()
         self.render('error.html',
                     message='Something wrong with the server.')
Пример #2
0
 def do_something(self):
     try:
         flag = self.check_request_type('get')
         if not flag:
             raise Exception('Request type error')
         is_admin = self.check_admin()
         if not is_admin:
             raise Exception('No permission error')
         urls = self.get_url_parts()
         BlogId = self.get_url_values(urls)
         info = MysqlHandler.select_blog_info(BlogId, is_admin)
         group_infos = MysqlHandler.select_group_info(is_admin)
         GroupCode = info[0]
         Subject = info[1]
         FileName = info[2]
         datetime = info[3]
         Privacy = info[5]
         if Privacy == 0:
             Privacy = False
         PostUrl = '/uploadblog?blogId=%s&filename=%s' % (BlogId, FileName)
         Content = self.get_file_content(FileName)
         self.render('createBlog.html',
                     datetime=datetime,
                     Check=GroupCode,
                     Privacy=Privacy,
                     Subject=Subject,
                     Content=Content,
                     PostUrl=PostUrl,
                     GroupInfos=group_infos,
                     IsAdmin=is_admin)
     except:
         get_err_msg()
         self.render('error.html',
                     message='Something wrong with the server.')
Пример #3
0
 def do_something(self):
     try:
         flag = self.check_request_type('post')
         if not flag:
             raise Exception('Request type error')
         is_admin = self.check_admin()
         if not is_admin:
             raise Exception('No permission error')
         content = self.get_argument('message')
         MysqlHandler.upload_about(content)
         self.redirect('/setting')
     except:
         get_err_msg()
         self.render('error.html',message = 'Something wrong with the server.')
Пример #4
0
 def do_something(self):
     try:
         flag = self.check_request_type('get')
         if not flag:
             raise Exception('Request type error')
         is_admin = self.check_admin()
         if not is_admin:
             raise Exception('No permission error')
         groupid = self.get_argument('groupid')
         MysqlHandler.delete_group(groupid)
         self.write('true')
     except:
         get_err_msg()
         self.render('error.html',message = 'Something wrong with the server.')
Пример #5
0
 def do_something(self):
     try:
         flag = self.check_request_type('get')
         if not flag:
             raise Exception('Request type error')
         is_admin = self.check_admin()
         if not is_admin:
             raise Exception('No permission error')
         groupname = self.get_argument('groupname')
         MysqlHandler.add_group(groupname)
         self.redirect('/setting')
     except:
         get_err_msg()
         self.render('error.html',message = 'Something wrong with the server.')
Пример #6
0
 def do_something(self):
     try:
         flag = self.check_request_type('get')
         if not flag:
             raise Exception('Request type error')
         is_admin = self.check_admin()
         if not is_admin:
             raise Exception('No permission error')
         GroupInfos = MysqlHandler.select_group_info(is_admin)
         Message = MysqlHandler.get_about()
         self.render('setting.html',GroupInfos = GroupInfos,AboutInfo = Message,IsAdmin = is_admin)
     except:
         get_err_msg()
         self.render('error.html',message = 'Something wrong with the server.')
Пример #7
0
 def do_something(self):
     try:
         flag = self.check_request_type('get')
         if not flag:
             raise Exception('Request type error')
         is_admin = self.check_admin()
         if not is_admin:
             raise Exception('No permission error')
         urls = self.get_url_parts()
         BlogId = self.get_url_values(urls)
         MysqlHandler.del_blog(BlogId)
         self.redirect('/')
     except:
         get_err_msg()
         self.render('error.html',
                     message='Something wrong with the server.')
Пример #8
0
 def do_something(self):
     try:
         flag = self.check_request_type('get')
         if not flag:
             raise Exception('Request type error')
         is_admin = self.check_admin()
         Message = MysqlHandler.get_about()
         self.render('about.html',Message = Message,IsAdmin = is_admin)
     except:
         get_err_msg()
         self.render('error.html',message = 'Something wrong with the server.')
Пример #9
0
 def do_something(self):
     try:
         flag = self.check_request_type('get')
         if not flag:
             raise Exception('Request type error')
         is_admin = self.check_admin()
         urls = self.get_url_parts()
         blogId = self.get_url_values(urls)
         info = MysqlHandler.select_blog_info(blogId, is_admin)
         if info:
             GroupCode = info[0]
             Subject = info[1]
             FileName = info[2]
             datetime = info[3]
             Views = info[4]
             Privacy = info[5]
         else:
             self.redirect('/')
             return
         group_infos = MysqlHandler.select_group_info(is_admin)
         lastpagenum, lasttitle = MysqlHandler.get_last_next_blog_info(
             blogId, GroupCode, IsLast=True)
         nextpagenum, nexttitle = MysqlHandler.get_last_next_blog_info(
             blogId, GroupCode, IsLast=False)
         blogdata = self.get_file_content(FileName)
         blogInfo = [Subject, datetime, blogdata, Views]
         self.render('blog.html',
                     BlogInfo=blogInfo,
                     GroupInfos=group_infos,
                     BlogId=blogId,
                     IsAdmin=is_admin,
                     lastpagenum=lastpagenum,
                     lasttitle=lasttitle,
                     nextpagenum=nextpagenum,
                     nexttitle=nexttitle,
                     Privacy=Privacy)
     except:
         get_err_msg()
         self.render('error.html',
                     message='Something wrong with the server.')
Пример #10
0
 def do_something(self):
     try:
         flag = self.check_request_type('post')
         if not flag:
             raise Exception('Request type error')
         is_admin = self.check_admin()
         if not is_admin:
             raise Exception('No permission error')
         username = self.get_current_user()
         groupcode = self.get_argument('category')
         subject = self.get_argument('subject')
         message = self.get_argument('message')
         privacy = self.get_argument('privacy')
         FileName = self.save_file(message)
         Addtime = time.strftime("%Y-%m-%d %H:%M:%S")
         MysqlHandler.insertdata(subject, username, Addtime, FileName,
                                 groupcode, privacy)
         self.redirect('/')
     except:
         get_err_msg()
         self.render('error.html',
                     message='Something wrong with the server.')
Пример #11
0
 def do_something(self):
     try:
         flag = self.check_request_type('post')
         if not flag:
             raise Exception('Request type error')
         is_admin = self.check_admin()
         if not is_admin:
             raise Exception('No permission error')
         blogId = self.get_argument('blogId')
         filename = self.get_argument('filename')
         groupcode = self.get_argument('category')
         subject = self.get_argument('subject')
         message = self.get_argument('message')
         privacy = self.get_argument('privacy')
         self.save_file(message, filename)
         UpdateTime = time.strftime("%Y-%m-%d %H:%M:%S")
         MysqlHandler.updatablog(subject, UpdateTime, groupcode, blogId,
                                 privacy)
         self.redirect('/')
     except:
         get_err_msg()
         self.render('error.html',
                     message='Something wrong with the server.')
Пример #12
0
 def do_something(self):
     try:
         flag = self.check_request_type('get')
         if not flag:
             raise Exception('Request type error')
         is_admin = self.check_admin()
         if not is_admin:
             raise Exception('No permission error')
         group_infos = MysqlHandler.select_group_info(is_admin)
         datetime = time.strftime("%Y-%m-%d %H:%M:%S")
         self.render('createBlog.html',
                     datetime=datetime,
                     Check='0',
                     Privacy=0,
                     Subject='',
                     Content='',
                     PostUrl='/saveblog',
                     GroupInfos=group_infos,
                     IsAdmin=is_admin)
     except:
         get_err_msg()
         self.render('error.html',
                     message='Something wrong with the server.')
Пример #13
0
 def do_something(self):
     try:
         flag = self.check_request_type('post')
         if not flag:
             raise Exception('Request type error')
         username = self.get_argument('username')
         username = username.strip()
         password = self.get_argument('password')
         password = password.strip()
         flag = MysqlHandler.checkuser(username, password)
         if flag:
             self.set_secure_cookie("username",
                                    self.get_argument("username"))
             self.redirect('/')
         else:
             self.render("login.html",
                         username=username,
                         password="",
                         message=u"用户名或密码错误",
                         IsAdmin=False)
     except:
         get_err_msg()
         self.render('error.html',
                     message='Something wrong with the server.')