class showPrepareCourseCommonContent(PrepareCoursePageService):
    def __init__(self):
        self.params = ParamUtil(request)
        self.pc_svc = __jitar__.getPrepareCourseService()
        self.user_svc = __jitar__.getUserService()
        self.printer = MessagePrint()

    def execute(self):
        site_config = SiteConfig()
        site_config.get_config()

        self.prepareCourseId = self.params.getIntParam("prepareCourseId")
        self.prepareCourse = self.pc_svc.getPrepareCourse(self.prepareCourseId)

        if self.prepareCourse == None:
            self.printer.addMessage(u"未能加载备课。请重新选择一次备课。")
            return self.printer.printMessage(
                "manage/course/showPrepareCourse.py?prepareCourseId=" +
                str(self.prepareCourseId), "")

        qry = PrepareCourseMemberQuery(
            """ u.userId, u.userIcon, u.loginName,u.trueName,u.nickName""")
        qry.prepareCourseId = self.prepareCourse.prepareCourseId
        user_list = qry.query_map()
        prepareCourseEdit_list = self.pc_svc.getPrepareCourseEditList(
            self.prepareCourseId)
        request.setAttribute("prepareCourseEdit_list", prepareCourseEdit_list)
        request.setAttribute("user_list", user_list)
        if self.loginUser != None:
            request.setAttribute("loginUser", self.loginUser)
        request.setAttribute("prepareCourse", self.prepareCourse)
        request.setAttribute("head_nav", "cocourses")
        return "/WEB-INF/ftl/course/showPrepareCourseCommonContent.ftl"
예제 #2
0
 def __init__(self):
     self.pc_svc = __jitar__.getPrepareCourseService()
     self.user_svc = __jitar__.getUserService()
     self.sbj_svc = __jitar__.getSubjectService()
     self.act_svc = __jitar__.getActionService()
     self.page_svc = __jitar__.getPageService()
     self.printer = MessagePrint()
예제 #3
0
 def __init__(self):
     self.params = ParamUtil(request)
     self.pc_svc = __jitar__.getPrepareCourseService()
     self.sbj_svc = __jitar__.getSubjectService()
     self.printer = MessagePrint()
     self.out = response.getWriter()
예제 #4
0
 def __init__(self):
     self.params = ParamUtil(request)
     self.pc_svc = __jitar__.getPrepareCourseService()
     self.user_svc = __jitar__.getUserService()
     self.printer = MessagePrint()
예제 #5
0
class showPrepareCourseStage(BaseAction):
    def __init__(self):
        self.params = ParamUtil(request)
        self.pc_svc = __jitar__.getPrepareCourseService()
        self.user_svc = __jitar__.getUserService()
        self.printer = MessagePrint()
        
    def execute(self):
        if self.loginUser == None:            
            self.printer.addMessage(u"请先<a href='../../login.jsp'>登录</a>,然后才能操作")
            return self.printer.printMessage("login.jsp","")
        site_config = SiteConfig()
        site_config.get_config()
        

        self.prepareCourseId =  self.params.getIntParam("prepareCourseId")
        self.prepareCourseStageId =  self.params.getIntParam("stageId")
        self.prepareCourse = self.pc_svc.getPrepareCourse(self.prepareCourseId)
        self.prepareCourseStage = self.pc_svc.getPrepareCourseStage(self.prepareCourseStageId)
        if self.prepareCourse == None:
            self.printer.addMessage(u"未能加载备课。请重新选择一次备课。")
            return self.printer.printMessage("cocourses.action","")
        
        if self.prepareCourseStage == None:
            self.printer.addMessage(u"未能加载备课阶段,请选择一个阶段。")
            return self.printer.printMessage("cocourses.action","")
        
        if self.isCourseMember() == "false":
            self.printer.addMessage(u"只有管理员和备课组成员才可以查看。")
            return self.printer.printMessage("manage/course/showPrepareCourse.py?prepareCourseId=" + str(self.prepareCourseId),"")
        
        if request.getMethod() == "POST":
            self.saveOrUpdate()
            
        request.setAttribute("loginUser", self.loginUser) 
        request.setAttribute("prepareCourse", self.prepareCourse)
        request.setAttribute("prepareCourseStage", self.prepareCourseStage)
        request.setAttribute("head_nav", "cocourses")
        request.setAttribute("prepareCourseStageId", self.prepareCourseStageId)
        request.setAttribute("prepareCourseId", self.prepareCourseId) 
        
        precs_list = self.pc_svc.getPrepareCourseStageList(self.prepareCourseId)        
        pcs_rpl_list = self.pc_svc.getPrepareCourseStageReplyList(self.prepareCourseStageId)
        #print "prepareCourseStageId",self.prepareCourseStageId
        #print "pcs_rpl_list",pcs_rpl_list
        request.setAttribute("precoursestage_list", precs_list)
        request.setAttribute("pcs_rpl_list", pcs_rpl_list)             
    
        return "/WEB-INF/ftl/course/course_stage_show.ftl" 
        
        
    def saveOrUpdate(self):
        # 判断是否是当前的备课,判断是否是成员
        
        stagePostTitle = self.params.safeGetStringParam("stagePostTitle")
        stagePostComment = self.params.safeGetStringParam("stagePostComment")
        if stagePostTitle == None or stagePostTitle == "":
            self.printer.addMessage(u"请输入讨论标题。")
            return self.printer.printMessage("manage/course/showPrepareCourseStage.py?stageId=" + str(self.prepareCourseStageId) + "&prepareCourseId=" + str(self.prepareCourseId),"")
        
        if stagePostComment == None or stagePostComment == "":
            self.printer.addMessage(u"请输入讨论内容。")
            return self.printer.printMessage("manage/course/showPrepareCourseStage.py?stageId=" + str(self.prepareCourseStageId) + "&prepareCourseId=" + str(self.prepareCourseId),"")
                
        prepareCourseStageReply = PrepareCourseStageReply()        
        prepareCourseStageReply.setPrepareCourseStageId(self.prepareCourseStageId)
        prepareCourseStageReply.setPrepareCourseId(self.prepareCourseId)
        prepareCourseStageReply.setTitle(stagePostTitle)
        prepareCourseStageReply.setUserId(self.loginUser.userId)
        prepareCourseStageReply.setCreateDate(Date())
        prepareCourseStageReply.setContent(stagePostComment)
        self.pc_svc.createPrepareCourseStageReply(prepareCourseStageReply)
        self.pc_svc.updateReplyCount(self.prepareCourseId,self.loginUser.userId)
        #return "/WEB-INF/ftl/course/course_stage_show.ftl" 
    
    # 当前登录用户是否是管理员
    def canAdmin(self):
        accessControlService = __spring__.getBean("accessControlService")
        if self.loginUser.userId == self.prepareCourse.createUserId or accessControlService.isSystemAdmin(self.loginUser):
            return "true"
        else:
            return "false"

    # 当前登录用户是否是该备课的成员
    def isCourseMember(self):
        ismember = "false"
        if self.loginUser == None:
            return ismember
        if self.canAdmin() == "true":
            return "true"
        ismember = self.pc_svc.checkUserInPreCourse(self.prepareCourse.prepareCourseId, self.loginUser.userId)
        return ismember
