Exemple #1
0
    def execute(self):
        params = ParamUtil(request)
        cmt_svc = __jitar__.getCommentService()
        writer = response.getWriter()
        if self.loginUser == None:
            writer.write(u"请先登录。")
            return
        userName = self.loginUser.trueName
        if userName == None:
            userName = self.loginUser.loginName
        title = params.getStringParam("title")
        objtype = params.getIntParam("objtype")
        aboutUserId = params.getIntParam("aboutUserId")
        objId = params.getIntParam("photoId")
        star = params.getIntParam("star")
        content = params.getStringParam("content")
        userIP = request.getHeader("x-forwarded-for")
        if userIP == None or userIP == "":
            userIP = request.getRemoteAddr()

        if title == "":
            writer.write(u"请输入标题。")
            return
        if content == "" or content == "<span></span>":
            writer.write(u"请输入评论内容。")
            return

        cmt = Comment()
        cmt.setTitle(title)
        cmt.setAboutUserId(aboutUserId)
        cmt.setIp(userIP)
        cmt.setUserName(userName)
        cmt.setUserId(self.loginUser.userId)
        cmt.setCreateDate(Date())
        cmt.setStar(star)
        cmt.setAudit(True)
        cmt.setContent(content)
        cmt.setObjId(objId)
        cmt.setObjType(objtype)
        cmt_svc.saveComment(cmt)

        # 评论计数器
        cmd = Command(
            """ UPDATE Photo SET commentCount = commentCount + 1 WHERE photoId = :photoId """
        )
        cmd.setInteger("photoId", objId)
        cmd.update()

        photoUser = params.getStringParam("photoUser")
        if request.getHeader("Referer") != None:
            response.sendRedirect(request.getHeader("Referer"))
            return
        request.setAttribute(
            "redUrl",
            photoUser + "/py/user_photo_show.py?photoId=" + str(objId))
        return "/WEB-INF/ftl/photo/PhotoComment_Success.ftl"
Exemple #2
0
 def updateGroupResourceCategoryId(self, category):
   cmd = Command(""" UPDATE GroupResource SET groupCateId = NULL
       WHERE groupId = :groupId AND groupCateId = :groupCateId """)
   cmd.setInteger("groupId", self.group.groupId)
   cmd.setInteger("groupCateId", category.categoryId)
   count = cmd.update()
   
 def deleteChannelCategory(self, resType, category):
     if category == None: return
     cmd = Command(
         " UPDATE " + resType +
         " SET channelCate = NULL,channelCateId = NULL WHERE channelId = :channelId AND channelCateId = :channelCateId "
     )
     cmd.setInteger("channelId", self.channel.channelId)
     cmd.setInteger("channelCateId", category.categoryId)
     count = cmd.update()
Exemple #4
0
    def execute(self):
        site_config = SiteConfig()
        site_config.get_config()

        param = ParamUtil(request)
        newsId = param.getIntParam("newsId")
        if newsId == None or newsId == "":
            return
        self.sub_svc = __jitar__.getSubjectService()

        news = self.sub_svc.getSiteNews(newsId)
        if news == None:
            return
        sql = """ Update SiteNews Set viewCount = viewCount + 1 Where newsId = :newsId """
        cmd = Command(sql)
        cmd.setInteger("newsId", newsId)
        cmd.update()
        request.setAttribute("news", news)
        response.setContentType("text/html; charset=UTF-8")
        return "/WEB-INF/ftl/show_news.ftl"
Exemple #5
0
 def actionPost(self):
     ErrMsg = ""
     cmd = self.params.getStringParam("cmd")
     guids = self.params.safeGetIntValues("guid")
     if guids.size() < 1:
         self.addActionError(u"请先选择一个活动")
         self.addActionLink(u"返回", "myaction.py")
         return self.ERROR
     for actId in guids:
         action = self.act_svc.getActionByActionUserId(actId)
         if action.status != 0:
             ErrMsg = ErrMsg + u"<li>名为 " + action.title + u" 的活动不是一个正常状态。无法进行操作."
             continue
         if cmd == "attend":
             qry = """ UPDATE ActionUser Set status = 1 WHERE actionUserId = :actionUserId """
             command = Command(qry)
             command.setInteger("actionUserId", actId)
             command.update()
         if cmd == "quit":
             qry = """ UPDATE ActionUser Set status = 2 WHERE actionUserId = :actionUserId"""
             command = Command(qry)
             command.setInteger("actionUserId", actId)
             command.update()
         if cmd == "leave":
             qry = """ UPDATE ActionUser Set status = 3 WHERE actionUserId = :actionUserId """
             command = Command(qry)
             command.setInteger("actionUserId", actId)
             command.update()
     if ErrMsg == "": ErrMsg = u"操作已完成"
     self.addActionMessage(ErrMsg)
     self.addActionLink(u"返回", "myaction.py")
     return self.SUCCESS
