Beispiel #1
0
 def get_unit_photo_list(self):
     qry = PhotoQuery(
         """ p.photoId, p.title, p.createDate, p.href, u.userId, u.loginName, u.nickName, p.summary """
     )
     qry.unitId = self.unit.unitId
     pager = self.createPager()
     pager.totalRows = qry.count()
     photo_list = qry.query_map(pager)
     request.setAttribute("photo_list", photo_list)
     request.setAttribute("pager", pager)
Beispiel #2
0
 def List(self) :
     # 构造查询.
     query = PhotoQuery(""" p.photoId, p.title, p.summary, p.href, p.tags, stap.title as stapTitle, 
                        sc.name as sysPhotoName, p.viewCount, p.createDate, p.addIp, 
                        u.nickName, u.loginName, p.auditState, p.delState, p.isPrivateShow """)
     
     query.unitId = self.unit.unitId
     query.isPrivateShow = None
     query.auditState = None
     query.delState = None
     
     auditState = self.params.safeGetStringParam("auditState")
     if auditState=="1":
         query.auditState = 1
     elif auditState=="0":
         query.auditState = 0
     
     isPrivateShow = self.params.safeGetStringParam("isPrivateShow")
     if isPrivateShow=="1":
         query.isPrivateShow = 1
     elif isPrivateShow=="0":
         query.isPrivateShow = 0
         
     query.k = self.params.safeGetStringParam("k")
     query.f = self.params.safeGetStringParam("f")
     query.sysCateId = self.params.getIntParamZeroAsNull("sc")
     query.photoStaple = self.params.getIntParamZeroAsNull("ps")
     self.putSysCategoryTree()
     self.putPhotoStaple()
     
     # TODO: 权限检查.
     
     # 调用分页函数.
     pager = self.createPager()
     pager.totalRows = query.count()
         
     # 得到所有照片的列表.
     photoList = query.query_map(pager)
     #print "photoList = ", photoList
         
     # 传给页面.
     request.setAttribute("photoList", photoList)
     request.setAttribute("pager", pager)
     request.setAttribute("auditState", auditState)
     request.setAttribute("isPrivateShow", isPrivateShow)
     request.setAttribute("k", query.k)
     request.setAttribute("f", query.f)
     request.setAttribute("sc", query.sysCateId)
     request.setAttribute("ps", query.photoStaple)
Beispiel #3
0
    def genernate_photo_content(self, webpart):
        cache_key = "unit" + str(self.unit.unitId) + "_" + str(
            webpart.getUnitWebpartId())
        content = cache.get(cache_key)
        if content != None:
            request.setAttribute(cache_key, content)
            return

        map = HashMap()
        qry = PhotoQuery(
            " p.photoId, p.title, p.createDate, p.href, u.userId, u.loginName, u.nickName, p.summary "
        )
        qry.unitId = self.unit.unitId
        photo_list = qry.query_map(6)
        map.put("photo_list", photo_list)
        map.put("unit", self.unit)
        map.put("webpart", webpart)
        map.put("UnitRootUrl", self.unitRootUrl)
        map.put("UserUrlPattern", request.getAttribute("UserUrlPattern"))
        content = self.templateProcessor.processTemplate(
            map, "/WEB-INF/unitspage/" + self.templateName + "/photo.ftl",
            "utf-8")
        request.setAttribute(cache_key, content)
        cache.put(cache_key, content)