Exemplo n.º 1
0
 def do_business(g, batcher):
     self.group_svc.auditGroup(g)
     #发送消息
     messageService = __spring__.getBean("messageService")
     if self.loginUser != None and messageService != None:
         message = Message()
         message.setSendId(self.loginUser.userId)
         message.setReceiveId(g.getCreateUserId())
         message.setTitle(u"您创建的群组 '" + g.getGroupTitle() + u"' 已经通过审核")
         message.setContent(u"祝贺您,您创建的群组 '" + g.getGroupTitle() +
                            u"' 已经通过审核")
         messageService.sendMessage(message)
     return True
Exemplo n.º 2
0
 def do_business(ru, batcher, *args):
     score = self.params.getIntParam("score")
     reason = self.params.getStringParam("reason")
     #print 'AAAAAAAAA'
     if score == None:
         upun = self.pun_svc.createUPunishScore(12, ru.resource.id,
                                                ru.resource.userId,
                                                score,
                                                self.loginUser.userId,
                                                self.loginUser.trueName)
     else:
         if score < 0:
             upun = self.pun_svc.createUPunishScore(
                 12, ru.resource.id, ru.resource.userId, -1 * score,
                 reason, self.loginUser.userId, self.loginUser.trueName)
         else:
             upun = self.pun_svc.createUPunishScore(
                 12, ru.resource.id, ru.resource.userId, score, reason,
                 self.loginUser.userId, self.loginUser.trueName)
     self.pun_svc.saveUPunishScore(upun)
     #消息通知
     message = Message()
     message.sendId = self.loginUser.userId
     message.receiveId = ru.resource.userId
     message.title = u"管理员删除了您的资源及扣分信息"
     if reason != "":
         message.content = u"您的 " + ru.resource.title + u" 被删除,扣" + str(
             upun.score) + u"分,原因:" + reason
     else:
         message.content = u"您的 " + ru.resource.title + u" 被删除,扣" + str(
             upun.score) + u"分"
     self.msg_svc.sendMessage(message)
     self.res_svc.deleteResource(ru.resource)
     return True
Exemplo n.º 3
0
  def reject_req(self):
    # 得到协作组.
    if self.get_current_group() == None:
      return ActionResult.ERROR

    # 判定是否有权限管理该协作组.
    gm = self.get_group_member()
    if gm == None or gm.groupRole < GroupMember.GROUP_ROLE_VICE_MANAGER or gm.status != GroupMember.STATUS_NORMAL:
      self.addActionError(u"您不是协作组 %s 的管理员, 不能管理其组员." % self.group.groupTitle)
      return ActionResult.ERROR 

    # 得到该申请.
    userId = self.params.getIntParam("userId")
    gm = self.group_svc.getGroupMemberByGroupIdAndUserId(self.group.groupId, userId)
    if gm == None:
      self.addActionError(u"未能找到该申请, 可能该申请已经过期.")
      return ActionResult.ERROR
    if gm.status != GroupMember.STATUS_WAIT_AUDIT:
      self.addActionError(u"该申请已经过期, 不能执行拒绝操作.")
      return ActionResult.ERROR

    # 执行业务.
    self.group_svc.destroyGroupMember(gm)
    
    # 我给申请的人发送短消息
    msg = Message()
    msg.sendId = self.loginUser.userId
    msg.receiveId = self.params.getIntParam("userId")
    msg.title = u"群组申请-被婉拒!"
    msg.content = u"您申请加入的群组:" + self.group.groupTitle + u",已被创建者-婉拒!"
    self.msg_svc.sendMessage(msg)

    self.addActionMessage(u"该申请已经被拒绝.")
    return ActionResult.SUCCESS
