예제 #1
0
    def list(self):
        pager = self.params.createPager()
        pager.itemName = u"机构链接"
        pager.itemUnit = u"个"

        # 计算总数.
        hql = """ SELECT COUNT(*) FROM Link 
         WHERE objectType = :objectType AND objectId = :objectId """
        cmd = Command(hql)
        cmd.setInteger("objectType", self.ObjectType_System)
        cmd.setInteger("objectId", self.ObjectId_School)
        pager.totalRows = cmd.int_scalar()

        # 获取当前页.
        hql = """ FROM Link 
         WHERE objectType = :objectType AND objectId = :objectId 
         ORDER BY linkId DESC """
        cmd = Command(hql)
        cmd.setInteger("objectType", self.ObjectType_System)
        cmd.setInteger("objectId", self.ObjectId_School)
        link_list = cmd.open(pager)

        request.setAttribute("link_list", link_list)
        request.setAttribute("pager", pager)

        #DEBUG: print "link_list = ", link_list
        return "/WEB-INF/ftl/admin/school_link_list.ftl"
예제 #2
0
    def main(self):
        qry = UserQuery(
            """ u.userId, u.loginName, u.userIcon, u.gender, u.trueName, u.email, u.blogName, u.blogIntroduce, 
                        u.myArticleCount, u.otherArticleCount, u.historyMyArticleCount, u.historyOtherArticleCount, u.visitCount,u.resourceCount,
                        u.commentCount,u.photoCount,u.subjectId, u.gradeId, u.positionId,
                        subj.subjectName, grad.gradeName, unit.unitTitle, sc.name
             """)
        qry.userStatus = None
        qry.loginName = self.loginUser.loginName
        users = qry.query_map()
        if users.size() == 0:
            response.sendRedirect("../login.jsp")

        user = users[0]
        request.setAttribute("user", user)

        # TODO: 下面的查询用 XxxQuery 改写, 现在统计不对.
        hql = """ select count(*) as groupCount
                          FROM GroupMember gm
                          where gm.userId = """ + str(
            self.loginUser.userId) + """
                         """
        cmd = Command(hql)
        groupCount = cmd.int_scalar()
        request.setAttribute("groupCount", groupCount)

        hql = """ select count(*) as messageCount
                          FROM Message m
                          where m.receiveId = """ + str(
            self.loginUser.userId) + """
                         """
        cmd = Command(hql)
        messageCount = cmd.int_scalar()
        request.setAttribute("messageCount", messageCount)

        hql = """ select count(*) as friendCount
                          FROM Friend f
                          where f.userId = """ + str(
            self.loginUser.userId) + """
                         """
        cmd = Command(hql)
        friendCount = cmd.int_scalar()
        request.setAttribute("friendCount", friendCount)

        return "/WEB-INF/ftl/user/manage_main.ftl"