def udel():
    view = AdmHtmlView()
    id = request.args.get('id', '')
    model = AdminModel('conf')
    model.delUser(id)
    model.commit()
    return redirect(url_for('admin'))
Exemple #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
Exemple #3
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;
Exemple #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, '用户名或密码错误,登陆失败')
Exemple #5
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, '用户名或密码错误,登陆失败')
Exemple #6
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"}))
Exemple #7
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"
         }))
Exemple #8
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)
Exemple #9
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);
Exemple #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"}))
Exemple #11
0
 def adminsave(self):
     id = self.get_argument('id', '')
     state = self.get_argument('state', '0')
     passWord = self.get_argument('passWord', '')
     userName = self.get_argument('userName', '')
     group = self.get_argument('group', 'admin')
     admin = AdminModel.new()
     if id != '':
         admin.id = id
     if userName != '':
         admin.userName = userName
     if passWord != '':
         admin.passWord = self.md5(passWord)
     admin.state = state
     admin.group = group
     admin.save()
     self.write(json.dumps({'statusCode': "200",
                            'callbackType': "closeCurrent",
                            'navTabId': "admin",
                            'forwardUrl': "/admin/adminlist"}))
Exemple #12
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"
             }))
Exemple #13
0
 def adminsave(self):
     id = self.get_argument('id', '')
     state = self.get_argument('state', '0')
     passWord = self.get_argument('passWord', '')
     userName = self.get_argument('userName', '')
     group = self.get_argument('group', 'admin')
     admin = AdminModel.new()
     if id != '':
         admin.id = id
     if userName != '':
         admin.userName = userName
     if passWord != '':
         admin.passWord = self.md5(passWord)
     admin.state = state
     admin.group = group
     admin.save()
     self.write(
         json.dumps({
             'statusCode': "200",
             'callbackType': "closeCurrent",
             'navTabId': "admin",
             'forwardUrl': "/admin/adminlist"
         }))
def admin():
    view = AdmHtmlView()
    model = AdminModel('conf')
    return view.draw(model.getAllUsers())
Exemple #15
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)
Exemple #16
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);
Exemple #17
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)
Exemple #18
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);
Exemple #19
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)
Exemple #20
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)