Exemplo n.º 4
0
    def delete(self):
        score = self.params.getIntParam("score")
        reason = self.params.getStringParam("reason")
        ids = self.params.getIdList("commentId")
        if ids == None or ids.size() == 0:
            self.addActionError(u"没有选择评论")
            return ActionResult.ERROR
        oper_count = 0
        for id in ids:
            if id != None:
                comment = self.cmt_svc.getComment(id)
                if comment != None:
                    if score == None:
                        upun = self.pun_svc.createUPunishScore(
                            16, comment.id, comment.userId,
                            self.loginUser.userId, self.loginUser.trueName)
                    else:
                        if score < 0:
                            upun = self.pun_svc.createUPunishScore(
                                16, comment.id, comment.userId, -1 * score,
                                reason, self.loginUser.userId,
                                self.loginUser.trueName)
                        else:
                            upun = self.pun_svc.createUPunishScore(
                                16, comment.id, comment.userId, score, reason,
                                self.loginUser.userId, self.loginUser.trueName)
                    self.pun_svc.saveUPunishScore(upun)
                    #消息通知
                    message = Message()
                    message.sendId = self.loginUser.userId
                    message.receiveId = comment.userId
                    message.title = u"管理员删除了您的评论及扣分信息"
                    if reason != "":
                        message.content = u"您的评论" + comment.title + u"被删除,扣" + str(
                            upun.score) + u"分,原因:" + reason
                    else:
                        message.content = u"您的评论" + comment.title + u"被删除,扣" + str(
                            upun.score) + u"分"
                    self.msg_svc.sendMessage(message)

                    self.cmt_svc.deleteComment(comment)
                    oper_count = oper_count + 1
        self.addActionMessage(u"删除了" + str(oper_count) + u" 条评论")
        type = self.params.getStringParam("type")
        if type == "3":
            self.addActionLink(
                u"返回", "?cmd=list1&page=" + self.params.getStringParam("ppp"))
        elif type == "12":
            self.addActionLink(
                u"返回", "?cmd=list2&page=" + self.params.getStringParam("ppp"))
        else:
            self.addActionLink(
                u"返回", "?cmd=list1&page=" + self.params.getStringParam("ppp"))
        #self.addActionLink(ActionLink.HISTORY_BACK);
        return ActionResult.SUCCESS
Exemplo n.º 5
0
 def do_business(au, batcher, *args):
   self.art_svc.deleteArticle(au.article)
   score = self.params.getIntParam("score")
   reason = self.params.getStringParam("reason")
   if score == None:
     upun = self.pun_svc.createUPunishScore(3, au.article.id, au.article.userId,self.loginUser.userId,self.loginUser.trueName)
   else:  
     if score<0 :
       upun = self.pun_svc.createUPunishScore(3, au.article.id, au.article.userId, -1*score, reason,self.loginUser.userId,self.loginUser.trueName)
     else:
       upun = self.pun_svc.createUPunishScore(3, au.article.id, au.article.userId, score, reason,self.loginUser.userId,self.loginUser.trueName)
   self.pun_svc.saveUPunishScore(upun)
   #消息通知
   message = Message()
   message.sendId = self.loginUser.userId
   message.receiveId = au.article.userId
   message.title = u"管理员删除了您的文章及扣分信息"
   if reason != "":
     message.content = u"您的 " + au.article.title + u" 被删除,扣" + str(upun.score) + u"分,原因:" + reason
   else:  
     message.content = u"您的 " + au.article.title + u" 被删除,扣" + str(upun.score) + u"分"
   self.msg_svc.sendMessage(message)
   return True
