예제 #1
0
 def lumpedit(self):
     id = self.get_argument('id', '0')
     lump = LumpModel.mgr().Q().filter(id=id)[0];
     categorys = LumpCategoryModel.mgr().Q()
     self.render('lump/edit.html',
                 lump=lump,
                 categorys=categorys);
예제 #2
0
    def add(self):
        lid = self.get_argument('id', '')
        name = self.get_argument('name', '').encode('utf-8')
        desc = self.get_argument('desc', '').encode('utf-8')
        iconUrl = self.get_argument('iconUrl', '').encode('utf-8')
        url = self.get_argument('url', '').encode('utf-8')
        categoryId = self.get_argument('categoryId', '0')
        sort = self.get_argument('sort', '0')
        state = self.get_argument('state', '0')

        lump = LumpModel.new()
        if lid != '':
            lump.id = lid
        lump.name = name
        lump.desc = desc
        lump.iconUrl = iconUrl
        lump.url = url
        lump.categoryId = categoryId
        lump.sort = sort;
        lump.state = state
        resLump = lump.save()
        res = dict()
        res['result'] = resLump
        res['code'] = 0
        res['msg'] = '成功'
        jsondata = json.dumps(res, cls=CJsonEncoder)
        self.write(jsondata)
예제 #3
0
 def lumpsave(self):
     id = self.get_argument('id', '')
     name = self.get_argument('name', '')
     desc = self.get_argument('desc', '')
     iconUrl = self.get_argument('iconUrl', '')
     url = self.get_argument('url', '')
     categoryId = self.get_argument('categoryId', '0')
     sort = self.get_argument('sort', '0')
     lump = LumpModel.new()
     if id != '':
         lump.id = id
     lump.name = name
     lump.desc = desc
     lump.iconUrl = iconUrl
     lump.url = url
     lump.categoryId = categoryId
     lump.sort = sort
     lump.save()
     self.write(
         json.dumps({
             'statusCode': "200",
             'callbackType': "closeCurrent",
             'navTabId': "lump",
             'forwardUrl': "/admin/lumplist"
         }))
예제 #4
0
    def add(self):
        lid = self.get_argument('id', '')
        name = self.get_argument('name', '').encode('utf-8')
        desc = self.get_argument('desc', '').encode('utf-8')
        iconUrl = self.get_argument('iconUrl', '').encode('utf-8')
        url = self.get_argument('url', '').encode('utf-8')
        categoryId = self.get_argument('categoryId', '0')
        sort = self.get_argument('sort', '0')
        state = self.get_argument('state', '0')

        lump = LumpModel.new()
        if lid != '':
            lump.id = lid
        lump.name = name
        lump.desc = desc
        lump.iconUrl = iconUrl
        lump.url = url
        lump.categoryId = categoryId
        lump.sort = sort
        lump.state = state
        resLump = lump.save()
        res = dict()
        res['result'] = resLump
        res['code'] = 0
        res['msg'] = '成功'
        jsondata = json.dumps(res, cls=CJsonEncoder)
        self.write(jsondata)
예제 #5
0
 def lumpdelete(self):
     ids = str(self.get_argument('ids')).split(",")
     for id in ids:
         lumps = LumpModel.mgr().Q().filter(id=id)
         if lumps:
             for lump in lumps:
                 lump.delete()
     self.write(json.dumps({'statusCode': "200",
                            'callbackType': "forward",
                            'navTabId': "lump",
                            'forwardUrl': "/admin/lumplist"}))
예제 #6
0
 def delete(self):
     lid = int(self.get_argument('id'))
     lumps = LumpModel.mgr(ismaster=1).Q().filter(id=lid)
     if lumps:
         for lump in lumps:
             lump.delete()
     res = dict()
     res['result'] = {}
     res['code'] = 0
     res['msg'] = '成功'
     jsondata = json.dumps(res)
     self.write(jsondata)
예제 #7
0
 def delete(self):
     lid = int(self.get_argument('id'))
     lumps = LumpModel.mgr(ismaster=1).Q().filter(id=lid)
     if lumps:
         for lump in lumps:
             lump.delete()
     res = dict()
     res['result'] = {}
     res['code'] = 0
     res['msg'] = '成功'
     jsondata = json.dumps(res)
     self.write(jsondata)