예제 #6
0
class createPreCourse2(SubjectMixiner, BaseAction):
    def __init__(self):
        self.params = ParamUtil(request)
        self.pc_svc = __jitar__.getPrepareCourseService()
        self.user_svc = __jitar__.getUserService()
        self.printer = MessagePrint()

    def execute(self):
        if self.loginUser == None:
            self.printer.addMessage(
                u"请先<a href='../../login.jsp'>登录</a>,然后才能操作")
            return self.printer.printMessage("login.jsp", "")

        self.prepareCourseId = self.params.getIntParam("prepareCourseId")
        self.prepareCourse = self.pc_svc.getPrepareCourse(self.prepareCourseId)
        self.cmd = request.getParameter("cmd")

        if self.prepareCourse == None:
            self.printer.addMessage(u"未能加载备课。请重新选择一次备课。")
            return self.printer.printMessage("cocourses.action", "")

        # 只有 admin 和 创建者才能进行编辑
        accessControlService = __spring__.getBean("accessControlService")
        if not (accessControlService.isSystemAdmin(self.loginUser) or
                self.loginUser.loginUserId == self.prepareCourse.createUserId):
            self.printer.addMessage(u"只有管理员和创建者才能进行操作。")
            return self.printer.printMessage(
                "manage/course/createPreCourse2.py?prepareCourseId=" +
                str(self.prepareCourseId), "")

        request.setAttribute("loginUser", self.loginUser)
        request.setAttribute("prepareCourseId", self.prepareCourseId)
        request.setAttribute("prepareCourse", self.prepareCourse)

        if request.getMethod() == "POST":
            if self.cmd == "add":
                return self.saveOrUpdatePrepareCourse()
            elif self.cmd == "delete":
                return self.deleteUser()
            else:
                self.printer.addMessage(u"无效的命令。")
                return self.printer.printMessage(
                    "manage/course/createPreCourse2.py?prepareCourseId=" +
                    str(self.prepareCourseId), "")
        else:
            return self.getPrepareCourse()

    def getPrepareCourse(self):
        site_config = SiteConfig()
        site_config.get_config()
        qry = PrepareCourseMemberQuery(
            """  u.userId, u.loginName,u.trueName,u.nickName,u.unitId, unit.unitName """
        )
        qry.prepareCourseId = self.prepareCourseId
        user_list = qry.query_map()
        request.setAttribute("user_list", user_list)
        request.setAttribute("head_nav", "cocourses")
        return "/WEB-INF/ftl/course/course_create2.ftl"

    def deleteUser(self):
        user_list_delete = request.getParameterValues("guid")
        for u in user_list_delete:
            # 不能删除创建者
            if int(u) != self.prepareCourse.createUserId:
                self.pc_svc.deletePrepareCourseMember(self.prepareCourseId,
                                                      int(u))

        self.printer.addMessage(u"删除用户成功。")
        return self.printer.printMessage(
            "manage/course/createPreCourse2.py?prepareCourseId=" +
            str(self.prepareCourseId), "")

    def saveOrUpdatePrepareCourse(self):
        userLoginName = self.params.safeGetStringParam("userLoginName")
        if userLoginName == None or userLoginName == "":
            self.printer.addMessage(u"请输入一个用户的登录名。")
            return self.printer.printMessage(
                "manage/course/createPreCourse2.py?prepareCourseId=" +
                str(self.prepareCourseId), "")

        # 判断用户是否真实存在,并是有效的用户。
        user = self.user_svc.getUserByLoginName(userLoginName)
        if user == None:
            self.printer.addMessage(u"您输入的用户不存在。")
            return self.printer.printMessage(
                "manage/course/createPreCourse2.py?prepareCourseId=" +
                str(self.prepareCourseId), "")

        # 判断该用户是否已经在此备课中
        if self.pc_svc.checkUserInPreCourse(self.prepareCourseId, user.userId):
            self.printer.addMessage(u"该用户已经存在。")
            return self.printer.printMessage(
                "manage/course/createPreCourse2.py?prepareCourseId=" +
                str(self.prepareCourseId), "")

        # 将用户加入到用户表中
        pcm = PrepareCourseMember()
        pcm.setPrepareCourseId(self.prepareCourseId)
        pcm.setUserId(user.userId)
        pcm.setReplyCount(0)
        self.pc_svc.addPrepareCourseMember(pcm)
        self.printer.addMessage(u"将用户 " + user.trueName + u"(登录名为 " +
                                user.loginName + u") 添加到备课 " +
                                self.prepareCourse.title + u" 成功。")
        return self.printer.printMessage(
            "manage/course/createPreCourse2.py?prepareCourseId=" +
            str(self.prepareCourseId), "")
예제 #7
0
class editCommonPreCourse(BaseAction):
    def __init__(self):
        self.params = ParamUtil(request)
        self.pc_svc = __jitar__.getPrepareCourseService()
        self.printer = MessagePrint()

    def execute(self):
        if self.loginUser == None:
            self.printer.addMessage(
                u"请先<a href='../../login.jsp'>登录</a>,然后才能操作")
            return self.printer.printMessage("login.jsp", "")
        site_config = SiteConfig()
        site_config.get_config()

        self.prepareCourseId = self.params.getIntParam("prepareCourseId")
        self.prepareCourse = self.pc_svc.getPrepareCourse(self.prepareCourseId)

        if self.prepareCourse == None:
            self.printer.addMessage(u"未能加载备课。请重新选择一次备课。")
            return self.printer.printMessage(
                "manage/course/showPrepareCourse.py?prepareCourseId=" +
                str(self.prepareCourseId), "")

        if self.canAdmin() == "false":
            self.printer.addMessage(u"只有 管理员 和 主备人(备课创建者)才可以修改。")
            return self.printer.printMessage(
                "manage/course/showPrepareCourse.py?prepareCourseId=" +
                str(self.prepareCourseId), "")

        if request.getMethod() == "POST":
            return self.saveOrUpdate()

        request.setAttribute("loginUser", self.loginUser)
        request.setAttribute("prepareCourse", self.prepareCourse)
        request.setAttribute("head_nav", "cocourses")
        return "/WEB-INF/ftl/course/common_course_edit.ftl"

    def saveOrUpdate(self):
        commonContent = self.params.safeGetStringParam("commonContent")

        if commonContent == None or commonContent == "":
            self.printer.addMessage(u"请输入共案内容。")
            return self.printer.printMessage(
                "manage/course/showPrepareCourse.py?prepareCourseId=" +
                str(self.prepareCourseId), "")

        self.prepareCourse.setCommonContent(commonContent)
        self.pc_svc.updatePrepareCourse(self.prepareCourse)

        self.printer.addMessage(u"操作成功。")
        self.printer.msgDesc = ""
        return self.printer.printMessage(
            "manage/course/showPrepareCourse.py?prepareCourseId=" +
            str(self.prepareCourseId), "")

    def canAdmin(self):
        accessControlService = __spring__.getBean("accessControlService")
        if self.loginUser.userId == self.prepareCourse.createUserId or accessControlService.isSystemAdmin(
                self.loginUser):
            return "true"
        else:
            return "false"