Exemplo n.º 6
0
  def accept_req(self):
    # 得到协作组.
    if self.get_current_group() == None:
      return ActionResult.ERROR

    # 判定协作组状态.
    if self.group.groupState == Group.GROUP_STATE_LOCKED:
      self.addActionError(u"协作组 %s 被管理员锁定了, 被锁定的协作组不能加入新成员." % self.group.groupTitle)
      return ActionResult.ERROR
    if self.group.groupState != Group.GROUP_STATE_NORMAL and self.group.groupState != Group.GROUP_STATE_HIDED:
      self.addActionError(u"协作组 %s 被删除或锁定, 不能加入新成员." % self.group.groupTitle)
      return ActionResult.ERROR
    
    # 判定是否有权限管理该协作组.
    gm = self.get_group_member()
    if gm == None or gm.groupRole < GroupMember.GROUP_ROLE_VICE_MANAGER or gm.status != GroupMember.STATUS_NORMAL:
      self.addActionError(u"您不是协作组 %s 的管理员, 不能管理其组员." % self.group.groupTitle)
      return ActionResult.ERROR

    # 得到该申请.
    userId = self.params.getIntParam("userId")
    gm = self.group_svc.getGroupMemberByGroupIdAndUserId(self.group.groupId, userId)
    if gm == None:
      self.addActionError(u"未能找到该申请, 可能该申请已经过期.")
      return ActionResult.ERROR
    if gm.status != GroupMember.STATUS_WAIT_AUDIT:
      self.addActionError(u"该申请已经过期, 不能执行同意操作.")
      return ActionResult.ERROR

    # 执行业务.
    self.group_svc.auditGroupMember(gm)
    
    # 我给申请的人发送短消息
    msg = Message()
    msg.sendId = self.loginUser.userId
    msg.receiveId = self.params.getIntParam("userId")
    msg.title = u"群组申请审核通过!"
    msg.content = u"您申请加入的群组:" + self.group.groupTitle + u",已被创建者审核通过!"
    self.msg_svc.sendMessage(msg)

    self.addActionMessage(u"该申请已经审核通过.")
    return ActionResult.SUCCESS
Exemplo n.º 7
0
    def execute(self):
        self.getBaseData()
        self.prepareCourseId = self.params.getIntParam("prepareCourseId")
        if self.prepareCourseId == 0:
            self.printer.write(u"无效的备课标识。")
            return

        self.prepareCourse = self.pc_svc.getPrepareCourse(self.prepareCourseId)
        if self.prepareCourse == None:
            self.printer.write(u"没有加载到所请求的备课。")
            return

        if self.canManage(self.prepareCourse) == False:
            self.printer.write(u"您无权管理本备课。")
            return

        self.group = self.pc_svc.getGroupOfPrepareCourse(
            self.prepareCourse.prepareCourseId)
        if self.group == None:
            self.printer.write(u"集备必须是在协作组之内。")
            return

        if request.getMethod() == "POST":
            cmd = self.params.safeGetStringParam("cmd")
            if cmd == "1":
                self.delete_precarecoursevideo()
            elif cmd == "addscore":
                #加分
                score = self.params.safeGetIntParam("add_score")
                if score > 0:
                    #注意:加分是正的,保存是负的
                    score = score * -1
                #print "score="+str(score)
                score_reason = self.params.safeGetStringParam(
                    "add_score_reason")
                vId = self.params.safeGetIntValues("vId")
                for id in vId:
                    video = self.videoService.findById(id)
                    if video != None:
                        upun = self.pun_svc.createUPunishScore(
                            ObjectType.OBJECT_TYPE_VIDEO.getTypeId(), video.id,
                            video.userId, float(score), score_reason,
                            self.loginUser.userId, self.loginUser.trueName)
                        self.pun_svc.saveUPunishScore(upun)

            elif cmd == "minusscore":
                #罚分 发消息
                score = self.params.safeGetIntParam("minus_score")
                #print "score="+str(score)
                if score < 0:
                    #注意:罚分是负的,保存是正的
                    score = score * -1
                score_reason = self.params.safeGetStringParam(
                    "minus_score_reason")
                vId = self.params.safeGetIntValues("vId")
                for id in vId:
                    video = self.videoService.findById(id)
                    self.pc_svc.removePrepareCourseVideo(
                        self.prepareCourseId, id)
                    if video != None:
                        title = video.title
                        upun = self.pun_svc.createUPunishScore(
                            ObjectType.OBJECT_TYPE_VIDEO.getTypeId(), video.id,
                            video.userId, float(score), score_reason,
                            self.loginUser.userId, self.loginUser.trueName)
                        self.pun_svc.saveUPunishScore(upun)

                        #发送消息:管理员删除了您的文章/资源/视频及扣分信息,内容为您的 ***(内容标题) 被删除,罚*分,原因:***。
                        message = Message()
                        message.sendId = self.loginUser.userId
                        message.receiveId = video.userId
                        message.title = u"管理员从集备中移除了您的视频及扣分信息"
                        if score_reason != "":
                            message.content = u"您的视频" + title + u"因为:" + score_reason + u" 原因,从 " + self.prepareCourse.title + u" 中移除,并罚分" + str(
                                score) + u"分"
                        else:
                            message.content = u"您的视频 " + title + u" 从 " + self.prepareCourse.title + u" 中移除,并罚分" + str(
                                score) + u"分"
                        self.msg_svc.sendMessage(message)

        pager = self.params.createPager()
        pager.itemName = u"视频"
        pager.itemUnit = u"个"
        pager.pageSize = 10
        qry = PrepareCourseVideoQuery(
            """ u.userId,u.loginName,u.trueName,u.nickName,pcv.videoTitle,pcv.videoId,pcv.createDate,v.flvThumbNailHref,v.flvHref """
        )
        qry.prepareCourseId = self.prepareCourse.prepareCourseId
        qry.orderType = 0
        pager.totalRows = qry.count()
        pcv_list = qry.query_map(pager)

        request.setAttribute("pager", pager)
        request.setAttribute("pcv_list", pcv_list)
        request.setAttribute("group", self.group)
        request.setAttribute("prepareCourse", self.prepareCourse)

        response.setContentType("text/html; charset=UTF-8")
        return "/WEB-INF/ftl/course/manage_createPrepareCourse_VideoList.ftl"