Exemple #6
0
    def execute(self):
        site_config = SiteConfig()
        site_config.get_config()

        photoId = self.params.getIntParam("photoId")

        photo = self.photo_svc.findById(photoId)
        request.setAttribute("photo", photo)
        #DEBUG print "photoId = ", photoId, ", photo = ", self.photo
        #print "===photo.sysCateId===:",photo.sysCateId
        if photo != None:
            if photo.sysCateId != None:
                category = self.cate_svc.getCategory(photo.sysCateId)
                request.setAttribute("category", category)
            # 更新访问计数
            cmd = Command(
                """ UPDATE Photo SET viewCount = viewCount + 1 WHERE photoId = :photoId """
            )
            cmd.setInteger("photoId", photo.photoId)
            cmd.update()

        return "/WEB-INF/ftl/showPhoto.ftl"
 def updateChannelCateId(self, resType, category):
     # 得到该分类及其下级所有分类
     cmd = Command(
         "SELECT categoryId FROM Category WHERE itemType = :itemType")
     cmd.setString("itemType", self.itemType)
     cateIdList = cmd.open()
     for id in cateIdList:
         cate = self.categoryService.getCategory(id)
         if cate != None:
             catePath = CommonUtil.convertIntFrom36To10(
                 cate.parentPath) + str(id) + "/"
             cmd = Command(
                 " UPDATE " + resType +
                 " SET channelCate = :channelCate WHERE channelCateId = :channelCateId "
             )
             cmd.setString("channelCate", catePath)
             cmd.setInteger("channelCateId", id)
             count = cmd.update()
Exemple #8
0
    def execute(self):
        photoService = __jitar__.getPhotoService()
        photoStapleService = __jitar__.getPhotoStapleService()
        self.params = ParamUtil(request)
        writer = response.getWriter()

        loginName = request.getAttribute("loginName")
        photoId = self.params.safeGetIntParam("photoId")
        user = __jitar__.userService.getUserByLoginName(loginName)
        request.setAttribute("user", user)
        if self.canVisitUser(user) == False:
            return self.ACCESS_ERROR
        # loginUser 对象来自基类 BaseAdminAction .
        request.setAttribute("loginUser", self.loginUser)

        # 得到照片对象
        photo = photoService.findById(photoId)
        if photo == None:
            self.addActionError(u"无法加载该照片。")
            return self.ERROR

        request.setAttribute("photo", photo)
        if photo.userStaple != None:
            photoStaple = photoStapleService.findById(photo.userStaple)
            request.setAttribute("photoStaple", photoStaple)

        cmd = Command(
            """ UPDATE Photo SET viewCount = viewCount + 1 WHERE photoId = :photoId """
        )
        cmd.setInteger("photoId", photo.photoId)
        cmd.update()

        hql = """SELECT new Map(p.skin as skin)
             FROM Page p 
             WHERE p.name = 'index' and p.objId = :userId and p.objType = 1
             """
        pageSkin = Command(hql).setInteger("userId", user.userId).first()

        # 构造页面数据,由于页面不是在数据库存在的,这里的数据是虚拟数据.
        #pages : [{id: ${page.pageId}, title: '${user.blogName!?js_string}', layoutId: ${page.layoutId!0} }],
        page = {
            "pageId": 0,
            "layoutId": 2,  # 固定是布局2
            "isSystemPage": "true",
            "owner": "user",
            "title": "",
            "skin": pageSkin["skin"]
        }
        request.setAttribute("page", page)
        self.page = self.getUserProfilePage(user)
        if self.page.customSkin != None:
            customSkin = JSONValue.parse(self.page.customSkin)
            request.setAttribute("customSkin", customSkin)

        # 构造widgets .
        widgets = [{
            "id": "1",
            "pageId": 0,
            "columnIndex": 1,
            "title": u"个人档案",
            "module": "profile",
            "ico": "",
            "data": ""
        }, {
            "id": "2",
            "pageId": 0,
            "columnIndex": 1,
            "title": u"相册分类",
            "module": "photo_cate",
            "ico": "",
            "data": ""
        }, {
            "id": "placerholder1",
            "pageId": 0,
            "columnIndex": 2,
            "title": "",
            "module": "placeholder",
            "ico": "",
            "data": ""
        }]

        request.setAttribute("widgets", widgets)
        request.setAttribute("widget_list", widgets)

        qry = CommentQuery(
            """ cmt.content,cmt.createDate,cmt.star,cmt.title,u.loginName,u.userId,u.userIcon
                            """)
        qry.objType = 11
        qry.orderType = 3
        qry.objId = photo.photoId
        pager = self.params.createPager()
        pager.setPageSize(10)
        pager.totalRows = qry.count()
        pager.itemName = u"评论"
        pager.itemUnit = u"条"

        result = qry.query_map(pager)
        request.setAttribute("photo_comment_list", result)
        request.setAttribute("pager", pager)

        response.setContentType("text/html; charset=UTF-8")
        return "/WEB-INF/user/default/user_photo_show.ftl"