예제 #8
0
class coEditCommonPrepareCourse(BaseAction):
    def __init__(self):
        self.prepareCourseEdit = None
        self.params = ParamUtil(request)
        self.pc_svc = __jitar__.getPrepareCourseService()
        self.user_svc = __jitar__.getUserService()
        self.printer = MessagePrint()

    def execute(self):
        if self.loginUser == None:
            self.printer.addMessage(
                u"请先<a href='../../login.jsp'>登录</a>,然后才能编辑")
            return self.printer.printMessage("login.jsp", "")
        site_config = SiteConfig()
        site_config.get_config()

        self.prepareCourseId = self.params.getIntParam("prepareCourseId")
        self.prepareCourse = self.pc_svc.getPrepareCourse(self.prepareCourseId)

        if self.prepareCourse == None:
            self.printer.addMessage(u"未能加载备课。请重新选择一次备课。")
            return self.printer.printMessage(
                "p/" + str(self.prepareCourse.prepareCourseId) + "/0/", "")

        if self.canAdmin() == "false":
            self.printer.addMessage(u"只有 管理员 和 主备人(备课创建者)才可以修改。")
            return self.printer.printMessage(
                "p/" + str(self.prepareCourse.prepareCourseId) + "/0/", "")

        #self.prepareCourseEdit = self.pc_svc.getLastestPrepareCourseEdit(self.prepareCourseId, self.loginUser.userId)

        if self.prepareCourse.lockedUserId > 0 and self.prepareCourse.lockedUserId != self.loginUser.userId:
            user = self.user_svc.getUserById(self.prepareCourse.lockedUserId)
            if user == None:
                self.printer.addMessage(u"此备课已经被 未知的人 签出,你暂时不能进行编辑该备课。")
            else:
                self.printer.addMessage(u"此备课已经被 " + user.trueName +
                                        u" 签出,你暂时不能进行编辑该备课。")
            return self.printer.printMessage(
                "p/" + str(self.prepareCourse.prepareCourseId) + "/0/", "")
        else:
            #设置锁标记

            self.prepareCourse.setLockedUserId(self.loginUser.userId)
            self.prepareCourse.setLockedDate(Date())
            self.pc_svc.updatePrepareCourse(self.prepareCourse)

        if request.getMethod() == "POST":
            return self.saveOrUpdate()

        prepareCourseEdit_list = self.pc_svc.getPrepareCourseEditList(
            self.prepareCourseId)
        request.setAttribute("prepareCourseEdit_list", prepareCourseEdit_list)
        request.setAttribute("loginUser", self.loginUser)
        request.setAttribute("prepareCourse", self.prepareCourse)
        request.setAttribute("head_nav", "cocourses")
        return "/WEB-INF/ftl/course/coEditCommonPrepareCourse.ftl"

    def saveOrUpdate(self):
        commonContent = self.params.safeGetStringParam("commonContent")
        optype = self.params.getIntParam("optype")
        if optype == 0:
            if commonContent == None or commonContent == "":
                self.printer.addMessage(u"请输入共案内容。")
                return self.printer.printMessage(
                    "manage/course/showPrepareCourse.py?prepareCourseId=" +
                    str(self.prepareCourseId), "")
            if self.prepareCourse.lockedUserId != self.loginUser.userId:
                user = self.user_svc.getUserById(
                    self.prepareCourse.lockedUserId)
                if user == None:
                    self.printer.addMessage(u"本次编辑已经被 未知的人 签出。")
                else:
                    self.printer.addMessage(u"本次编辑已经被 " + user.trueName +
                                            u" 签出。")
                return self.printer.printMessage(
                    "p/" + str(self.prepareCourse.prepareCourseId) + "/0/", "")

            self.prepareCourseEdit = PrepareCourseEdit()
            self.prepareCourseEdit.setContent(commonContent)
            self.prepareCourseEdit.setEditDate(Date())
            self.prepareCourseEdit.setLockStatus(0)
            self.prepareCourseEdit.setEditUserId(self.loginUser.userId)
            self.prepareCourseEdit.setPrepareCourseId(self.prepareCourseId)
            self.pc_svc.updatePrepareCourseEdit(self.prepareCourseEdit)

            self.prepareCourse.setLockedUserId(0)
            self.prepareCourse.setCommonContent(commonContent)
            self.prepareCourse.setPrepareCourseEditId(
                self.prepareCourseEdit.prepareCourseEditId)
            self.pc_svc.updatePrepareCourse(self.prepareCourse)
        else:
            self.prepareCourse.setLockedUserId(0)
            self.pc_svc.updatePrepareCourse(self.prepareCourse)

        self.printer.addMessage(u"操作成功。")
        self.printer.msgDesc = ""
        return self.printer.printMessage(
            "p/" + str(self.prepareCourse.prepareCourseId) + "/0/", "")
예제 #9
0
 def __init__(self):        
     self.act_svc = __jitar__.actionService  
     self.ERROR_FTL = "/WEB-INF/ftl/action/error.ftl"
     self.MsgPrint = MessagePrint()
