Beispiel #1
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')
        address = self.get_argument('address', '').encode('utf-8')
        sort = self.get_argument('sort', '0')
        state = self.get_argument('state', '0')

        live = LiveModel.new()
        if lid != '':
            live.id = lid
        live.name = name
        live.desc = desc
        live.iconUrl = iconUrl
        live.address = address
        live.sort = sort
        live.state = state
        resLive = live.save()
        res = dict()
        res['result'] = resLive
        res['code'] = 0
        res['msg'] = '成功'
        jsondata = json.dumps(res, cls=CJsonEncoder)
        self.write(jsondata)
Beispiel #2
0
 def list(self):
     size = int(self.get_argument('size', '20'))
     page = int(self.get_argument('page', '0'))
     if page < 0:
         page = 0
     if size <= 0:
         size = 20
     sql = 'select id,name,address from monitor_live order by sort desc limit %d,%d' % (page * size, size);
     #limit %d,%d' % (page * size, size);
     lives = LiveModel.mgr().raw(sql)
     self.send_json(lives, 0, '成功')
Beispiel #3
0
 def livedelete(self):
     ids = str(self.get_argument('ids')).split(",")
     for id in ids:
         lives = LiveModel.mgr().Q().filter(id=id)
         if lives:
             for live in lives:
                 live.delete()
     self.write(json.dumps({'statusCode': "200",
                            'callbackType': "forward",
                            'navTabId': "live",
                            'forwardUrl': "/admin/livelist"}))
Beispiel #4
0
 def delete(self):
     lid = int(self.get_argument('id'))
     lives = LiveModel.mgr(ismaster=1).Q().filter(id=lid)
     if lives:
         for live in lives:
             live.delete()
     res = dict()
     res['result'] = {}
     res['code'] = 0
     res['msg'] = '成功'
     jsondata = json.dumps(res)
     self.write(jsondata)
Beispiel #5
0
 def livelist(self):
     # 列表的当前页,默认在第一页
     currentPage = int(self.get_argument('pageNum', 1))
     # 列表中每页显示多少条,默认每页显示20条
     numPerPage = int(self.get_argument('numPerPage', 20))
     # 计算User的总数
     all = LiveModel.mgr().Q().orderby('sort', 'desc')
     totalCount = len(all)
     lives = all[(currentPage - 1) * numPerPage: currentPage * numPerPage]
     self.render('live/list.html',
                 lives=lives,
                 currentPage=currentPage,
                 numPerPage=numPerPage,
                 totalCount=totalCount);
Beispiel #6
0
 def livedelete(self):
     ids = str(self.get_argument('ids')).split(",")
     for id in ids:
         lives = LiveModel.mgr().Q().filter(id=id)
         if lives:
             for live in lives:
                 live.delete()
     self.write(
         json.dumps({
             'statusCode': "200",
             'callbackType': "forward",
             'navTabId': "live",
             'forwardUrl': "/admin/livelist"
         }))
Beispiel #7
0
 def livelist(self):
     # 列表的当前页,默认在第一页
     currentPage = int(self.get_argument('pageNum', 1))
     # 列表中每页显示多少条,默认每页显示20条
     numPerPage = int(self.get_argument('numPerPage', 20))
     # 计算User的总数
     all = LiveModel.mgr().Q().orderby('sort', 'desc')
     totalCount = len(all)
     lives = all[(currentPage - 1) * numPerPage:currentPage * numPerPage]
     self.render('live/list.html',
                 lives=lives,
                 currentPage=currentPage,
                 numPerPage=numPerPage,
                 totalCount=totalCount)
Beispiel #8
0
 def livesave(self):
     id = self.get_argument('id', '')
     name = self.get_argument('name', '')
     desc = self.get_argument('desc', '')
     address = self.get_argument('address', '')
     sort = self.get_argument('sort', '0')
     live = LiveModel.new()
     if id != '':
         live.id = id
     live.name = name
     live.desc = desc
     live.address = address
     live.sort = sort
     live.save()
     self.write(json.dumps({'statusCode': "200",
                            'callbackType': "closeCurrent",
                            'navTabId': "live",
                            'forwardUrl': "/admin/livelist"}))
Beispiel #9
0
 def livesave(self):
     id = self.get_argument('id', '')
     name = self.get_argument('name', '')
     desc = self.get_argument('desc', '')
     address = self.get_argument('address', '')
     sort = self.get_argument('sort', '0')
     live = LiveModel.new()
     if id != '':
         live.id = id
     live.name = name
     live.desc = desc
     live.address = address
     live.sort = sort
     live.save()
     self.write(
         json.dumps({
             'statusCode': "200",
             'callbackType': "closeCurrent",
             'navTabId': "live",
             'forwardUrl': "/admin/livelist"
         }))
Beispiel #10
0
        res = dict()
        res['result'] = resLive
        res['code'] = 0
        res['msg'] = '成功'
        jsondata = json.dumps(res, cls=CJsonEncoder)
        self.write(jsondata)

    def delete(self):
        lid = int(self.get_argument('id'))
        lives = LiveModel.mgr(ismaster=1).Q().filter(id=lid)
        if lives:
            for live in lives:
                live.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__":
    lives = LiveModel.mgr().Q()
    for live in lives:
        live['iconUrl'] = ''
        live.save()
    pass
Beispiel #11
0
 def liveedit(self):
     id = self.get_argument('id', '0')
     live = LiveModel.mgr().Q().filter(id=id)[0];
     self.render('live/edit.html',
                 live=live);
Beispiel #12
0
 def liveedit(self):
     id = self.get_argument('id', '0')
     live = LiveModel.mgr().Q().filter(id=id)[0]
     self.render('live/edit.html', live=live)