Exemplo n.º 8
0
    def save_post(self):
        cmd = self.params.safeGetStringParam("cmd")
        guids = self.params.safeGetIntValues("guid")
        if cmd == "remove":
            for guid in guids:
                r = self.resourceService.getResource(guid)
                if r != None:
                    r.subjectId = None
                    self.resourceService.updateResource(r)
        elif cmd == "push":
            for guid in guids:
                r = self.resourceService.getResource(guid)
                if r != None and r.pushState == 0 and r.auditState == 0:
                    r.setPushState(2)
                    r.setPushUserId(self.loginUser.userId)
                    self.resourceService.updateResource(r)

        elif cmd == "unpush":
            for guid in guids:
                r = self.resourceService.getResource(guid)
                if r != None and r.pushState == 2:
                    r.setPushState(0)
                    r.setPushUserId(None)
                    self.resourceService.updateResource(r)

        elif cmd == "real_delete":
            for guid in guids:
                r = self.resourceService.getResource(guid)
                if r != None:
                    #删除资源的罚分机制
                    #upun =self.pun_svc.createUPunishScore(12,r.id,r.userId,self.loginUser.userId,self.loginUser.trueName)
                    #self.pun_svc.saveUPunishScore(upun)
                    #正式删除资源
                    self.resourceService.crashResource(r)
        elif cmd == "addscore":
            #加分
            score = self.params.safeGetIntParam("add_score")
            if score > 0:
                #注意:加分是正的,保存是负的
                score = score * -1
            #print "score="+str(score)
            score_reason = self.params.safeGetStringParam("add_score_reason")
            for guid in guids:
                r = self.resourceService.getResource(guid)
                if r != None:
                    upun = self.pun_svc.createUPunishScore(
                        ObjectType.OBJECT_TYPE_RESOURCE.getTypeId(), r.id,
                        r.userId, float(score), score_reason,
                        self.loginUser.userId, self.loginUser.trueName)
                    self.pun_svc.saveUPunishScore(upun)
        elif cmd == "minusscore":
            #罚分 并删除删除文章,发消息
            score = self.params.safeGetIntParam("minus_score")
            #print "score="+str(score)
            if score < 0:
                #注意:罚分是负的,保存是正的
                score = score * -1
            score_reason = self.params.safeGetStringParam("minus_score_reason")
            for guid in guids:
                r = self.resourceService.getResource(guid)
                if r != None:
                    title = r.title
                    upun = self.pun_svc.createUPunishScore(
                        ObjectType.OBJECT_TYPE_RESOURCE.getTypeId(), r.id,
                        r.userId, float(score), score_reason,
                        self.loginUser.userId, self.loginUser.trueName)
                    self.pun_svc.saveUPunishScore(upun)

                    #发送消息:管理员删除了您的文章/资源/视频及扣分信息,内容为您的 ***(内容标题) 被删除,罚*分,原因:***。
                    message = Message()
                    message.sendId = self.loginUser.userId
                    message.receiveId = r.userId
                    message.title = u"管理员删除了您的资源及扣分信息"
                    if score_reason != "":
                        message.content = u"您的资源" + title + u" 被删除,扣" + str(
                            score) + u"分,原因:" + score_reason
                    else:
                        message.content = u"您的资源 " + title + u" 被删除,扣" + str(
                            score) + u"分"
                    self.msg_svc.sendMessage(message)

                    #删除
                    self.resourceService.crashResource(r)
                    #self.resourceService.deleteResource(r)
        elif cmd == "select_type":
            cmd_type = self.params.safeGetStringParam("cmdtype")
            if cmd_type == "":
                return
            for guid in guids:
                r = self.resourceService.getResource(guid)
                if r != None:
                    if cmd_type == "approve":
                        r.setApprovedPathInfo(r.getOrginPathInfo())
                        self.resourceService.updateResource(r)
                        self.resourceService.auditResource(r)
                    elif cmd_type == "unapprove":
                        r.setApprovedPathInfo(None)
                        self.resourceService.updateResource(r)
                        self.resourceService.unauditResource(r)
                    elif cmd_type == "rcmd":
                        r.setRcmdPathInfo(r.getOrginPathInfo())
                        self.resourceService.updateResource(r)
                        self.resourceService.rcmdResource(r)
                    elif cmd_type == "unrcmd":
                        r.setRcmdPathInfo(None)
                        self.resourceService.updateResource(r)
                        self.resourceService.unrcmdResource(r)
                    elif cmd_type == "delete":
                        self.resourceService.deleteResource(r)
                    elif cmd_type == "undelete":
                        self.resourceService.recoverResource(r)