예제 #10
0
class createAction(BaseAction, RequestMixiner, ResponseMixiner, PageCheckMixiner):
    
    grp_svc = __jitar__.groupService
    user_svc = __jitar__.userService
    pc_svc = __jitar__.getPrepareCourseService()
    
    def __init__(self):        
        self.act_svc = __jitar__.actionService  
        self.ERROR_FTL = "/WEB-INF/ftl/action/error.ftl"
        self.MsgPrint = MessagePrint()
    
    def execute(self):
        self.params = ParamUtil(request)
        self.out = response.writer
        if self.loginUser == None:
            self.MsgPrint.addMessage(u"请先<a href='../../login.jsp'>登录</a>,然后才能创建活动")            
            return self.MsgPrint.printMessage("login.jsp", "back")
        
        site_config = SiteConfig()
        site_config.get_config()

        # 活动必须属于一个类别,如user,group,course等
        self.ownerId = self.params.getIntParam("ownerId")     
        self.ownerType = self.params.getStringParam("ownerType")
        
        if self.ownerId == None or self.ownerId == 0:
            self.MsgPrint.addMessage(u"缺少类别标识。")
            self.MsgPrint.hasError = True
        if self.ownerType == None or self.ownerType == "":
            self.MsgPrint.hasError = True
            self.MsgPrint.addMessage(u"缺少类别名称。")        
        
        #限定活动的范围,
        if self.ownerType != "user" and self.ownerType != "group" and self.ownerType != "preparecourse" and self.ownerType != "subject":
            self.MsgPrint.hasError = True
            self.MsgPrint.addMessage(u"活动类别必须是个人、协作组、集备、学科。")
            
        if self.MsgPrint.hasError == True:
            return self.MsgPrint.printMessage("actions.py.py", "back")
        
        self.ownerId = self.get_owner_entity_id()
        
        if self.ownerId == -1:
            self.MsgPrint.addMessage(u"您没有创建活动的权限。")
            self.MsgPrint.hasError = True

        if self.MsgPrint.hasError == True:
            return self.MsgPrint.printMessage("", "back")
        
        request.setAttribute("ownerId", self.ownerId)
        request.setAttribute("ownerType", self.ownerType)
        
        if request.getMethod() == "POST":
            return self.actionPost()
        else:
            return self.actionGet()        
    
    def actionGet(self):
        response.setContentType("text/html; charset=UTF-8")
        cal = Calendar.getInstance()
        request.setAttribute("year", cal.get(Calendar.YEAR))
        return "/WEB-INF/ftl/action/action_create.ftl"
    
    def actionPost(self):
        title = self.params.getStringParam("actionName")
        if len(title) == 0 :
            self.MsgPrint.hasError = True
            self.MsgPrint.addMessage(u"请输入标题。")
        actionDescription = self.params.getStringParam("actionDescription")
        if len(actionDescription) == 0 :
            self.MsgPrint.hasError = True
            self.MsgPrint.addMessage(u"请输入活动描述。")            
        
        actionType = self.params.getIntParam("actionType")
        if actionType == None:
            self.MsgPrint.hasError = True
            self.MsgPrint.addMessage(u"请选项活动类型。")
        
        visibility = self.params.getIntParam("actionVisibility")        
        if visibility == None:
            self.MsgPrint.hasError = True
            self.MsgPrint.addMessage(u"请选项活动方式。")
        
        userLimit = self.params.getIntParam("actionUserLimit")
        if userLimit == None :
            self.MsgPrint.hasError = True
            self.MsgPrint.addMessage(u"请输入活动的限制人数。")
        
        actionStartDateTime = self.validate_input_datetime("actionStartDateTime")
        actionFinishDateTime = self.validate_input_datetime("actionFinishDateTime")
        attendLimitDateTime = self.validate_input_datetime("attendLimitDateTime")
        
        if DateUtil.compareDateTime(actionStartDateTime, actionFinishDateTime) > 0 :
            self.MsgPrint.hasError = True
            self.MsgPrint.addMessage(u"活动开始日期不能大于结束日期。")
        
        if DateUtil.compareDateTime(attendLimitDateTime, actionFinishDateTime) > 0 :
            self.MsgPrint.hasError = True
            self.MsgPrint.addMessage(u"活动报名截止日期不能大于结束日期。")
        
        if self.MsgPrint.hasError == True:
            return self.MsgPrint.printMessage("", "back")
        
        self.action = Action()
        self.action.title = title
        # 群组id,用户id,或者课程id 
        self.action.ownerId = int(self.ownerId)
        self.action.ownerType = self.ownerType
        self.action.createUserId = self.loginUser.userId
        self.action.actionType = actionType
        self.action.visibility = int(visibility)
        self.action.description = actionDescription
        self.action.place = self.params.getStringParam("actionPlace")
        self.action.userLimit = int(userLimit)
        self.action.startDateTime = actionStartDateTime
        self.action.finishDateTime = actionFinishDateTime
        self.action.attendLimitDateTime = attendLimitDateTime
        self.act_svc.addAction(self.action)
        
        # 将创建者插入到活动用户表内        
        actionUser = ActionUser()
        actionUser.setActionId(self.action.actionId)
        actionUser.setUserId(self.loginUser.userId)
        actionUser.setAttendUserCount(1)
        actionUser.setIsApprove(1)
        actionUser.setStatus(1)       
        self.act_svc.addActionUser(actionUser)
        
        #插入活动的用户表
        self.inviteUser = self.params.safeGetIntValues("inviteUserId")
        self.addInviteUser()
                
        response.setContentType("text/html; charset=UTF-8")
        self.MsgPrint.hasError = False
        #self.MsgPrint.addMessage()
        return self.MsgPrint.printMessage("manage/action/showAction.py?actionId=" + str(self.action.actionId), "")

    def validate_input_datetime(self, varType):
        error_msg = ""
        if varType == "actionStartDateTime":
            error_msg = u"活动开始"
        elif varType == "actionFinishDateTime":
            error_msg = u"活动结束"
        elif varType == "attendLimitDateTime":
            error_msg = u"活动报名截止" 
        else:
            pass
            
        actionStartDateTimeY = self.params.getStringParam(varType + "Y")
        actionStartDateTimeM = self.params.getStringParam(varType + "M")
        actionStartDateTimeD = self.params.getStringParam(varType + "D")
        actionStartDateTimeH = self.params.getStringParam(varType + "H")
        actionStartDateTimeMM = self.params.getStringParam(varType + "MM")
        if actionStartDateTimeY.isdigit() == False:
            self.MsgPrint.hasError = True
            self.MsgPrint.addMessage(u"输入的" + error_msg + u"日期的年份。")
        
        if actionStartDateTimeM.isdigit() == False:
            self.MsgPrint.hasError = True
            self.MsgPrint.addMessage(u"输入的" + error_msg + u"日期的年份。") 
        
        if int(actionStartDateTimeM) > 12 or int(actionStartDateTimeM) < 1 :
            self.MsgPrint.hasError = True
            self.MsgPrint.addMessage(error_msg + u"日期的月份应当在1-12之间。")
        
        if actionStartDateTimeD.isdigit() == False:
            self.MsgPrint.hasError = True
            self.MsgPrint.addMessage(u"输入的" + error_msg + u"日期的天数。")
        
        if int(actionStartDateTimeD) > 31 or int(actionStartDateTimeD) < 0:
            self.MsgPrint.hasError = True
            self.MsgPrint.addMessage(error_msg + u"日期的天数应当在1-31之间。")
        
        if int(actionStartDateTimeH) > 23 or int(actionStartDateTimeH) < 0:
            self.MsgPrint.hasError = True
            self.MsgPrint.addMessage(error_msg + u"日期的小时数应当在0-23之间。")
        
        if int(actionStartDateTimeMM) > 59 or int(actionStartDateTimeMM) < 0:
            self.MsgPrint.hasError = True
            self.MsgPrint.addMessage(error_msg + u"日期的分钟数应当在0-59之间。")
        strDate = actionStartDateTimeY + "-" + actionStartDateTimeM + "-" + actionStartDateTimeD + " " + str(actionStartDateTimeH) + ":" + actionStartDateTimeMM + ":0"
        actionStartDateTime = SimpleDateFormat("yyyy-M-d H:m:s").parse(strDate)
        return actionStartDateTime
        
    def get_owner_entity_id(self):
        if self.ownerType == "user":
            # 只能登录用户创建自己的活动
            user_svc = __jitar__.userService
            user = user_svc.getUserById(self.ownerId)
            if user == None:
                return -1
            else:
                if user.userId == self.loginUser.userId:
                    return user.userId
                else:
                    return -1
        elif self.ownerType == "group":
            # 群组管理员可以创建自己群组的活动
            group = self.grp_svc.getGroup(self.ownerId)
            if group == None:
                return -1
            else:
                if self.get_user_is_group_admin(group) == "admin":
                    return group.groupId
                else:
                    return -1
        elif self.ownerType == "preparecourse":
            # 集体备课:管理员,所有参与人员可以创建            
            prepareCourse = self.pc_svc.getPrepareCourse(self.ownerId)
            if prepareCourse == None:
                return -1
            else:
                if prepareCourse.createUserId != None and prepareCourse.createUserId == self.loginUser.userId:
                    return prepareCourse.prepareCourseId
                if prepareCourse.leaderId != None and prepareCourse.leaderId == self.loginUser.userId:
                    return prepareCourse.prepareCourseId
                return -1
        elif self.ownerType == "subject":
            #学科活动
            sub_svc = __spring__.getBean("subjectService")
            accessControlService = __spring__.getBean("accessControlService")
            subject = sub_svc.getSubjectById(self.ownerId)
            if subject == None:
                return -1
            else:
                if self.loginUser.loginName == "admin":
                    return subject.subjectId
                elif  accessControlService.userIsSubjectContentAdmin(self.loginUser, subject) == True or accessControlService.userIsSubjectAdmin(self.loginUser, subject) == True:
                    return subject.subjectId
                else:
                    return -1                
        else:
            return -1
    
    # 判断用户舒服是有群组管理权限
    def get_user_is_group_admin(self, grp):
        visitor_role = "guest"       
        gm = self.grp_svc.getGroupMemberByGroupIdAndUserId(grp.groupId, self.loginUser.userId)
        if gm != None and gm.getStatus() == 0 and gm.getGroupRole() >= 800:
            visitor_role = "admin"
        
        return visitor_role
            
    def addInviteUser(self):
        strErr = ""
        for u in self.inviteUser:
            user = user_svc.getUserById(u)
            if user == None:
                strErr = strErr + u + u","
            else:
                self.act_svc.addActionUser(self.action.actionId, user, self.loginUser.userId)
        request.setAttribute("errMsg", strErr)
        return
