示例#1
0
    def get(self, aid):
        try:
            aid = int(aid)
        except:
            self.get_error('/', '10', u'None', SITE_NAME)
            return

        articlei = Article().find_by_aid(aid)
        if articlei:
            ausers = User().select(['username', 'isavatar']).find_by_uid(articlei.uid)
            comas = []
            annids = []
            anode = Noderelated().select(['nid']).findall_by_aid(articlei.aid)
            for anid in anode:
                anid = anid.to_dict()
                anids = Node().select(['nName', 'nUrl']).find_by_nid(anid.nid).to_dict()
                artsn = anid.copy()
                artsn.update(anids)
                annids.append(artsn)

            comment = Comment().order_by('cptime').findall_by_aid(aid, limit=comm_total)
            for ci in comment:
                cuser = User().select(['username', 'isavatar', 'item']).find_by_uid(ci.uid).to_dict()
                iai = ci.to_dict()
                arts = cuser.copy()
                arts.update(iai)
                comas.append(arts)

            for cidi in comas:
                if cidi and cidi['item']:
                    cidi['item'] = pickle_loads(str(cidi['item']))
                else:
                    cidi['item'] = ''

            countent = self.render_template('view_article.html',
                                            title=unicode(articlei.title) + ' - ' + SITE_NAME,
                                            article=articlei,
                                            comments=comas,
                                            auser=ausers,
                                            nodes=annids,
                                            nowtime=temptime(),)
            self.write(countent)
        else:
            self.get_error('/', '10', u'参数错误', SITE_NAME)
示例#2
0
    def get(self, username):
        username = xhtml_escape(username.strip())
        if username:
            authorinfo = User().select(['uid', 'username', 'item', 'isavatar', 'regtime']).find_by_username(username)
            if authorinfo:
                if authorinfo.item:
                    authorinfo.item = pickle_loads(str(authorinfo.item))
                else:
                    authorinfo.item = ''

                logs = []
                anodes = []
                typelists = ['article', 'comments']
                aidlists = []
                lids = Log().select(['aid', 'optime', 'optype', 'cid']).order_by('-optime').where('uid', '=', authorinfo.uid).findall_in_optype(typelists, limit=15)
                for li in lids:
                    aids = Article().select(['title']).find_by_aid(li.aid).to_dict()
                    cids = Comment().select(['content']).find_by_cid(li.cid).to_dict()
                    arts = aids.copy()
                    arts.update(li.to_dict())
                    arts.update(cids)
                    logs.append(arts)
                    aidlists.append(li.aid)

                aidlis = {}.fromkeys(aidlists).keys()
                #list 去重复
                anode = Noderelated().select(['nid', 'aid']).findall_in_aid(aidlis)
                for anid in anode:
                    anids = Node().select(['nName', 'nUrl']).find_by_nid(anid.nid).to_dict()
                    nrts = anids.copy()
                    nrts.update(anid.to_dict())
                    anodes.append(nrts)

                countent = self.render_template('user_view.html',
                                                title=username + ' - ' + SITE_NAME,
                                                authorinfo=authorinfo,
                                                logs=logs,
                                                anodes=anodes,
                                                useravatar=authorinfo.uid)
                self.write(countent)
            else:
                self.get_error('/', '10', u'没有找到', SITE_NAME)
        else:
            self.get_error('/', '10', u'参数错误', SITE_NAME)
示例#3
0
    def get(self):
        if self.session['gnaflag'] <> '675':
            raise tornado.web.HTTPError(404)
            return

        try:
            op = xhtml_escape(self.get_argument('op','index'))
            pageid = int(self.get_argument("p",1))
            uid = int(self.get_argument('uid','0'))
            uflag = int(self.get_argument("norclo",'1'))
        except:
            self.get_error('/zzginoa/users','10',u'error','toaza.com')
            return

        if op == 'index':
            uTotal = User().where('flag','!=',uflag).count()
            if uTotal:
                if uTotal % adminpnum == 0:
                    pages = uTotal / adminpnum
                else:
                    pages = uTotal / adminpnum + 1
                offset = (pageid - 1) * adminpnum
                userlists = []
                users = User().where('flag','!=',uflag).findall(limit=adminpnum,offset=offset)
                for u in users:
                    u = u.to_dict()
                    if u.item:
                        u.item = pickle_loads(str(u.item))
                    else:
                        u.item = ''
                    u.flag = checkuserflag(str(u.flag))
                    userlists.append(u)

                countent = self.render_template('zz_users.html',
                    users = userlists,
                    f1page = '/zzginoa/users?op=%s&amp;norclo=%s'%(str(op),uflag),
                    f1pagewa = '&',
                    thisp = pageid,
                    Totalp = pages,
                    uTotal = uTotal,
                    title = u'用户管理',)
                self.write(countent)
        elif op == 'doclock':
            if uid:
                if uid == 1:
                    self.get_error('javascript:history.go(-1);','2',u'该用户不能锁定','toaza.com')
                    return
                else:
                    User().update_user_flag('2',uid)
                    self.logaw('admin',u'锁定用户','0','0','0',uid) #记录日志(type,des,aid,cid,nid,puid)
                    self.get_error('javascript:history.go(-1);','2',u'用户已锁定','toaza.com')
                    return
            else:
                self.get_error('/zzginoa/users','2',u'error','toaza.com')
                return
        elif op == 'dounclock':
            if uid:
                if uid == 1:
                    self.get_error('javascript:history.go(-1);','2',u'该用户不能解锁','toaza.com')
                    return
                else:
                    User().update_user_flag('1',uid)
                    self.logaw('admin',u'解锁用户','0','0','0',uid) #记录日志(type,des,aid,cid,nid,puid)
                    self.get_error('javascript:history.go(-1);','2',u'用户已解锁','toaza.com')
                    return
            else:
                self.get_error('/zzginoa/users','2',u'error','toaza.com')
                return
        elif op == 'edit':
            if uid:
                user = User().select(['uid','username']).find_by_uid(uid)
                countent = self.render_template('zz_users_edit.html',
                    user = user,
                    title = u'编辑 - 用户管理',)
                self.write(countent)
            else:
                self.get_error('/zzginoa/users','2',u'error','toaza.com')
                return
        else:
            self.get_error('/zzginoa/users','10',u'参数错误','toaza.com')
            return