예제 #1
0
파일: zz_main.py 프로젝트: amxku/toaza.com
    def get(self):
        if self.session['gnaflag'] <> '675':
            raise tornado.web.HTTPError(404)
            return
        pageid = int(self.get_argument("p",1))
        aTotal = Article().count()
        if aTotal:
            if aTotal % adminpnum == 0:
                pages = aTotal / adminpnum
            else:
                pages = aTotal / adminpnum + 1
            offset = (pageid-1) * adminpnum
            articles = []
            aarticles = Article().select(['uid','aid','title','aptime','comtotal']).order_by('-lastctime').findall(adminpnum,offset)
            for iai in aarticles:
                auser = User().select(['username']).find_by_uid(iai.uid).to_dict()
                iai = iai.to_dict()
                arts = auser.copy()
                arts.update(iai)
                articles.append(arts)

        countent = self.render_template('zz_articles.html',
            articles = articles,
            aTotal = aTotal,
            f1page = '/zzginoa/articles',
            f1pagewa = '?',
            thisp = pageid,
            Totalp = pages,
            title = u'主题管理 %s/%s' % (pageid,pages),)
        self.write(countent)
예제 #2
0
파일: zz_main.py 프로젝트: amxku/toaza.com
    def get(self):
        if self.session['gnaflag'] <> '675':
            raise tornado.web.HTTPError(404)
            return

        pageid = int(self.get_argument("p",1))
        op = xhtml_escape(self.get_argument('op', 'index'))
        access_token = str(self.get_cookie('_part',''))
        token = self.get_argument('token', '0')

        if op == 'index':
            aTotal = Log().count()
            if aTotal:
                if aTotal % adminpnum == 0:
                    pages = aTotal / adminpnum
                else:
                    pages = aTotal / adminpnum + 1
                offset = (pageid-1) * adminpnum
                logs = []
                lids = Log().order_by('-optime').findall(adminpnum,offset)
                for li in lids:
                    uid = User().select(['username']).find_by_uid(li.uid).to_dict()
                    aid = Article().select(['title']).find_by_aid(li.aid).to_dict()
                    pun = User().select(['(username) as puname']).find_by_uid(li.puid)
                    nid = Node().select(['nName','nUrl']).find_by_nid(li.nid).to_dict()
                    arts = uid.copy()
                    arts.update(li.to_dict())
                    arts.update(aid)
                    arts.update(pun)
                    arts.update(nid)
                    logs.append(arts)

                countent = self.render_template('zz_logs.html',
                    logs = logs,
                    f1page = '/zzginoa/logs',
                    f1pagewa = '?',
                    thisp = pageid,
                    Totalp = pages,
                    aTotal = aTotal,
                    access_token = access_token,
                    title = u'日志管理',)
                self.write(countent)
        elif op == 'del:login':
            if token != access_token:
                self.get_error('/','10',u'参数异常',SITE_NAME)
                return
            adminlid =  Log().findall_by_optype('login',limit=Log().where('optype','=','login').count())
            for ali in adminlid:
                ali.delete()
            self.logaw('admin',u'删除登录日志','0','0','0','0')  #记录日志(type,des,aid,cid,nid,puid)
            self.get_error('/zzginoa/logs','10',u'删除完成',SITE_NAME)
            return
        else:
            self.get_error('/','10',u'参数错误','toaza.com')
            return
예제 #3
0
파일: x_views.py 프로젝트: amxku/toaza.com
    def get(self):
        try:
            pageid = int(self.get_argument("p", 1))
        except:
            self.get_error('/', '10', u'参数错误', SITE_NAME)
            return

        results_user_counter = User().count()
        results_article_counter = Article().count()
        results_comments_counter = Comment().count()

        aTotal = Article().count()
        if aTotal:
            if aTotal % pnum == 0:
                pages = aTotal / pnum
            else:
                pages = aTotal / pnum + 1
            offset = (pageid-1) * pnum

            anodeids = []
            annids = []
            aarticles = Article().select(['uid', 'aid', 'title', 'lastctime', 'comtotal']).order_by('-lastctime').findall(limit=pnum, offset=offset)
            for iai in aarticles:
                auser = User().select(['username', 'isavatar']).find_by_uid(iai.uid).to_dict()
                iai = iai.to_dict()
                arts = auser.copy()
                arts.update(iai)
                anodeids.append(arts)

                anode = Noderelated().select(['nid', 'aid']).findall_by_aid(iai.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)

        else:
            self.get_error('/', '10', u'参数错误', SITE_NAME)
            return

        countent = self.render_template('view_pages.html',
                                        title=u'最近的推帖 %s/%s - %s' % (pageid, pages, SITE_NAME),
                                        nodes=annids,
                                        articles=anodeids,
                                        f1page='/recent',
                                        f1pagewa='?',
                                        thisp=pageid,
                                        Totalp=pages,
                                        user_Count=results_user_counter,
                                        article_Count=results_article_counter,
                                        comments_Count=results_comments_counter,)
        self.write(countent)