예제 #11
0
class showStageDetail(BaseAction):
    def __init__(self):
        self.params = ParamUtil(request)
        self.pc_svc = __jitar__.getPrepareCourseService()
        self.user_svc = __jitar__.getUserService()
        self.printer = MessagePrint()

    def execute(self):
        if self.loginUser == None:
            self.printer.addMessage(
                u"请先<a href='../../login.jsp'>登录</a>,然后才能操作")
            return self.printer.printMessage("login.jsp", "")

        self.prepareCourseId = self.params.getIntParam("prepareCourseId")
        self.prepareCourseStageId = self.params.getIntParam("stageId")

        self.prepareCourse = self.pc_svc.getPrepareCourse(self.prepareCourseId)
        self.prepareCourseStage = self.pc_svc.getPrepareCourseStage(
            self.prepareCourseStageId)

        if self.prepareCourse == None:
            self.printer.addMessage(u"未能加载备课。请重新选择一次备课。")
            return self.printer.printMessage(
                "manage/course/showPrepareCourse.py?prepareCourseId=" +
                str(self.prepareCourseId), "")

        if self.prepareCourseStage == None:
            self.printer.addMessage(u"未能加载备课的当前阶段。")
            return self.printer.printMessage(
                "manage/course/showPrepareCourse.py?prepareCourseId=" +
                str(self.prepareCourseId), "")

        request.setAttribute("loginUser", self.loginUser)
        request.setAttribute("prepareCourseId", self.prepareCourseId)
        request.setAttribute("prepareCourseStageId", self.prepareCourseStageId)

        if request.getMethod() == "POST":
            return self.saveOrUpdatePrepareCourse()
        else:
            return self.getPrepareCourse()

    def getPrepareCourse(self):

        qry = PrepareCourseMemberQuery(
            """  u.loginName,u.trueName,u.nickName,u.unitId, unit.unitName """)
        qry.prepareCourseId = self.prepareCourseId
        user_list = qry.query_map()
        request.setAttribute("user_list", user_list)
        request.setAttribute("head_nav", "cocourses")
        return "/WEB-INF/ftl/course/course_stage_detail_show.ftl"

    def saveOrUpdatePrepareCourse(self):
        stageComment = self.params.safeGetStringParam("stageComment")

        if stageComment == None or stageComment == "":
            self.printer.addMessage(u"请输入讨论内容。")
            return self.printer.printMessage(
                "manage/course/createPreCourse3.py?prepareCourseId=" +
                str(self.prepareCourseId), "")

        pcStageStartDate = SimpleDateFormat("yyyy-M-d").parse(stageStartDate)
        pcEndDateTime = SimpleDateFormat("yyyy-M-d").parse(stageEndDate)

        maxOrder = self.pc_svc.getMaxCourseStageOrderIndex(
            self.prepareCourseId)

        prepareCourseStage = PrepareCourseStage()
        prepareCourseStage.setPrepareCourseId(self.prepareCourseId)
        prepareCourseStage.setTitle(stageTitle)
        prepareCourseStage.setBeginDate(pcStageStartDate)
        prepareCourseStage.setFinishDate(pcEndDateTime)
        prepareCourseStage.setDescription(stageDescription)
        prepareCourseStage.setOrderIndex(maxOrder + 1)
        self.pc_svc.createPrepareCourseStage(prepareCourseStage)

        self.printer.addMessage(u"创建 " + prepareCourseStage.title + u" 阶段成功。")
        return self.printer.printMessage(
            "manage/course/createPreCourse3.py?prepareCourseId=" +
            str(self.prepareCourseId), "")