예제 #8
0
 def lumpdelete(self):
     ids = str(self.get_argument('ids')).split(",")
     for id in ids:
         lumps = LumpModel.mgr().Q().filter(id=id)
         if lumps:
             for lump in lumps:
                 lump.delete()
     self.write(
         json.dumps({
             'statusCode': "200",
             'callbackType': "forward",
             'navTabId': "lump",
             'forwardUrl': "/admin/lumplist"
         }))
예제 #9
0
 def lumplist(self):
     # 列表的当前页,默认在第一页
     currentPage = int(self.get_argument('pageNum', 1))
     # 列表中每页显示多少条,默认每页显示20条
     numPerPage = int(self.get_argument('numPerPage', 20))
     # 计算User的总数
     all = LumpModel.mgr().Q().orderby('sort', 'desc')
     totalCount = len(all)
     lumps = all[(currentPage - 1) * numPerPage: currentPage * numPerPage]
     categorys = LumpCategoryModel.mgr().Q()
     print 'lumplist numPerPage:%d' % numPerPage
     self.render('lump/list.html',
                 lumps=lumps,
                 categorys=categorys,
                 currentPage=currentPage,
                 numPerPage=numPerPage,
                 totalCount=totalCount);
예제 #10
0
 def lumplist(self):
     # 列表的当前页,默认在第一页
     currentPage = int(self.get_argument('pageNum', 1))
     # 列表中每页显示多少条,默认每页显示20条
     numPerPage = int(self.get_argument('numPerPage', 20))
     # 计算User的总数
     all = LumpModel.mgr().Q().orderby('sort', 'desc')
     totalCount = len(all)
     lumps = all[(currentPage - 1) * numPerPage:currentPage * numPerPage]
     categorys = LumpCategoryModel.mgr().Q()
     print 'lumplist numPerPage:%d' % numPerPage
     self.render('lump/list.html',
                 lumps=lumps,
                 categorys=categorys,
                 currentPage=currentPage,
                 numPerPage=numPerPage,
                 totalCount=totalCount)
예제 #11
0
 def list(self):
     size = int(self.get_argument('size', '10'))
     page = int(self.get_argument('page', '0'))
     if page == 0:
         page = 0
     if size == 0:
         size = 10
     sql = 'select `id`,`name` from monitor_lumpCategory order by sort desc limit %d,%d' % (page * size, size);
     categorys = LumpCategoryModel.mgr().raw(sql)
     for category in categorys:
         lumpsql = 'select `id`,`name`,`desc`,`iconUrl`,`url` from monitor_lump where categoryId=%d order by sort desc' % category['id']
         lumps = LumpModel.mgr().raw(lumpsql)
         for lump in lumps:
             iconUrl = lump['iconUrl']
             if iconUrl.startswith('/static/images/'):
                 lump['iconUrl'] = SERVER_ADDRESS + iconUrl
         category['lumps'] = lumps
     print categorys
     self.send_json(categorys, 0, '成功')
예제 #12
0
 def list(self):
     size = int(self.get_argument('size', '10'))
     page = int(self.get_argument('page', '0'))
     if page < 0:
         page = 0
     if size <= 0:
         size = 10
     sql = 'select * from monitor_lump order by sort desc limit %d,%d' % (page * size, size);
     lumps = LumpModel.mgr().raw(sql)
     for lump in lumps:
         iconUrl = lump['iconUrl']
         if iconUrl.startswith('/static/images/'):
             lump['iconUrl'] = SERVER_ADDRESS + iconUrl
     res = {}
     res['result'] = lumps
     res['code'] = 0
     res['msg'] = '成功'
     jsondata = json.dumps(res, cls=CJsonEncoder)
     self.write(jsondata)