예제 #4
0
파일: x_views.py 프로젝트: amxku/toaza.com
    def get(self, nName):
        try:
            gnName = xhtml_escape(nName)
            pageid = int(self.get_argument("p", 1))
        except:
            self.get_error('/', '10', u'error', SITE_NAME)
            return
        nodenid = Node().select(['nName', 'nDes', 'nid', 'nUrl']).find_by_nUrl(gnName)
        if nodenid:
            aTotal = Noderelated().count_by_nid(nodenid.nid)
            if aTotal:
                if aTotal % pnum == 0:
                    pages = aTotal / pnum
                else:
                    pages = aTotal / pnum + 1
                offset = (pageid-1) * pnum

                nrids = []
                anodeids = []
                naids = Noderelated().select(['aid']).findall_by_nid(nodenid.nid, limit=pnum, offset=offset)
                for nir in naids:
                    nrids.append(nir.aid)
                aarticles = Article().select(['uid', 'aid', 'title', 'aptime', 'comtotal']).findall_in_aid(nrids)
                for iai in aarticles:
                    auser = User().select(['username', 'isavatar']).find_by_uid(iai.uid).to_dict()
                    iai = iai.to_dict()
                    arts = auser.copy()
                    arts.update(iai)
                    anodeids.append(arts)

                if pageid == 1:
                    title = nodenid.nName + ' - ' + SITE_NAME
                else:
                    title = '%s %s/%s - %s' % (nodenid.nName, pageid, pages, SITE_NAME)

                countent = self.render_template('view_tag.html',
                                                title=title,
                                                nodenid=nodenid,
                                                f1page='/n/' + nodenid.nUrl,
                                                f1pagewa='?',
                                                thisp=pageid,
                                                Totalp=pages,
                                                narticles=anodeids,)
                self.write(countent)
            else:
                self.get_error('/', '10', u'None', SITE_NAME)
                return
        else:
            self.get_error('javascript:history.go(-1);', '10', u'没找到哦', u'点击返回')
            return
예제 #5
0
파일: x_views.py 프로젝트: amxku/toaza.com
    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)
예제 #6
0
파일: x_views.py 프로젝트: amxku/toaza.com
    def get(self):
        gnauid = self.session['gnauid'] if 'gnauid' in self.session else ''

        annids = []
        anodeids = []
        aarticles = Article().select(['uid', 'aid', 'title', 'lastctime', 'comtotal']).order_by('-lastctime').findall(limit=pnum)
        for iai in aarticles:
            auser = User().select(['username', 'isavatar']).find_by_uid(iai.uid).to_dict()
            iai = iai.to_dict()
            arts = auser.copy()
            arts.update(iai)
            anodeids.append(arts)

            anode = Noderelated().select(['nid', 'aid']).findall_by_aid(iai.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)

        results_user_counter = User().count()
        results_article_counter = Article().count()
        results_comments_counter = Comment().count()
        nodens = Node().select(['nName', 'nUrl', 'subhead']).order_by('-nCou').where('nCou', '!=', '0').where('subhead', '!=', '0').where('nType', '=', 'N').findall(limit=node_total)

        #cache
        if not gnauid:
            anodeids = get_cache('index_articles', anodeids, timeout=60*5)

        results_user_counter = get_cache('results_user_counter', results_user_counter, timeout=60*30)
        results_article_counter = get_cache('results_article_counter', results_article_counter, timeout=60*30)
        results_comments_counter = get_cache('results_comments_counter', results_comments_counter, timeout=60*30)

        countent = self.render_template('home.html',
                                        title=SITE_NAME,
                                        articles=anodeids,
                                        nodens=nodens,
                                        nodes=annids,
                                        user_Count=results_user_counter,
                                        article_Count=results_article_counter,
                                        comments_Count=results_comments_counter,)
        self.write(countent)