예제 #12
0
 def __init__(self):
     self.ERROR_FTL = "/WEB-INF/ftl/action/error.ftl"
     self.printer = MessagePrint()
     self.subjectService = __spring__.getBean("subjectService")
     self.accessControlService = __spring__.getBean("accessControlService")
예제 #13
0
class actionedit(BaseAction, RequestMixiner, ResponseMixiner,
                 PageCheckMixiner):

    grp_svc = __jitar__.groupService
    act_svc = __jitar__.actionService
    user_svc = __jitar__.userService
    pc_svc = __jitar__.getPrepareCourseService()

    def __init__(self):
        self.ERROR_FTL = "/WEB-INF/ftl/action/error.ftl"
        self.printer = MessagePrint()
        self.subjectService = __spring__.getBean("subjectService")
        self.accessControlService = __spring__.getBean("accessControlService")

    def execute(self):
        self.ErrMsg = ""
        self.params = ParamUtil(request)
        self.out = response.writer
        if self.loginUser == None:
            self.printer.addMessage(
                u"请先<a href='../../login.jsp'>登录</a>,然后才能编辑活动")
            return self.printer.printMessage("login.jsp", "")

        # 导航数据
        site_config = SiteConfig()
        site_config.get_config()

        # 活动必须属于一个类别,如user,group,course等
        self.actionId = self.params.getIntParam("actionId")
        if self.actionId == None or self.actionId == 0:
            self.addActionLink(u"返回活动列表",
                               CommonUtil.getSiteUrl(request) + "actions.py")
            self.addActionError(u"缺少标识。")
            return self.ERROR
        self.act_svc.updateActionUserStatById(self.actionId)
        self.action = self.act_svc.getActionById(self.actionId)
        if self.action == None:
            self.addActionLink(u"返回活动列表",
                               CommonUtil.getSiteUrl(request) + "actions.py")
            self.addActionError(u"加载活动信息失败。")
            return self.ERROR

        #学科内容管理员权限
        self.contentAdmin = False
        #学科管理员权限
        self.manageAdmin = False
        if self.action.ownerType == "subject":
            self.subjectId = self.action.ownerId
            self.subject = self.subjectService.getSubjectById(self.subjectId)
            #print "self.subjectId=",self.subjectId
            #print "self.subject=",self.subject
            #print "self.loginUser="******"self.contentAdmin=",self.contentAdmin
            #print "self.manageAdmin=",self.manageAdmin

        if self.contentAdmin == True or self.manageAdmin == True:
            #是内容管理员或管理员
            #print "是内容管理员或管理员"
            bManage = True
        else:
            if not (self.loginUser.userId == self.action.createUserId
                    or self.loginUser.loginName == "admin"):
                self.addActionLink(
                    u"返回活动列表",
                    CommonUtil.getSiteUrl(request) +
                    "manage/action/showAction.py?actionId=" +
                    str(self.action.actionId))
                self.addActionError(u"只有活动的创建者,系统管理员,或者内容管理员才可以修改活动。")
                return self.ERROR
        if self.printer.hasError == True:
            return self.printer.printMessage("", "back")
        if request.getMethod() == "POST":
            # 判断是否是合法的实体,如user,group,确认是否是合法
            # 修改这些字段不更新,不用判断
            #self.ownerId = self.get_owner_entity_id()
            #if self.ownerId == -1:
            #    self.out.print("您没有创建活动的权限")
            #    return
            cmd = self.params.getStringParam("cmd")
            if cmd == "edit":
                return self.actionPost()
            elif cmd == "deluser":
                return self.delUser()
            elif cmd == "inviteuser":
                return self.inviteUser()
            elif cmd == "printuser":
                return self.printUser()
            else:
                self.addActionError(u"无效的命令。")
                return self.ERROR
        else:

            action_user_list = self.act_svc.getActionUserWithDistUnit(
                self.action.actionId)
            #得到活动参与人员列表
            #action_user_list = self.act_svc.getActionUserIdListByActionId(self.action.actionId)

            request.setAttribute("action_user_list", action_user_list)
            request.setAttribute("action", self.action)
            return self.actionGet()

    def actionGet(self):
        self.get_datetime_part("startDateTime", self.action.startDateTime)
        self.get_datetime_part("finishDateTime", self.action.finishDateTime)
        self.get_datetime_part("attendLimitDateTime",
                               self.action.attendLimitDateTime)
        cal = Calendar.getInstance()
        request.setAttribute("year", cal.get(Calendar.YEAR))
        response.setContentType("text/html; charset=UTF-8")
        return "/WEB-INF/ftl/action/action_edit.ftl"

    def actionPost(self):
        request.setAttribute(
            "RedUrl", "manage/action/actionedit.py?actionId=" +
            str(self.action.actionId))
        title = self.params.getStringParam("actionName")
        if len(title) == 0:
            self.printer.addMessage(u"请输入标题。")

        actionType = self.params.getIntParam("actionType")
        if actionType == None:
            self.printer.addMessage(u"请选项活动类型。")

        visibility = self.params.getIntParam("actionVisibility")
        if visibility == None:
            self.printer.addMessage(u"请选项活动方式。")

        userLimit = self.params.getIntParam("actionUserLimit")
        if userLimit == None:
            self.printer.addMessage(u"请输入活动的限制人数。")

        actionStartDateTime = self.validate_input_datetime(
            "actionStartDateTime")
        actionFinishDateTime = self.validate_input_datetime(
            "actionFinishDateTime")
        attendLimitDateTime = self.validate_input_datetime(
            "attendLimitDateTime")

        if DateUtil.compareDateTime(actionStartDateTime,
                                    actionFinishDateTime) > 0:
            self.printer.addMessage(u"活动开始日期不能大于结束日期。")

        if DateUtil.compareDateTime(attendLimitDateTime,
                                    actionFinishDateTime) > 0:
            self.printer.addMessage(u"活动报名截止日期不能大于结束日期。")

        if DateUtil.compareDateTime(actionStartDateTime,
                                    attendLimitDateTime) > 0:
            self.printer.addMessage(u"活动开始日期不能大于活动报名截止日期。")

        if self.printer.hasError == True:
            return self.printer.printMessage("", "back")

        self.action.title = title
        self.action.actionType = actionType
        self.action.visibility = int(visibility)
        self.action.description = self.params.getStringParam(
            "actionDescription")
        self.action.place = self.params.getStringParam("actionPlace")
        self.action.userLimit = int(userLimit)
        self.action.startDateTime = actionStartDateTime
        self.action.finishDateTime = actionFinishDateTime
        self.action.attendLimitDateTime = attendLimitDateTime
        #print "action =", action
        self.act_svc.saveAction(self.action)
        response.setContentType("text/html; charset=UTF-8")
        return self.printer.printMessage(
            "manage/action/actionedit.py?actionId=" +
            str(self.action.actionId), "")

    def validate_input_datetime(self, varType):
        error_msg = ""
        if varType == "actionStartDateTime":
            error_msg = u"活动开始"
        elif varType == "actionFinishDateTime":
            error_msg = u"活动结束"
        elif varType == "attendLimitDateTime":
            error_msg = u"活动报名截止"
        else:
            pass

        actionStartDateTimeY = self.params.getStringParam(varType + "Y")
        actionStartDateTimeM = self.params.getStringParam(varType + "M")
        actionStartDateTimeD = self.params.getStringParam(varType + "D")
        actionStartDateTimeH = self.params.getStringParam(varType + "H")
        actionStartDateTimeMM = self.params.getStringParam(varType + "MM")
        if actionStartDateTimeY.isdigit() == False:
            self.printer.addMessage(u"输入的" + error_msg + u"日期的年份。")

        if actionStartDateTimeM.isdigit() == False:
            self.printer.addMessage(u"输入的活" + error_msg + u"日期的月份。")

        if int(actionStartDateTimeM) > 12 or int(actionStartDateTimeM) < 1:
            self.printer.addMessage(error_msg + u"日期的月份应当在1-12之间。")

        if actionStartDateTimeD.isdigit() == False:
            self.printer.addMessage(u"输入的" + error_msg + u"日期的天数。")

        if int(actionStartDateTimeD) > 31 or int(actionStartDateTimeD) < 0:
            self.printer.addMessage(error_msg + u"日期的天数应当在1-31之间。")

        if int(actionStartDateTimeH) > 23 or int(actionStartDateTimeH) < 0:
            self.printer.addMessage(error_msg + u"日期的小时数应当在0-23之间。")

        if int(actionStartDateTimeMM) > 59 or int(actionStartDateTimeMM) < 0:
            self.printer.addMessage(error_msg + u"日期的分钟数应当在0-59之间。")

        strDate = actionStartDateTimeY + "-" + actionStartDateTimeM + "-" + actionStartDateTimeD + " " + str(
            actionStartDateTimeH) + ":" + actionStartDateTimeMM + ":0"
        actionStartDateTime = SimpleDateFormat("yyyy-M-d H:m:s").parse(strDate)
        return actionStartDateTime

    def get_datetime_part(self, varType, varDateTime):
        c = Calendar.getInstance()
        c.setTime(varDateTime)
        request.setAttribute(varType + "Y", c.get(Calendar.YEAR))
        request.setAttribute(varType + "M", c.get(Calendar.MONTH) + 1)
        request.setAttribute(varType + "D", c.get(Calendar.DAY_OF_MONTH))
        if c.get(Calendar.AM_PM) == Calendar.PM:
            request.setAttribute(varType + "H", c.get(Calendar.HOUR) + 12)
        else:
            request.setAttribute(varType + "H", c.get(Calendar.HOUR))
        request.setAttribute(varType + "MM", c.get(Calendar.MINUTE))

    def get_owner_entity_id(self):
        if self.ownerType == "user":
            # 只能登录用户创建自己的活动
            user_svc = __jitar__.userService
            user = user_svc.getUserById(self.ownerId)
            if user == None:
                return -1
            else:
                if user.userId == self.loginUser.userId:
                    return user.userId
                else:
                    return -1
        elif self.ownerType == "group":
            # 群组管理员可以创建自己群组的活动
            group = self.grp_svc.getGroup(self.ownerId)
            if group == None:
                return -1
            else:
                if self.get_user_is_group_admin(group) == "admin":
                    return group.groupId
                else:
                    return -1
        elif self.ownerType == "preparecourse":
            # 集体备课:管理员,所有参与人员可以创建
            prepareCourse = self.pc_svc.getPrepareCourse(self.ownerId)
            if prepareCourse == None:
                return -1
            else:
                if prepareCourse.createUserId != None and prepareCourse.createUserId == self.loginUser.userId:
                    return prepareCourse.prepareCourseId
                if prepareCourse.leaderId != None and prepareCourse.leaderId == self.loginUser.userId:
                    return prepareCourse.prepareCourseId
                return -1
        elif self.ownerType == "subject":
            #学科活动
            sub_svc = __spring__.getBean("subjectService")
            accessControlService = __spring__.getBean("accessControlService")
            subject = sub_svc.getSubjectById(self.ownerId)
            if subject == None:
                return -1
            else:
                if self.loginUser.loginName == "admin":
                    return subject.subjectId
                elif accessControlService.userIsSubjectContentAdmin(
                        self.loginUser, subject) == True:
                    #self.loginUser.subjectId == subject.metaSubject.msubjId and self.loginUser.gradeId == subject.metaSubject.metaGrade.gradeId:
                    return subject.subjectId
                else:
                    return -1
        else:
            return -1

    # 判断用户舒服是有群组管理权限
    def get_user_is_group_admin(self, grp):
        visitor_role = "guest"
        gm = self.grp_svc.getGroupMemberByGroupIdAndUserId(
            grp.groupId, self.loginUser.userId)
        if gm != None and gm.getStatus() == 0 and gm.getGroupRole() >= 800:
            visitor_role = "admin"

        return visitor_role

    def inviteUser(self):
        str_error = ""
        invite_users = self.params.safeGetIntValues("inviteUserId")
        for invite_userId in invite_users:
            #print "user_loginName = ", user_loginName
            user = self.user_svc.getUserById(invite_userId)
            if user == None:
                str_error = str_error + u"<li>用户" + invite_userId + u"不是本系统存在的用户。</li>"
            else:
                if self.act_svc.userIsInAction(user.getUserId(),
                                               self.action.actionId):
                    str_error = str_error + u"<li>用户" + user.trueName + u"已经是该活动的成员。</li>"
                else:
                    self.act_svc.addActionUser(self.action.actionId, user,
                                               self.loginUser.userId)

        #更新统计数据
        self.act_svc.updateActionUserStatById(self.action.actionId)
        if str_error != "":
            self.printer.addMessage(str_error)

        return self.printer.printMessage(
            "manage/action/actionedit.py?actionId=" +
            str(self.action.actionId), "")

    def delUser(self):
        action_user_users = self.params.getRequestParamValues("guid")
        if action_user_users == None:
            self.printer.addMessage(u"请选择一个用户。")
            return self.printer.printMessage("", "back")
        for action_user_id in action_user_users:
            self.act_svc.delActionUserById(int(action_user_id))

        #更新统计数据
        self.act_svc.updateActionUserStatById(self.action.actionId)
        return self.printer.printMessage(
            "manage/action/actionedit.py?actionId=" +
            str(self.action.actionId), "")

    def printUser(self):
        request.setCharacterEncoding("utf-8")
        action_user_list = self.act_svc.getActionUserWithDistUnit(
            self.action.actionId)
        request.setAttribute("action_user_list", action_user_list)
        request.setAttribute("action", self.action)
        response.reset()
        response.setContentType("application/vnd.ms-excel")
        response.setHeader("Content-Type",
                           "application/vnd.ms-excel; charset=GB2312")
        #response.setCharacterEncoding("GB2312")
        #response.setLocale(Locale.SIMPLIFIED_CHINESE)
        response.addHeader("Content-Disposition",
                           "attachment;filename=ActionUser.xls")
        return "/WEB-INF/ftl/action/action_user_print.ftl"
