コード例 #1
0
ファイル: view.py プロジェクト: zhoutong1996/UUBlog
    def GetContext(self, **kwargs):
        super(PageView, self).GetContext(**kwargs)

        pid = utility.ToInt(utility.GetDicData(kwargs, "pid"), 0)

        pageInfo = self.GetPage(pid)
        if pageInfo is None:
            self.SetMessageTemplate("此页面不存在")
            return locals()

        #更新文章浏览量
        pageInfo.views += 1
        pageInfo.save()

        commentObject = pageInfo
        commentList = self.GetCommentList(obj_id=pid)

        comment_paging = self.GetOption("comment_paging", "True")
        if comment_paging == "True":
            pageIndex = utility.ToInt(self.GetGetData("page"), 1)
            pageSize = utility.ToInt(self.GetOption("comment_pagesize"), 20)

            commentList = pub.GetPagedObject(commentList, pageIndex, pageSize)
            pagedObject = commentList

        self.templateName = "page_" + pageInfo.template
        self.sidebar = pageInfo.sidebar
        self.sidebarFloat = pageInfo.sidebarfloat

        self.SetTemplateAndSidebar()
        return locals()
コード例 #2
0
ファイル: adminpost.py プロジェクト: zhoutong1996/UUBlog
    def GetContext(self, **kwargs):
        catid = utility.ToInt(self.GetGetData("catid"), -1)
        istop = utility.ToInt(self.GetGetData("istop"), -1)
        status = utility.ToInt(self.GetGetData("status"), -1)
        time = utility.ToInt(self.GetGetData("time"), -1)
        keywords = self.GetGetData("keywords")

        catTree = "var data=Array();"
        catTree += self.BuildCatTreeJs(0, -1, -1)

        postList = Post.objects.order_by("-createtime")

        if catid > -1:
            postList = postList.filter(category_id=catid)
        if istop > -1:
            postList = postList.filter(istop=istop)
        if status > -1:
            postList = postList.filter(status=status)
        if time > -1:
            startTime = datetime.datetime.now() - datetime.timedelta(time)
            postList = postList.filter(createtime__gte=startTime)
        if keywords != "":
            postList = postList.filter(title__icontains=keywords)

        pageIndex = utility.ToInt(self.GetGetData("page"), 1)
        pageSize = self.GetOption("admin_pagesize", 10)

        postList = pub.GetPagedObject(postList, pageIndex, pageSize)
        pagedObject = postList

        self.SetTemplateName("postlist")
        return locals()
コード例 #3
0
    def GetContext(self, **kwargs):
        filetype=utility.ToInt(self.GetGetData("filetype"),None)

        attachList=Attachment.objects.all().order_by("-createtime")
        if filetype:
            attachList=attachList.filter(filetype=filetype)

        pageIndex=utility.ToInt(self.GetGetData("page"),1)
        pageSize=self.GetOption("admin_pagesize",10)

        attachList=pub.GetPagedObject(attachList,pageIndex,pageSize)
        pagedObject=attachList

        self.SetTemplateName("attachlist")
        return locals()
コード例 #4
0
ファイル: view.py プロジェクト: zhoutong1996/UUBlog
    def GetContext(self, **kwargs):
        super(IndexView, self).GetContext(**kwargs)

        pageIndex = utility.ToInt(self.GetGetData("page"), 1)
        pageSize = utility.ToInt(self.GetOption("index_pagesize"), 20)

        postList = self.GetPostList("-istop", "-createtime", status=1)
        postList = pub.GetPagedObject(postList, pageIndex, pageSize)
        pagedObject = postList

        self.templateName = "index_" + self.GetOption("index_template",
                                                      "default")
        self.sidebar = self.GetOption("index_sidebar", "default")
        self.sidebarFloat = self.GetOption("index_sidebar_float", "right")

        self.SetTemplateAndSidebar()
        return locals()
コード例 #5
0
ファイル: view.py プロジェクト: zhoutong1996/UUBlog
    def GetContext(self, **kwargs):
        super(SearchView, self).GetContext(**kwargs)

        word = self.GetGetData("word")

        pageIndex = utility.ToInt(self.GetGetData("page"), 1)
        pageSize = utility.ToInt(self.GetOption("search_pagesize"), 20)

        postList = self.GetPostList(status=1, title__icontains=word)
        postList = pub.GetPagedObject(postList, pageIndex, pageSize)
        pagedObject = postList

        self.templateName = "search"
        self.sidebar = self.GetOption("search_sidebar", "default")
        self.sidebarFloat = self.GetOption("search_sidebar_float", "right")

        self.SetTemplateAndSidebar()
        return locals()
コード例 #6
0
ファイル: view.py プロジェクト: zhoutong1996/UUBlog
    def GetContext(self, **kwargs):
        super(ListView, self).GetContext(**kwargs)

        cid = utility.ToInt(utility.GetDicData(kwargs, "cid"), 0)
        tid = utility.ToInt(utility.GetDicData(kwargs, "tid"), 0)

        if cid > 0:
            catInfo = self.GetCat(cid)
            if catInfo is None:
                self.SetMessageTemplate("分类不存在")
                return locals()

            pageSize = utility.ToInt(self.GetOption("cat_pagesize"), 20)

            postList = self.GetPostList(status=1, category_id=cid)

            self.templateName = "cat_" + catInfo.template
            self.sidebar = catInfo.sidebar
            self.sidebarFloat = catInfo.sidebarfloat

        elif tid > 0:
            postList = self.GetPostList(status=1)
            #pageSize=self.GetOption("tag_pagesize",10)
            #postList=postList.filter(category_id=cid)
            #self.sidebar=catInfo.sidebar
            #self.templateName="tag_"+catInfo.template

            pass
        else:
            self.redirectUrl = "/"
            return locals()

        pageIndex = utility.ToInt(self.GetGetData("page"), 1)

        postList = pub.GetPagedObject(postList, pageIndex, pageSize)
        pagedObject = postList

        self.SetTemplateAndSidebar()
        return locals()
コード例 #7
0
ファイル: view.py プロジェクト: zhoutong1996/UUBlog
    def GetContext(self, **kwargs):
        super(PostView, self).GetContext(**kwargs)

        pid = utility.ToInt(utility.GetDicData(kwargs, "pid"), 0)

        postInfo = self.GetPost(pid)
        if postInfo is None:
            self.SetMessageTemplate("此文章不存在")
            return locals()

        #更新文章浏览量
        postInfo.views += 1
        postInfo.save()

        hookList = self.GetHookList("post_BeforShow")
        for hook in hookList:
            if callable(hook):
                postInfo = hook(postInfo)

        commentObject = postInfo
        commentList = self.GetCommentList(obj_id=pid)

        comment_paging = self.GetOption("comment_paging", "True")
        if comment_paging == "True":
            pageIndex = utility.ToInt(self.GetGetData("page"), 1)
            pageSize = utility.ToInt(self.GetOption("comment_pagesize"), 20)

            commentList = pub.GetPagedObject(commentList, pageIndex, pageSize)
            pagedObject = commentList

        self.templateName = "post_" + postInfo.template
        self.sidebar = postInfo.sidebar
        self.sidebarFloat = postInfo.sidebarfloat

        self.SetTemplateAndSidebar()
        return locals()