Exemplo n.º 9
0
    def save_post(self):        
        cmd = self.params.safeGetStringParam("cmd")

        guids = self.params.safeGetIntValues("guid")
        if cmd == "remove":
            for guid in guids:
                art = self.articleService.getArticle(guid)
                if art != None:
                    art.subjectId = None
                    self.articleService.updateArticle(art)
        elif cmd == "push":
            for guid in guids:
                art = self.articleService.getArticle(guid)
                if art != None:
                    # print art.auditState
                    if art.pushState == 0 and art.auditState == Article.AUDIT_STATE_OK:
                        art.setPushState(2)
                        art.setPushUserId(self.loginUser.userId)
                        self.articleService.updateArticle(art)
                    
        elif cmd == "unpush":
            for guid in guids:
                art = self.articleService.getArticle(guid)
                if art != None:
                    if art.pushState == 2:
                        art.setPushState(0)
                        art.setPushUserId(None)
                        self.articleService.updateArticle(art)
                    
        elif cmd == "real_delete":
            for guid in guids:
                art = self.articleService.getArticle(guid)
                if art != None:   
                    #self.loginUser.userId==art.userId
                    #删除文章的罚分机制
                    #upun =self.pun_svc.createUPunishScore(3,art.id,art.userId)
                    #self.pun_svc.saveUPunishScore(upun)
                    #正式删除文章                 
                    self.articleService.crashArticle(art) 
        elif cmd == "addscore":
            #加分
            score = self.params.safeGetIntParam("add_score")
            if score>0:
                #注意:加分是正的,保存是负的
                score = score*-1   
            #print "score="+str(score)
            score_reason = self.params.safeGetStringParam("add_score_reason")
            for guid in guids:
                art = self.articleService.getArticle(guid)
                if art != None:   
                    upun =self.pun_svc.createUPunishScore(ObjectType.OBJECT_TYPE_ARTICLE.getTypeId(),art.id,art.userId,float(score),score_reason,self.loginUser.userId,self.loginUser.trueName)
                    self.pun_svc.saveUPunishScore(upun)
        elif cmd == "minusscore":
            #罚分 并删除删除文章,发消息
            score = self.params.safeGetIntParam("minus_score")
            #print "score="+str(score)
            if score<0:
                #注意:罚分是负的,保存是正的
                score = score*-1   
            score_reason = self.params.safeGetStringParam("minus_score_reason")
            for guid in guids:
                art = self.articleService.getArticle(guid)
                if art != None:
                    title=art.title
                    upun =self.pun_svc.createUPunishScore(ObjectType.OBJECT_TYPE_ARTICLE.getTypeId(),art.id,art.userId,float(score),score_reason,self.loginUser.userId,self.loginUser.trueName)
                    self.pun_svc.saveUPunishScore(upun)
                    
                    #发送消息:管理员删除了您的文章/资源/视频及扣分信息,内容为您的 ***(内容标题) 被删除,罚*分,原因:***。
                    message = Message()
                    message.sendId = self.loginUser.userId
                    message.receiveId = art.userId
                    message.title = u"管理员删除了您的文章及扣分信息"
                    if score_reason != "":
                        message.content = u"您的文章 " + title + u" 被删除,扣" + str(score) + u"分,原因:" + score_reason
                    else:  
                        message.content = u"您的文章 " + title + u" 被删除,扣" + str(score) + u"分"
                    self.msg_svc.sendMessage(message)
                   
                    #删除文章                 
                    self.articleService.crashArticle(art) 
                    #self.articleService.deleteArticle(art)
        elif cmd == "select_type":
            cmd_type = self.params.safeGetStringParam("cmdtype")
            if cmd_type == "":
                return
            for guid in guids:
                art = self.articleService.getArticle(guid)
                if art != None:
                    if cmd_type == "approve":                        
                        art.setApprovedPathInfo(art.getOrginPath())                        
                        self.articleService.updateArticle(art)
                        self.articleService.auditArticle(art)
                    elif cmd_type == "unapprove":
                        art.setApprovedPathInfo(None)                        
                        self.articleService.updateArticle(art)
                        self.articleService.unauditArticle(art)
                    elif cmd_type == "best":
                        self.articleService.bestArticle(art)
                    elif cmd_type == "unbest":
                        self.articleService.unbestArticle(art)
                    elif cmd_type == "rcmd":
                        art.setRcmdPathInfo(art.getOrginPath())  
                        self.articleService.updateArticle(art)                        
                        self.articleService.rcmdArticle(art)
                    elif cmd_type == "unrcmd":
                        art.setRcmdPathInfo(None)  
                        self.articleService.updateArticle(art)
                        self.articleService.unrcmdArticle(art)
                    elif cmd_type == "delete":
                        self.articleService.deleteArticle(art)
                    elif cmd_type == "undelete":
                        self.articleService.recoverArticle(art)            