예제 #13
0
 def list(self):
     size = int(self.get_argument('size', '10'))
     page = int(self.get_argument('page', '0'))
     if page < 0:
         page = 0
     if size <= 0:
         size = 10
     sql = 'select * from monitor_lump order by sort desc limit %d,%d' % (
         page * size, size)
     lumps = LumpModel.mgr().raw(sql)
     for lump in lumps:
         iconUrl = lump['iconUrl']
         if iconUrl.startswith('/static/images/'):
             lump['iconUrl'] = SERVER_ADDRESS + iconUrl
     res = {}
     res['result'] = lumps
     res['code'] = 0
     res['msg'] = '成功'
     jsondata = json.dumps(res, cls=CJsonEncoder)
     self.write(jsondata)
예제 #14
0
 def list(self):
     size = int(self.get_argument('size', '10'))
     page = int(self.get_argument('page', '0'))
     if page == 0:
         page = 0
     if size == 0:
         size = 10
     sql = 'select `id`,`name` from monitor_lumpCategory order by sort desc limit %d,%d' % (
         page * size, size)
     categorys = LumpCategoryModel.mgr().raw(sql)
     for category in categorys:
         lumpsql = 'select `id`,`name`,`desc`,`iconUrl`,`url` from monitor_lump where categoryId=%d order by sort desc' % category[
             'id']
         lumps = LumpModel.mgr().raw(lumpsql)
         for lump in lumps:
             iconUrl = lump['iconUrl']
             if iconUrl.startswith('/static/images/'):
                 lump['iconUrl'] = SERVER_ADDRESS + iconUrl
         category['lumps'] = lumps
     print categorys
     self.send_json(categorys, 0, '成功')
예제 #15
0
 def lumpsave(self):
     id = self.get_argument('id', '')
     name = self.get_argument('name', '')
     desc = self.get_argument('desc', '')
     iconUrl = self.get_argument('iconUrl', '')
     url = self.get_argument('url', '')
     categoryId = self.get_argument('categoryId', '0')
     sort = self.get_argument('sort', '0')
     lump = LumpModel.new()
     if id != '':
         lump.id = id
     lump.name = name
     lump.desc = desc
     lump.iconUrl = iconUrl
     lump.url = url
     lump.categoryId = categoryId
     lump.sort = sort
     lump.save()
     self.write(json.dumps({'statusCode': "200",
                            'callbackType': "closeCurrent",
                            'navTabId': "lump",
                            'forwardUrl': "/admin/lumplist"}))
예제 #16
0
 def lumpedit(self):
     id = self.get_argument('id', '0')
     lump = LumpModel.mgr().Q().filter(id=id)[0]
     categorys = LumpCategoryModel.mgr().Q()
     self.render('lump/edit.html', lump=lump, categorys=categorys)
예제 #17
0
    def delete(self):
        lid = int(self.get_argument('id'))
        lumps = LumpModel.mgr(ismaster=1).Q().filter(id=lid)
        if lumps:
            for lump in lumps:
                lump.delete()
        res = dict()
        res['result'] = {}
        res['code'] = 0
        res['msg'] = '成功'
        jsondata = json.dumps(res)
        self.write(jsondata)

    def edit(self):
        self.add()


if __name__ == "__main__":
    for i in range(0, 50):
        lump = LumpModel.new()
        u = '%d%d%d%d' % (i, i, i, i)
        lump.name = u
        lump.desc = u
        lump.iconUrl = u
        lump.url = u
        lump.categoryId = 1
        res = lump.save()
        print res
    pass
예제 #18
0
    def delete(self):
        lid = int(self.get_argument('id'))
        lumps = LumpModel.mgr(ismaster=1).Q().filter(id=lid)
        if lumps:
            for lump in lumps:
                lump.delete()
        res = dict()
        res['result'] = {}
        res['code'] = 0
        res['msg'] = '成功'
        jsondata = json.dumps(res)
        self.write(jsondata)

    def edit(self):
        self.add();


if __name__ == "__main__":
    for i in range(0, 50):
        lump = LumpModel.new()
        u = '%d%d%d%d' % (i, i, i, i)
        lump.name = u
        lump.desc = u
        lump.iconUrl = u
        lump.url = u
        lump.categoryId = 1
        res = lump.save()
        print res
    pass