Exemplo n.º 1
0
 def get_current_user(self):
     uInfo = self.session[SESSION_USER]
     if uInfo:
         user = AdminModel.mgr().Q().filter(userName=uInfo['userName'])[0]
         print user
         if not user:
             self._logout()
     print 'get_current_user:%s' % uInfo
     return uInfo
Exemplo n.º 2
0
 def get_current_user(self):
     uInfo = self.session[SESSION_USER];
     if uInfo:
         user = AdminModel.mgr().Q().filter(userName=uInfo['userName'])[0]
         print user
         if not user:
             self._logout()
     print 'get_current_user:%s'%uInfo
     return uInfo;
Exemplo n.º 3
0
 def check(self):
     userName = self.get_argument('userName', '').encode('utf-8')
     passWord = self.get_argument('passWord', '')
     sql = "select * from monitor_admin where userName='******' and passWord='******' and `group` in ('root','admin')" % (
         userName, passWord)
     admins = AdminModel.mgr().raw(sql)
     if len(admins) > 0:
         self._login(admins[0]['userName'])
         self.send_json({}, 0, '登陆成功')
     else:
         self.send_json({}, 1, '用户名或密码错误,登陆失败')
Exemplo n.º 4
0
 def check(self):
     userName = self.get_argument('userName', '').encode('utf-8')
     passWord = self.get_argument('passWord', '')
     sql = "select * from monitor_admin where userName='******' and passWord='******' and `group` in ('root','admin')" % (
         userName, passWord)
     admins = AdminModel.mgr().raw(sql)
     if len(admins) > 0:
         self._login(admins[0]['userName'])
         self.send_json({}, 0, '登陆成功')
     else:
         self.send_json({}, 1, '用户名或密码错误,登陆失败')
Exemplo n.º 5
0
 def admindelete(self):
     ids = str(self.get_argument('ids')).split(",")
     for id in ids:
         admins = AdminModel.mgr().Q().filter(id=id)
         if admins:
             for admin in admins:
                 if admin['userName'] != 'admin':
                     admin.delete()
     self.write(json.dumps({'statusCode': "200",
                            'callbackType': "forward",
                            'navTabId': "admin",
                            'forwardUrl': "/admin/adminlist"}))
Exemplo n.º 6
0
 def adminlist(self):
     # 列表的当前页,默认在第一页
     currentPage = int(self.get_argument('pageNum', 1))
     # 列表中每页显示多少条,默认每页显示20条
     numPerPage = int(self.get_argument('numPerPage', 20))
     print 'numPerPage : %s' % numPerPage;
     # 计算User的总数
     all = AdminModel.mgr().Q()
     totalCount = len(all)
     admins = all[(currentPage - 1) * numPerPage: currentPage * numPerPage]
     self.render('admin/list.html',
                 admins=admins,
                 currentPage=currentPage,
                 numPerPage=numPerPage,
                 totalCount=totalCount);
Exemplo n.º 7
0
 def adminlist(self):
     # 列表的当前页,默认在第一页
     currentPage = int(self.get_argument('pageNum', 1))
     # 列表中每页显示多少条,默认每页显示20条
     numPerPage = int(self.get_argument('numPerPage', 20))
     print 'numPerPage : %s' % numPerPage
     # 计算User的总数
     all = AdminModel.mgr().Q()
     totalCount = len(all)
     admins = all[(currentPage - 1) * numPerPage:currentPage * numPerPage]
     self.render('admin/list.html',
                 admins=admins,
                 currentPage=currentPage,
                 numPerPage=numPerPage,
                 totalCount=totalCount)
Exemplo n.º 8
0
 def admindelete(self):
     ids = str(self.get_argument('ids')).split(",")
     for id in ids:
         admins = AdminModel.mgr().Q().filter(id=id)
         if admins:
             for admin in admins:
                 if admin['userName'] != 'admin':
                     admin.delete()
     self.write(
         json.dumps({
             'statusCode': "200",
             'callbackType': "forward",
             'navTabId': "admin",
             'forwardUrl': "/admin/adminlist"
         }))
Exemplo n.º 9
0
 def adminpwd(self):
     id = self.get_argument('id', '')
     oldPassWord = self.get_argument('oldPassWord', '')
     newPassWord = self.get_argument('newPassWord', '')
     admins = AdminModel.mgr().Q().filter(id=id)
     admin = admins[0];
     if admin.passWord == self.md5(oldPassWord):
         admin.passWord = self.md5(newPassWord)
         admin.save()
         self.write(json.dumps({'statusCode': "200",
                                'message': '修改成功',
                                'callbackType': "closeCurrent",}))
     else:
         self.write(json.dumps({'statusCode': "300",
                                'message': '旧密码错误',
                                'callbackType': "closeCurrent"}))
Exemplo n.º 10
0
 def adminpwd(self):
     id = self.get_argument('id', '')
     oldPassWord = self.get_argument('oldPassWord', '')
     newPassWord = self.get_argument('newPassWord', '')
     admins = AdminModel.mgr().Q().filter(id=id)
     admin = admins[0]
     if admin.passWord == self.md5(oldPassWord):
         admin.passWord = self.md5(newPassWord)
         admin.save()
         self.write(
             json.dumps({
                 'statusCode': "200",
                 'message': '修改成功',
                 'callbackType': "closeCurrent",
             }))
     else:
         self.write(
             json.dumps({
                 'statusCode': "300",
                 'message': '旧密码错误',
                 'callbackType': "closeCurrent"
             }))
Exemplo n.º 11
0
 def adminedit(self):
     id = self.get_argument('id', '0')
     admin = AdminModel.mgr().Q().filter(id=id)[0];
     self.render('admin/edit.html',
                 admin=admin);
Exemplo n.º 12
0
 def modifypwd(self):
     id = self.get_argument('id', '0')
     admin = AdminModel.mgr().Q().filter(id=id)[0];
     self.render('admin/modifypwd.html',
             admin=admin);
Exemplo n.º 13
0
 def index(self):
     user = self.get_current_user()
     userName = user['userName']
     admin = AdminModel.mgr().Q().filter(userName=userName)[0]
     self.render('index.html',
                 admin=admin)
Exemplo n.º 14
0
 def adminedit(self):
     id = self.get_argument('id', '0')
     admin = AdminModel.mgr().Q().filter(id=id)[0]
     self.render('admin/edit.html', admin=admin)
Exemplo n.º 15
0
 def modifypwd(self):
     id = self.get_argument('id', '0')
     admin = AdminModel.mgr().Q().filter(id=id)[0]
     self.render('admin/modifypwd.html', admin=admin)
Exemplo n.º 16
0
 def index(self):
     user = self.get_current_user()
     userName = user['userName']
     admin = AdminModel.mgr().Q().filter(userName=userName)[0]
     self.render('index.html', admin=admin)