Exemplo n.º 10
0
# coding=utf-8
Exemplo n.º 11
0
    def execute(self):
        self.getBaseData()
        self.prepareCourseId = self.params.getIntParam("prepareCourseId")
        if self.prepareCourseId == 0:
            self.printer.write(u"无效的备课标识。")
            return

        prepareCourse = self.getBasePrepareCourse()
        if prepareCourse == None:
            self.printer.write(u"没有加载到所请求的备课。")
            return

        if self.canManage(prepareCourse) == False:
            self.printer.write(u"您无权管理本备课。")
            return

        if request.getMethod() == "POST":
            cmd = self.params.safeGetStringParam("cmd")
            if cmd == "delete":
                prepareCourseArticleId = self.params.safeGetIntValues(
                    "prepareCourseArticleId")
                for id in prepareCourseArticleId:
                    self.pc_svc.deleteArticleToPrepareCourseStageById(id)
            elif cmd == "move":
                destStageId = self.params.safeGetIntParam("stageId")
                if destStageId > 0:
                    prepareCourseArticleId = self.params.safeGetIntValues(
                        "prepareCourseArticleId")
                    for id in prepareCourseArticleId:
                        self.pc_svc.moveArticleToPrepareCourseStageById(
                            id, destStageId)
            elif cmd == "addscore":
                #加分
                score = self.params.safeGetIntParam("add_score")
                if score > 0:
                    #注意:加分是正的,保存是负的
                    score = score * -1
                #print "score="+str(score)
                score_reason = self.params.safeGetStringParam(
                    "add_score_reason")
                prepareCourseArticleId = self.params.safeGetIntValues(
                    "prepareCourseArticleId")
                for id in prepareCourseArticleId:
                    prepareCourseArticle = self.pc_svc.getPrepareCourseArticle(
                        id)
                    art = self.articleService.getArticle(
                        prepareCourseArticle.articleId)
                    if art != None:
                        upun = self.pun_svc.createUPunishScore(
                            ObjectType.OBJECT_TYPE_ARTICLE.getTypeId(), art.id,
                            art.userId, float(score), score_reason,
                            self.loginUser.userId, self.loginUser.trueName)
                        self.pun_svc.saveUPunishScore(upun)

            elif cmd == "minusscore":
                #罚分 并删除删除文章,发消息
                score = self.params.safeGetIntParam("minus_score")
                #print "score="+str(score)
                if score < 0:
                    #注意:罚分是负的,保存是正的
                    score = score * -1
                score_reason = self.params.safeGetStringParam(
                    "minus_score_reason")
                prepareCourseArticleId = self.params.safeGetIntValues(
                    "prepareCourseArticleId")
                for id in prepareCourseArticleId:
                    prepareCourseArticle = self.pc_svc.getPrepareCourseArticle(
                        id)
                    if prepareCourseArticle != None:
                        art = self.articleService.getArticle(
                            prepareCourseArticle.articleId)
                        self.pc_svc.deleteArticleToPrepareCourseStageById(id)
                        if art != None:
                            title = art.title
                            upun = self.pun_svc.createUPunishScore(
                                ObjectType.OBJECT_TYPE_ARTICLE.getTypeId(),
                                art.id, art.userId, float(score), score_reason,
                                self.loginUser.userId, self.loginUser.trueName)
                            self.pun_svc.saveUPunishScore(upun)

                            message = Message()
                            message.sendId = self.loginUser.userId
                            message.receiveId = art.userId
                            message.title = u"管理员从集备中移除了您的文章及扣分信息"
                            if score_reason != "":
                                message.content = u"您发布的文章 " + title + u"因为:" + score_reason + u" 原因,从 " + prepareCourse.title + u" 中移除,并罚分" + str(
                                    score) + u"分"
                            else:
                                message.content = u"您发布的文章 " + title + u" 从 " + prepareCourse.title + u" 中移除,并罚分" + str(
                                    score) + u"分"
                            self.msg_svc.sendMessage(message)

        prepareCourseStageList = self.pc_svc.getPrepareCourseStageList(
            self.prepareCourseId)
        pager = self.params.createPager()
        pager.itemName = u"文章"
        pager.itemUnit = u"篇"
        qry = PrepareArticleQuery(
            """ pca.prepareCourseArticleId,pca.title,pca.userId,pca.articleId,pca.createDate,pcs.title as pcsTitle """
        )
        qry.prepareCourseId = prepareCourse.prepareCourseId
        pager.totalRows = qry.count()
        article_list = qry.query_map(pager)

        request.setAttribute("pager", pager)
        request.setAttribute("article_list", article_list)
        request.setAttribute("stage_list", prepareCourseStageList)
        request.setAttribute("prepareCourse", prepareCourse)
        response.setContentType("text/html; charset=UTF-8")
        return "/WEB-INF/ftl/course/manage_createPrepareCourse_article.ftl"