예제 #14
0
class show_preparecourse_index(PrepareCoursePageService, PageCheckMixiner):
    def __init__(self):
        self.pc_svc = __jitar__.getPrepareCourseService()
        self.user_svc = __jitar__.getUserService()
        self.sbj_svc = __jitar__.getSubjectService()
        self.act_svc = __jitar__.getActionService()
        self.page_svc = __jitar__.getPageService()
        self.printer = MessagePrint()

    def execute(self):
        self.getBaseData()

        if self.prepareCourse == None:
            self.printer.addMessage(u"未能加载备课。请重新选择一次备课。")
            return self.printer.printMessage("cocourses.action", "")

        if self.prepareCourse.status != 0:
            self.printer.addMessage(u"该备课状态处于非正常状态,目前无法进行访问。")
            return self.printer.printMessage("cocourses.action", "")

        canVisitCourse = self.canView(self.prepareCourse)
        if canVisitCourse == False:
            self.printer.addMessage(u"只有该备课成员才能进行查看。")
            return self.printer.printMessage("cocourses.action", "")

        grade = self.sbj_svc.getGrade(self.prepareCourse.gradeId)
        metaSubject = self.sbj_svc.getMetaSubjectById(
            self.prepareCourse.metaSubjectId)

        page = self.getPrepareCoursePageWithCustomSkin(self.prepareCourse)

        if page == None:
            self.printer.addMessage(u"无法加载页面。")
            return self.printer.printMessage("cocourses.action", "")

        self.widget_list = self.getPageWidgets(page)
        request.setAttribute("widget_list", self.widget_list)
        request.setAttribute("widgets", self.widget_list)

        request.setAttribute("page", page)
        if self.canManage(self.prepareCourse) == True:
            request.setAttribute("visitor_role", "admin")
        request.setAttribute("canVisitCourse", canVisitCourse)
        request.setAttribute("grade", grade)
        request.setAttribute("metaSubject", metaSubject)
        request.setAttribute("loginUser", self.loginUser)
        request.setAttribute("prepareCourse", self.prepareCourse)
        request.setAttribute("head_nav", "cocourses")
        request.setAttribute("canAdmin", self.canAdmin())

        precs_list = self.pc_svc.getPrepareCourseStageList(
            self.prepareCourseId)
        self.pc_svc.countPrepareCourseData(self.prepareCourseId)
        self.pc_svc.addViewCount(self.prepareCourseId)
        request.setAttribute("precoursestage_list", precs_list)
        return "/WEB-INF/ftl/course/show_preparecourse_index.ftl"