Exemplo n.º 12
0
    def save_post(self):
        cmd = self.params.safeGetStringParam("cmd")
        guids = self.params.safeGetIntValues("guid")
        videoService = __spring__.getBean("videoService")

        if cmd == "remove":
            for g in guids:
                video = videoService.findById(g)
                if video != None:
                    video.setSubjectId(0)
                    videoService.updateVideo(video)

        if cmd == "approve":
            for g in guids:
                video = videoService.findById(g)
                if video != None:
                    videoService.auditVideo(video)

        if cmd == "unapprove":
            for g in guids:
                video = videoService.findById(g)
                if video != None:
                    #删除资源的罚分机制
                    #upun =self.pun_svc.createUPunishScore(17,video.id,video.userId,self.loginUser.userId,self.loginUser.trueName)
                    #self.pun_svc.saveUPunishScore(upun)
                    #正式删除资源
                    videoService.unauditVideo(video)
        elif cmd == "addscore":
            #加分
            score = self.params.safeGetIntParam("add_score")
            if score > 0:
                #注意:加分是正的,保存是负的
                score = score * -1
            #print "score="+str(score)
            score_reason = self.params.safeGetStringParam("add_score_reason")
            for guid in guids:
                video = videoService.findById(guid)
                if video != None:
                    upun = self.pun_svc.createUPunishScore(
                        ObjectType.OBJECT_TYPE_VIDEO.getTypeId(), video.id,
                        video.userId, float(score), score_reason,
                        self.loginUser.userId, self.loginUser.trueName)
                    self.pun_svc.saveUPunishScore(upun)
        elif cmd == "minusscore":
            #罚分 并删除删除文章,发消息
            score = self.params.safeGetIntParam("minus_score")
            #print "score="+str(score)
            if score < 0:
                #注意:罚分是负的,保存是正的
                score = score * -1
            score_reason = self.params.safeGetStringParam("minus_score_reason")
            for guid in guids:
                video = videoService.findById(guid)
                if video != None:
                    title = video.title
                    upun = self.pun_svc.createUPunishScore(
                        ObjectType.OBJECT_TYPE_VIDEO.getTypeId(), video.id,
                        video.userId, float(score), score_reason,
                        self.loginUser.userId, self.loginUser.trueName)
                    self.pun_svc.saveUPunishScore(upun)

                    #发送消息:管理员删除了您的文章/资源/视频及扣分信息,内容为您的 ***(内容标题) 被删除,罚*分,原因:***。
                    message = Message()
                    message.sendId = self.loginUser.userId
                    message.receiveId = video.userId
                    message.title = u"管理员删除了您的视频及扣分信息"
                    if score_reason != "":
                        message.content = u"您的视频" + title + u" 被删除,扣" + str(
                            score) + u"分,原因:" + score_reason
                    else:
                        message.content = u"您的视频 " + title + u" 被删除,扣" + str(
                            score) + u"分"
                    self.msg_svc.sendMessage(message)

                    #删除
                    videoService.delVideo(video)
                    #videoService.delVideo(video)
        if cmd == "real_delete":
            for g in guids:
                video = videoService.findById(g)
                if video != None:
                    videoService.delVideo(video)