예제 #15
0
class showPrepareCourse(BaseAction):
    def __init__(self):
        self.params = ParamUtil(request)
        self.pc_svc = __jitar__.getPrepareCourseService()
        self.user_svc = __jitar__.getUserService()
        self.sbj_svc = __jitar__.getSubjectService()
        self.act_svc = __jitar__.getActionService()
        
        self.printer = MessagePrint()
        
    def execute(self):
        if self.loginUser == None:            
            self.printer.addMessage(u"请先<a href='../../login.jsp'>登录</a>,然后才能操作")
            return self.printer.printMessage("login.jsp", "")
        
        self.prepareCourseId = self.params.getIntParam("prepareCourseId")
        self.prepareCourse = self.pc_svc.getPrepareCourse(self.prepareCourseId)
        
        if self.prepareCourse == None:
            self.printer.addMessage(u"未能加载备课。请重新选择一次备课。")
            return self.printer.printMessage("cocourses.action", "")
        
        canVisitCourse = self.isCourseMember()
        if canVisitCourse == "false":
            self.printer.addMessage(u"只有该备课成员才能进行查看。")
            return self.printer.printMessage("cocourses.action", "")
        
        
        grade = self.sbj_svc.getGrade(self.prepareCourse.gradeId)
        metaSubject = self.sbj_svc.getMetaSubjectById(self.prepareCourse.metaSubjectId)
        
        request.setAttribute("canVisitCourse", canVisitCourse)
        request.setAttribute("grade", grade)
        request.setAttribute("metaSubject", metaSubject)
        request.setAttribute("loginUser", self.loginUser) 
        request.setAttribute("prepareCourse", self.prepareCourse)
        request.setAttribute("head_nav", "cocourses")
        request.setAttribute("canAdmin", self.canAdmin())
        self.getActionList()
        return self.getPrepareCourse()
    
    def getPrepareCourse(self):
        site_config = SiteConfig()
        site_config.get_config()
        
        qry = PrepareCourseMemberQuery(""" pcm.replyCount, u.userId, u.loginName,u.trueName,u.nickName,u.unitId, unit.unitName """)
        qry.prepareCourseId = self.prepareCourseId
        user_list = qry.query_map()
        request.setAttribute("user_list", user_list)
        
        precs_list = self.pc_svc.getPrepareCourseStageList(self.prepareCourseId)
        request.setAttribute("precoursestage_list", precs_list)        
        
        return "/WEB-INF/ftl/course/course_show.ftl" 
    
    def getActionList(self):
        qry = ActionQuery(""" act.title, act.createDate, act.actionId, act.ownerId, act.ownerType, act.createUserId, act.actionType,
                              act.description, act.userLimit, act.startDateTime,act.finishDateTime, act.attendLimitDateTime, act.place,
                              act.status, act.visibility, act.attendCount
                            """)
        qry.ownerType = "course"
        qry.status = 0
        qry.ownerId = self.prepareCourseId
        action_list = qry.query_map()
        request.setAttribute("action_list", action_list)      
    
    # 当前登录用户是否是管理员
    def canAdmin(self):
        accessControlService = __spring__.getBean("accessControlService")
        if self.loginUser.userId == self.prepareCourse.createUserId or accessControlService.isSystemAdmin(self.loginUser):
            return "true"
        else:
            return "false"

    # 当前登录用户是否是该备课的成员
    def isCourseMember(self):
        ismember = "false"
        if self.loginUser == None:
            return ismember
        if self.canAdmin() == "true":
            return "true"
        ismember = self.pc_svc.checkUserInPreCourse(self.prepareCourse.prepareCourseId, self.loginUser.userId)
        return ismember