Exemplo n.º 1
0
 def approveLevel(self):
     guids = self.params.safeGetIntValues("guid")
     for g in guids:
         resource = self.resourceService.getResource(g)
         if resource != None:
             self.resourceService.auditResource(resource)
             resourceUnitId = resource.unitId
             if resourceUnitId != None:
                 resourceUnit = self.unitService.getUnitById(resourceUnitId)
                 if resourceUnit != None:
                     unitPath = self.unitService.getUnitPathBetweenUnits(
                         self.unit, resourceUnit)
                     if unitPath != "":
                         unitPath = CommonUtil.sortNumberString(unitPath)
                         approvedPathInfo = resource.approvedPathInfo
                         if approvedPathInfo == None:
                             resource.setApprovedPathInfo(unitPath)
                         else:
                             arraypath = unitPath.split("/")
                             for p in range(len(arraypath) - 1, -1, -1):
                                 if arraypath[p] != "":
                                     partInfo = "/" + arraypath[p] + "/"
                                     approvedPathInfo = resource.approvedPathInfo
                                     if approvedPathInfo.find(
                                             partInfo) == -1:
                                         PathInfo = "/" + arraypath[
                                             p] + approvedPathInfo
                                         resource.setApprovedPathInfo(
                                             CommonUtil.sortNumberString(
                                                 PathInfo))
                         self.resourceService.updateResource(resource)
Exemplo n.º 2
0
 def setRcmd(self):
     guids = self.params.safeGetIntValues("guid")
     for g in guids:
         article = self.articleService.getArticle(g)
         if article != None:
             articleUnitId = article.unitId
             if articleUnitId != None:
                 articleUnit = self.unitService.getUnitById(articleUnitId)
                 if articleUnit != None:
                     unitPath = self.unitService.getUnitPathBetweenUnits(
                         self.unit, articleUnit)
                     if unitPath != "":
                         unitPath = CommonUtil.sortNumberString(unitPath)
                         rcmdPathInfo = article.rcmdPathInfo
                         if rcmdPathInfo == None:
                             article.setRcmdPathInfo(unitPath)
                         else:
                             arraypath = unitPath.split("/")
                             for p in range(len(arraypath) - 1, -1, -1):
                                 if arraypath[p] != "":
                                     partInfo = "/" + arraypath[p] + "/"
                                     rcmdPathInfo = article.rcmdPathInfo
                                     if rcmdPathInfo.find(partInfo) == -1:
                                         PathInfo = "/" + arraypath[
                                             p] + rcmdPathInfo
                                         PathInfo = CommonUtil.sortNumberString(
                                             PathInfo)
                                         article.setRcmdPathInfo(PathInfo)
                         self.articleService.updateArticle(article)
Exemplo n.º 3
0
    def get_rcmd_list(self, topCount):
        minNum = CommonUtil.convertRoundMinNumber(self.get_current_gradeId())
        maxNum = CommonUtil.convertRoundMaxNumber(self.get_current_gradeId())
        strOrderBy = "UserId DESC"
        strWhereClause = "(UserStatus=0 And UserType LIKE '%/2/%' "
        strWhere1 = strWhereClause + " And GradeId >= " + str(
            minNum) + " And GradeId<" + str(maxNum) + " And SubjectId=" + str(
                self.get_current_subjectId())
        strWhere1 += ")"
        strWhere2 = ""

        if self.userIds != "":
            strWhere2 = " And UserId In(" + self.userIds + ")"

        if strWhere2 != "":
            strWhere2 = strWhereClause + strWhere2 + ")"
        if strWhere2 == "":
            strWhereClause = strWhere1
        else:
            strWhereClause = strWhere1 + " Or " + strWhere2
        pagingService = __spring__.getBean("pagingService")
        pagingQuery = PagingQuery()
        pagingQuery.keyName = "UserId"
        pagingQuery.fetchFieldsName = "*"
        pagingQuery.spName = "findPagingUser"
        pagingQuery.tableName = "Jitar_User"
        pagingQuery.whereClause = strWhereClause
        pagingQuery.orderByFieldName = strOrderBy
        pagingQuery.topCount = topCount
        hot_list = pagingService.getPagingList(pagingQuery)
        return hot_list
Exemplo n.º 4
0
    def unsetRcmd(self):
        guids = self.params.safeGetIntValues("guid")
        for g in guids:
            resource = self.resourceService.getResource(g)
            if resource != None:
                resourceUnitId = resource.unitId
                if resourceUnitId != None:
                    resourceUnit = self.unitService.getUnitById(resourceUnitId)
                    if resourceUnit != None:
                        unitPath = self.unitService.getUnitPathBetweenUnits(
                            self.unit, resourceUnit)
                        if unitPath != "":
                            unitPath = CommonUtil.sortNumberString(unitPath)
                            rcmdPathInfo = resource.rcmdPathInfo
                            if rcmdPathInfo != None:
                                arraypath = unitPath.split("/")
                                for p in range(len(arraypath) - 1, -1, -1):
                                    if arraypath[p] != "":
                                        partInfo = "/" + arraypath[p] + "/"
                                        rcmdPathInfo = resource.rcmdPathInfo
                                        if rcmdPathInfo.find(partInfo) > -1:
                                            rcmdPathInfo = rcmdPathInfo.replace(
                                                partInfo, "/")
                                            if rcmdPathInfo == "/":
                                                rcmdPathInfo = None

                                            if rcmdPathInfo != None:
                                                rcmdPathInfo = CommonUtil.sortNumberString(
                                                    rcmdPathInfo)
                                            resource.setRcmdPathInfo(
                                                rcmdPathInfo)
                            self.resourceService.updateResource(resource)
    def execute(self):
        self.getBaseData()
        """
        发起或者编辑活动的前提:
        1,用户必须先登录
        2,登录用户必须是管理员或者备课成员
        """
        if self.loginUser == None:
            backUrl = request.getAttribute('javax.servlet.forward.request_uri')
            if backUrl == None or backUrl == "": backUrl = request.requestURI
            response.sendRedirect(
                CommonUtil.getSiteUrl(request) + "login.jsp?redUrl=" +
                CommonUtil.urlUtf8Encode(
                    CommonUtil.getSiteServer(request) + backUrl))
            return

        if self.prepareCourseId == 0:
            self.printer.write(u"无效的课程标识。")
            return
        self.prepareCourse = self.getBasePrepareCourse()
        if self.prepareCourse == None:
            self.printer.write(u"没有加载到所请求的备课。")
            return
        now = Date()
        if self.prepareCourse.startDate > now:
            self.printer.write(u"备课时间还没开始,不允许增加活动 。")
            return

        if self.prepareCourse.endDate < now:
            self.printer.write(u"备课已经结束,不允许增加活动 。")
            return
        # 如果有了prepareCourse对象,就可以使用show_preparecourse_ok_info了
        page = self.getPrepareCoursePageWithCustomSkin(self.prepareCourse)
        widgets = [{
            "id": "placerholder1",
            "pageId": 0,
            "columnIndex": 2,
            "title": "",
            "module": "placeholder",
            "ico": "",
            "data": ""
        }]

        request.setAttribute("widget_list", widgets)
        request.setAttribute("page", page)
        request.setAttribute("prepareCourse", self.prepareCourse)
        request.setAttribute("prepareCourseId", self.prepareCourseId)

        if self.isPrepareCourseMember() == False:
            operation_result = u"不是本课程的成员。"
            request.setAttribute("operation_result", operation_result)
            return "/WEB-INF/ftl/course/show_preparecourse_ok_info.ftl"

        if request.getMethod() == "POST":
            return self.save_action()
        else:
            return self.show_action_edit()
Exemplo n.º 6
0
 def execute(self):
     if self.loginUser == None:
         backUrl = request.getAttribute('javax.servlet.forward.request_uri')
         if backUrl == None or backUrl == "":backUrl = request.requestURI    
         response.sendRedirect(CommonUtil.getSiteUrl(request) + "login.jsp?redUrl=" + CommonUtil.urlUtf8Encode(CommonUtil.getSiteServer(request) + backUrl))
         return
     
     accessControlService = __spring__.getBean("accessControlService")
     if accessControlService.isSystemAdmin(self.loginUser) == False:
         self.addActionError(u"没有管理权限.")
         return ActionResult.ERROR
     if request.getMethod() == "POST":            
         return self.coursePost()
     else: 
         qry = PrepareCourseQuery(""" pc.title, pc.prepareCourseId, pc.createDate,pc.metaSubjectId,pc.gradeId,pc.createUserId,u.loginName,u.trueName """)
         pager = self.params.createPager()
         pager.itemName = u"备课"
         pager.itemUnit = u"个"
         pager.pageSize = 20
         pager.totalRows = qry.count()
         preparecourse_list = qry.query_map(pager)
         request.setAttribute("preparecourse_list", preparecourse_list)
         request.setAttribute("pager", pager)
         response.setContentType("text/html; charset=UTF-8")
         return "/WEB-INF/ftl/course/admin_course_list.ftl"
Exemplo n.º 7
0
 def GenSubjectNav(self):
     subjectService = __spring__.getBean("subjectService")      
     mGradeId = subjectService.getGradeIdList()
     MetaGrade = ArrayList()
     metaSubject = ArrayList()
     for grade in mGradeId:
         mGrade = subjectService.getGrade(int(grade))
         MetaGrade.add(mGrade)
         subj = subjectService.getSubjectByGradeId(int(grade))
         m = ArrayList()
         if subj != None:
             for sj in range(0, subj.size()):
                 m.add(subj[sj].metaSubject)
             metaSubject.add({"gradeName" : mGrade.gradeName, "gradeId" : grade, "metaSubject" : m })
     map = HashMap()
     map.put("metaGrade", MetaGrade)
     map.put("meta_Grade", MetaGrade)
     map.put("SubjectNav", metaSubject)
     map.put("SiteUrl", CommonUtil.getContextUrl(request))
     
     templateProcessor = __spring__.getBean("templateProcessor")
     str = templateProcessor.processTemplate(map, "/WEB-INF/ftl/site_subject_nav.ftl", "utf-8")
     rootPath = JitarRequestContext.getRequestContext().getServletContext().getRealPath("/")
     fileIndex = rootPath + "html" + File.separator + "subject_nav.html"
     try:
         file = File(fileIndex)
         fw = OutputStreamWriter(FileOutputStream(file), "utf-8")
         # fw = FileWriter(file, False)
         fw.flush()
         fw.write(str)
         fw.close()
     finally:
         file = None
         fw = None
Exemplo n.º 8
0
    def unapproveLevel(self):
        guids = self.params.safeGetIntValues("guid")
        for g in guids:
            article = self.articleService.getArticle(g)
            if article != None:
                articleUnitId = article.unitId
                if articleUnitId != None:
                    articleUnit = self.unitService.getUnitById(articleUnitId)
                    if articleUnit != None:
                        unitPath = self.unitService.getUnitPathBetweenUnits(
                            self.unit, articleUnit)
                        if unitPath != "":
                            approvedPathInfo = article.approvedPathInfo
                            if approvedPathInfo != None:
                                arraypath = unitPath.split("/")
                                for p in range(len(arraypath) - 1, -1, -1):
                                    if arraypath[p] != "":
                                        partInfo = "/" + arraypath[p] + "/"
                                        approvedPathInfo = article.approvedPathInfo
                                        if approvedPathInfo.find(
                                                partInfo) > -1:
                                            approvedPathInfo = approvedPathInfo.replace(
                                                partInfo, "/")
                                            if approvedPathInfo == "/":
                                                approvedPathInfo = None
                                                self.articleService.unauditArticle(
                                                    article)

                                            if approvedPathInfo != None:
                                                approvedPathInfo = CommonUtil.sortNumberString(
                                                    approvedPathInfo)

                                            article.setApprovedPathInfo(
                                                approvedPathInfo)
                            self.articleService.updateArticle(article)
Exemplo n.º 9
0
 def delete_theme(self):
     guids = self.params.safeGetIntValues("guid")
     candeletefile = self.params.safeGetStringParam("deletefile")
     servlet_ctxt = self.theme_svc.getServletContext()
     for guid in guids:
         theme = self.theme_svc.getSiteThemeById(guid)
         if theme != None:
             if theme.status != 1:
                 self.theme_svc.deleteSiteTheme(theme)
                 #删除物理文件
                 if candeletefile == "1":
                     filePath = servlet_ctxt.getRealPath(
                         "/"
                     ) + "theme" + File.separator + "site" + File.separator + theme.folder + File.separator
                     CommonUtil.deleteDir(filePath)
     response.sendRedirect("site_theme.py")
Exemplo n.º 10
0
    def execute(self):
        self.params = ParamUtil(request)
        wid = self.params.safeGetStringParam("wid")
        oldCateId = self.params.safeGetIntParam("oldCateId")
        count = self.params.safeGetIntParam("count")
        title = self.params.safeGetStringParam("title")
        if count == 0: count = 9
        if wid == None or wid == "":
            wid = ""

        loginName = request.getAttribute("loginName")
        if (loginName == None or loginName == ''):
            writer.write(u"没有该用户。")
            return

        # 加载当前用户对象.
        user = __jitar__.userService.getUserByLoginName(loginName)
        categoryService = __jitar__.categoryService
        itemType = CommonUtil.toUserVideoCategoryItemType(user.getUserId())
        usercate_tree = categoryService.getCategoryTree(itemType)
        request.setAttribute("wid", wid)
        request.setAttribute("count", count)
        request.setAttribute("oldCateId", oldCateId)
        request.setAttribute("title", title)
        request.setAttribute("usercate_tree", usercate_tree)
        response.getWriter().write(title)
        return "/WEB-INF/user/default/get_user_videocategory.ftl"
Exemplo n.º 11
0
 def execute(self):
     self.userName = request.getAttribute("loginName")
     userService = __jitar__.userService
     categoryService = __jitar__.categoryService
     user = userService.getUserByLoginName(self.userName)
     if user == None:
         response.writer.println(u"不能加载该用户的信息")
         return
     if self.canVisitUser(user) == False:
         response.writer.println(u"用户  %s 无法访问." % self.userName)
         return
     fc = FileCache()
     # 14400 为10 天
     content = fc.getUserFileCacheContent(self.userName, "user_cate.html",14400)
     if content != "":
         response.getWriter().write(content)
         fc = None
         return
     
     itemType = CommonUtil.toUserArticleCategoryItemType(user.getUserId())        
     usercate_tree = categoryService.getCategoryTree(itemType)
     
     templateProcessor = __spring__.getBean("templateProcessor")
     map = HashMap()
     map.put("user", user)
     map.put("usercate_tree", usercate_tree)
     map.put("UserSiteUrl", self.getUserSiteUrl())
     content = templateProcessor.processTemplate(map, "/WEB-INF/user/default/user_cate.ftl", "utf-8")
     
     fc.writeUserFileCacheContent(self.userName, "user_cate.html",content)        
     response.getWriter().write(content)
     fc = None
Exemplo n.º 12
0
    def actionComment(self):
        if self.loginUser == None:
            self.addActionLink(
                u"返回活动",
                CommonUtil.getSiteUrl(request) +
                "manage/action/showAction.py?actionId=" +
                str(self.action.actionId))
            self.addActionError(u"请<a href='../../login.jsp'>登录</a>发表留言。")
            return self.ERROR

        title = self.params.getStringParam("title")
        comment = self.params.getStringParam("actionComment")
        if title == None or title == "":
            self.addActionLink(
                u"返回活动",
                CommonUtil.getSiteUrl(request) +
                "manage/action/showAction.py?actionId=" +
                str(self.action.actionId))
            self.addActionError(u"请输入讨论标题。")
            return self.ERROR
        if comment == None or comment == "":
            self.addActionLink(
                u"返回活动",
                CommonUtil.getSiteUrl(request) +
                "manage/action/showAction.py?actionId=" +
                str(self.action.actionId))
            self.addActionError(u"请输入讨论内容。")
            return self.ERROR

        actionReply = ActionReply()
        actionReply.setTopic(title)
        actionReply.setContent(comment)
        actionReply.setAddIp(self.get_client_ip())
        actionReply.setUserId(self.loginUser.userId)
        actionReply.setActionId(self.action.actionId)
        self.act_svc.addComment(actionReply)

        #计算转向页面地址
        pageSize = self.params.getIntParam("pageSize")
        totalRows = self.params.getIntParam("totalRows") + 1
        if pageSize <= 0: pageSize = 10
        pageCount = totalRows / pageSize
        if totalRows % pageSize != 0: pageCount = pageCount + 1
        response.sendRedirect("showAction.py?actionId=" +
                              str(self.action.actionId) + "&page=" +
                              str(pageCount))
        return None
Exemplo n.º 13
0
    def query_blog(self):
        minNum = CommonUtil.convertRoundMinNumber(self.get_current_gradeId())
        maxNum = CommonUtil.convertRoundMaxNumber(self.get_current_gradeId())
        strOrderBy = "UserId DESC"
        strWhereClause = "(UserStatus=0 "
        strWhere1 = strWhereClause + " And GradeId >= " + str(
            minNum) + " And GradeId<" + str(maxNum) + " And SubjectId=" + str(
                self.get_current_subjectId())
        strWhere1 += ")"
        strWhere2 = ""

        if self.userIds != "" and self.userIds.endswith(","):
            self.userIds = self.userIds[0:len(self.userIds) - 1]
            strWhere2 = " And UserId In(" + self.userIds + ")"

        if strWhere2 != "":
            strWhere2 = strWhereClause + strWhere2 + ")"
        if strWhere2 == "":
            strWhereClause = strWhere1
        else:
            strWhereClause = strWhere1 + " Or " + strWhere2
        #print "strWhereClause=" + strWhereClause
        pagingService = __spring__.getBean("pagingService")
        pagingQuery = PagingQuery()
        pagingQuery.keyName = "UserId"
        pagingQuery.fetchFieldsName = "*"
        pagingQuery.spName = "findPagingUser"
        pagingQuery.tableName = "Jitar_User"
        pagingQuery.whereClause = strWhereClause
        pagingQuery.orderByFieldName = strOrderBy
        totalCount = self.params.safeGetIntParam("totalCount")
        pager = Pager()
        pager.setCurrentPage(self.params.safeGetIntParam("page", 1))
        pager.setPageSize(10)
        pager.setItemNameAndUnit(u"用户", u"个")
        pager.setUrlPattern(self.params.generateUrlPattern())
        if totalCount == 0:
            pager.setTotalRows(pagingService.getRowsCount(pagingQuery))
        else:
            pager.setTotalRows(totalCount)

        blog_list = pagingService.getPagingList(pagingQuery, pager)
        request.setAttribute("blog_list", blog_list)
        request.setAttribute("pager", pager)
        return
Exemplo n.º 14
0
    def get_pic_news(self):
        cache_key = 'index_pic_news'
        pic_news = cache.get(cache_key)
        if pic_news == None:
            qry = SiteNewsQuery(
                """ snews.newsId, snews.title, snews.picture """)
            qry.hasPicture = True
            qry.subjectId = 0
            pic_news = qry.query_map(5)
            if pic_news == None: return
            for p in pic_news:
                p_url = p["picture"]
                p_url_path = p_url[0:p_url.rfind("/") + 1]
                p_url_fileName = p_url[p_url.rfind("/") + 1:p_url.rfind(".")]
                p_url_fileExt = p_url[p_url.rfind("."):]
                p_url_fileName = CommonUtil.escape(
                    CommonUtil.urlGB2312Encode(p_url_fileName))
                p["picture"] = p_url_path + p_url_fileName + p_url_fileExt
            cache.put(cache_key, pic_news)

        request.setAttribute("pic_news", pic_news)
Exemplo n.º 15
0
    def execute(self):
        if self.loginUser == None:
            return ActionResult.LOGIN

        accessControlService = __spring__.getBean("accessControlService")
        if accessControlService.isSystemAdmin(self.loginUser) == False:
            self.addActionError(u"没有管理站点配置的权限,只有超级管理员才能进行管理。")
            return ActionResult.ERROR

        strFile = request.getServletContext().getRealPath("/")
        strFile = strFile + "html" + File.separator
        strFile = URLDecoder.decode(strFile, "utf-8")
        file = File(strFile)
        if file.exists() == False:
            file.mkdirs()
        #创建学科导航
        strFile = strFile + "updateinfo.htm"
        file = File(strFile)
        if request.getMethod() == "POST":
            params = ParamUtil(request)
            html = params.safeGetStringParam("updateInfo")
            fw = OutputStreamWriter(FileOutputStream(file), "utf-8")
            fw.flush()
            fw.write(html)
            fw.close()
            siteIndexPartService = __spring__.getBean("siteIndexPartService")
            if html == "":
                siteIndexPart = siteIndexPartService.getSiteIndexPartByModuleName(
                    u"系统维护通知")
                if siteIndexPart != None:
                    siteIndexPartService.deleteSiteIndexPart(siteIndexPart)
            else:
                siteIndexPart = siteIndexPartService.getSiteIndexPartByModuleName(
                    u"系统维护通知")
                if siteIndexPart == None:
                    siteIndexPart = SiteIndexPart()
                siteIndexPart.setModuleName(u"系统维护通知")
                siteIndexPart.setModuleZone(1)
                siteIndexPart.setModuleOrder(0)
                siteIndexPart.setModuleDisplay(1)
                siteIndexPart.setModuleHeight(0)
                siteIndexPart.setContent(html)
                siteIndexPart.setPartType(100)
                siteIndexPart.setShowType(0)
                siteIndexPart.setShowBorder(0)
                siteIndexPartService.saveOrUpdateSiteIndexPart(siteIndexPart)
            request.setAttribute("deleteCache", "1")
        else:
            html = CommonUtil.readFile(file.getCanonicalPath(), "UTF-8")
            request.setAttribute("deleteCache", "0")

        request.setAttribute("updateInfo", html)
        return "/WEB-INF/ftl/admin/admin_site_update.ftl"
Exemplo n.º 16
0
    def get_subject_comissioner(self):
        #qry = UserQuery(""" u.loginName, u.nickName, u.trueName,u.userIcon, u.blogName, u.createDate,
        #                    u.myArticleCount, u.otherArticleCount, u.resourceCount, u.blogIntroduce,u.articleCount """)
        #qry.setSubjectCondition(self.subject)
        #qry.isComissioner = True
        #qry.FuzzyMatch = True
        #qry.metaSubjectId = self.get_current_subjectId()
        #qry.metaGradeId = self.get_current_gradeId()
        #comissioner_list = qry.query_map(6)

        minNum = CommonUtil.convertRoundMinNumber(self.get_current_gradeId())
        maxNum = CommonUtil.convertRoundMaxNumber(self.get_current_gradeId())
        strOrderBy = "VisitCount DESC"
        strWhereClause = "(UserStatus=0 And UserType LIKE '%/4/%' "
        strWhere1 = strWhereClause + " And GradeId >= " + str(
            minNum) + " And GradeId<" + str(maxNum) + " And SubjectId=" + str(
                self.get_current_subjectId())
        strWhere1 += ")"
        strWhere2 = ""

        if self.userIds != "":
            strWhere2 = " And UserId In(" + self.userIds + ")"

        if strWhere2 != "":
            strWhere2 = strWhereClause + strWhere2 + ")"
        if strWhere2 == "":
            strWhereClause = strWhere1
        else:
            strWhereClause = strWhere1 + " Or " + strWhere2
        pagingService = __spring__.getBean("pagingService")
        pagingQuery = PagingQuery()
        pagingQuery.keyName = "UserId"
        pagingQuery.fetchFieldsName = "*"
        pagingQuery.spName = "findPagingUser"
        pagingQuery.tableName = "Jitar_User"
        pagingQuery.whereClause = strWhereClause
        pagingQuery.orderByFieldName = strOrderBy
        pagingQuery.topCount = 6
        comissioner_list = pagingService.getPagingList(pagingQuery)
        return comissioner_list
Exemplo n.º 17
0
    def execute(self):
        self.getBaseData()
        response.setContentType("text/html; charset=UTF-8")
        if self.loginUser == None:
            backUrl = request.getAttribute('javax.servlet.forward.request_uri')
            if backUrl == None or backUrl == "": backUrl = request.requestURI
            response.sendRedirect(
                CommonUtil.getSiteUrl(request) + "login.jsp?redUrl=" +
                CommonUtil.urlUtf8Encode(
                    CommonUtil.getSiteServer(request) + backUrl))
            return

        if self.prepareCourseId == 0:
            self.printer.write(u"无效的课程标识。")
            return
        prepareCourse = self.getBasePrepareCourse()
        if prepareCourse == None:
            self.printer.write(u"没有加载到所请求的备课。")
            return
        if self.canView(prepareCourse) == False:
            self.printer.write(u"您无权查看本内容。")
            return

        if self.isPrepareCourseMember() == False:
            self.printer.write(u"您无权编辑备课内容。")
            return

        # 判断锁定人是否是当前用户
        if prepareCourse.lockedUserId == None or prepareCourse.lockedUserId == 0:
            self.printer.write(u"当前没有被锁定。")
            return
        if prepareCourse.lockedUserId != self.loginUser.userId:
            self.printer.write(u"当前集备的锁定者不是您本人。锁定者userId = " +
                               str(prepareCourse.lockedUserId))
            return
        prepareCourse.setLockedUserId(0)
        self.pc_svc.updatePrepareCourse(prepareCourse)
        response.sendRedirect("../../0/")
Exemplo n.º 18
0
    def get_expert_list(self):
        #qry = UserQuery("""  u.loginName, u.blogName, u.nickName,u.trueName, u.userIcon, u.blogIntroduce,u.articleCount, subj.subjectId """)
        #qry.isExpert = True
        #qry.FuzzyMatch = True
        #qry.metaSubjectId = self.get_current_subjectId()
        #qry.metaGradeId = self.get_current_gradeId()
        #expert_list = qry.query_map(3)

        minNum = CommonUtil.convertRoundMinNumber(self.get_current_gradeId())
        maxNum = CommonUtil.convertRoundMaxNumber(self.get_current_gradeId())
        strOrderBy = "UserId DESC"
        strWhereClause = "(UserStatus=0 And UserType LIKE '%/3/%' "
        strWhere1 = strWhereClause + " And GradeId >= " + str(
            minNum) + " And GradeId<" + str(maxNum) + " And SubjectId=" + str(
                self.get_current_subjectId())
        strWhere1 += ")"
        strWhere2 = ""

        if self.userIds != "":
            strWhere2 = " And UserId In(" + self.userIds + ")"

        if strWhere2 != "":
            strWhere2 = strWhereClause + strWhere2 + ")"
        if strWhere2 == "":
            strWhereClause = strWhere1
        else:
            strWhereClause = strWhere1 + " Or " + strWhere2
        pagingService = __spring__.getBean("pagingService")
        pagingQuery = PagingQuery()
        pagingQuery.keyName = "UserId"
        pagingQuery.fetchFieldsName = "*"
        pagingQuery.spName = "findPagingUser"
        pagingQuery.tableName = "Jitar_User"
        pagingQuery.whereClause = strWhereClause
        pagingQuery.orderByFieldName = strOrderBy
        pagingQuery.topCount = 3
        expert_list = pagingService.getPagingList(pagingQuery)
        return expert_list
Exemplo n.º 19
0
 def execute(self):
   request.setAttribute("today", CommonUtil.rssDateFormat(Date()))
   type = request.getParameter("type")
   if type == "article":
       return self.article()
   elif type == "resource":
       return self.resource()
   elif type == "photo":
       return self.photo()
   elif type == "topic":
       return self.topic()
   else:
       response.setContentType("text/html; charset=UTF-8")
       return "/WEB-INF/ftl/site_rss.ftl"
Exemplo n.º 20
0
 def user_info(self):        
     request.setAttribute("user", self.user)
     self.putSubjectList()
     self.putGradeList()
     self.putUserCategories()
 
     folder = File(application.getRealPath("/images/deficon/"));
     if folder.exists() == False or folder.isDirectory() == False:
         return
     
     icons = []
     for f in folder.listFiles():
         ext = CommonUtil.getFileExtension(f.getName()).lower()
         if "jpg" == ext or "gif" == ext or "png" == ext:
             icons.append("images/deficon/" + f.getName())
     if len(icons) > 0:
         request.setAttribute("icon_list", icons)
Exemplo n.º 21
0
    def subject_options(self):
        gradeId = self.params.safeGetIntParam("gradeId")
        if gradeId == None or gradeId == 0:
            qry = Command(
                """ SELECT distinct metaSubject as metaSubject FROM Subject """
            )
        else:
            gradeId = CommonUtil.convertRoundMinNumber(gradeId)
            #gradeId=gradeId[0]+"000"
            qry = Command(
                """ SELECT metaSubject as metaSubject FROM Subject Where metaGradeId ="""
                + str(gradeId))
        subjectList = qry.open()
        #print subjectList
        request.setAttribute("subject_list", subjectList)

        return "/WEB-INF/ftl/admin/subject_options_ajax.ftl"
Exemplo n.º 22
0
 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()
Exemplo n.º 23
0
 def validSubjectGrade(self, gradeId, subjectId):
     if gradeId == None and subjectId == None:
         return True
     subjectService = __jitar__.subjectService
     if gradeId != None and subjectId != None:
         gradeId1 = CommonUtil.convertRoundMinNumber(gradeId)
         sl = subjectService.getSubjectByMetaGradeSubjectId(gradeId1, subjectId)
         if sl == None:
             return False
     elif gradeId != None:
         sl = subjectService.getGrade(gradeId)
         if sl == None:
             return False
     elif subjectId != None:
         sl = subjectService.getSubjectByMetaSubjectId(subjectId)
         if sl == None:
             return False
     return True
Exemplo n.º 24
0
    def execute(self):
        #检查是否 存在根节点
        unitList = self.unitService.getChildUnitListByParenId(0, [False])
        if len(unitList) > 0:
            self.addActionError(u"根节点已经存在,只能有一个根节点。")
            return ActionResult.ERROR

        if request.getMethod() == "POST":
            enname = self.params.safeGetStringParam("enname")
            title = self.params.safeGetStringParam("title")
            siteTitle = self.params.safeGetStringParam("siteTitle")
            if enname == "" or title == "":
                self.addActionError(u"机构名称和英文名称不能为空。")
                return ActionResult.ERROR
            if siteTitle == "":
                self.addActionError(u"机构网站名称不能为空。")
                return ActionResult.ERROR
            if CommonUtil.isValidName(enname) == False:
                self.addActionError(u"英文名称只能是英文字母、数字并且必须以英文字母开头。")
                return ActionResult.ERROR

            unit = Unit()
            unit.setUnitName(enname)
            unit.setUnitTitle(title)
            unit.setSiteTitle(siteTitle)
            unit.setParentId(0)
            unit.setUnitPathInfo("")
            unit.setHasChild(False)
            self.unitService.saveOrUpdateUnit(unit)
            unit.setUnitPathInfo("/" + str(unit.unitId) + "/")
            self.unitService.saveOrUpdateUnit(unit)

            # 将管理员添加到根机构中。
            userService = __spring__.getBean("userService")
            u = userService.getUserByLoginName("admin")
            if u != None:
                u.setUnitId(unit.unitId)
                u.setUnitPathInfo(unit.unitPathInfo)
                userService.updateUserUnit(u)

            return "/WEB-INF/ftl/admin/admin_add_unit_root_success.ftl"

        return "/WEB-INF/ftl/admin/admin_add_unit_root.ftl"
Exemplo n.º 25
0
 def do_business(u, batcher):
   oldUserType = u.userType
   if userTypeId > 0:
     #增加
     if oldUserType == None:
       self.userService.updateUserType(u.userId, "/" + str(userTypeId) + "/")
     else:
       if oldUserType.find("/" + str(userTypeId) + "/") == -1:
         oldUserType = oldUserType + str(userTypeId) + "/"
         #按照从小到大排序
         oldUserType = CommonUtil.sortNumberString(oldUserType)
         self.userService.updateUserType(u.userId, oldUserType)
   elif userTypeId < 0:
     #取消设置
     if oldUserType != None and oldUserType.find("/" + str(abs(userTypeId)) + "/") > -1:
       oldUserType = oldUserType.replace("/" + str(abs(userTypeId)) + "/","/")
       if oldUserType == "/" : oldUserType = None
       self.userService.updateUserType(u.userId, oldUserType)
   return True
Exemplo n.º 26
0
    def execute(self):
        # 解析 uri.
        if self.parseUri() == False:
            return self.sendNotFound(self.uri)

        # 得到要访问的协作组, 访问者角色, 并验证其可访问状态.
        if self.getGroupInfo(self.groupName) == False:
            actionLinks = [
                ActionLink(u"返回协作组列表",
                           CommonUtil.getSiteUrl(request) + "groups.action")
            ]
            request.setAttribute("actionLinks", actionLinks)
            return self.ACCESS_ERROR
        #print "group = ", self.group, ", visitor = ", self.visitor, ", gm = ", self.group_member

        uuid = group_svc.getGroupCateUuid(self.group)
        if uuid == CategoryService.GROUP_CATEGORY_GUID_KTYJ:
            #课题
            request.setAttribute("isKtGroup", "1")
        elif uuid == CategoryService.GROUP_CATEGORY_GUID_JTBK:
            #备课
            request.setAttribute("isKtGroup", "2")
        else:
            request.setAttribute("isKtGroup", "0")

        # 得到协作组首页.
        page = self.getGroupIndexPage(self.group)
        #print "page =", page
        if page == None:
            return self.sendNotFound()
        request.setAttribute("page", page)

        # 得到页面功能块.
        self.widget_list = self.getPageWidgets(page)
        #print "self.widget_list = ", self.widget_list
        request.setAttribute("widget_list", self.widget_list)
        request.setAttribute("widgets", self.widget_list)

        # 增加访问计数.
        self.incGroupVisitCount(self.group)

        return "/WEB-INF/group/default/index.ftl"
 def execute(self):
     self.getBaseData()
     if self.prepareCourseId == 0:
         self.printer.write(u"无效的课程标识。")
         return
     prepareCourse = self.getBasePrepareCourse()
     if prepareCourse == None:
         self.printer.write(u"没有加载到所请求的备课。")
         return
     if self.canView(prepareCourse) == False:
         self.printer.write(u"您无权查看本内容。")
         return
     if prepareCourse.contentType == 2 or prepareCourse.contentType == 3 or prepareCourse.contentType == 4 or prepareCourse.contentType == 100:
         noHtmlContent = u"本共案为文档类型的,请点击查看。"
     else:
         noHtmlContent = CommonUtil.getTxtWithoutHTMLElement(
             prepareCourse.commonContent)
     request.setAttribute("prepareCourse", prepareCourse)
     request.setAttribute("noHtmlContent", noHtmlContent)
     response.setContentType("text/html; charset=UTF-8")
     return "/WEB-INF/ftl/course/show_preparecourse_common_abstract.ftl"
Exemplo n.º 28
0
 def topic(self):
     qry = TopicQuery(""" t.topicId, t.title, t.createDate, t.groupId, t.content,
                           u.loginName, u.userIcon, u.trueName, g.groupName                                                   
                           """)
     userId = request.getParameter("userId")      
     if(request.getParameter("userId") != None):
         qry.userId = int(userId)
         request.setAttribute("showType", "user")
         
     qry.isDeleted = 0
     qry.orderType = 0    
     result = qry.query_map(20)
     #print "result = ", result
     #return
     for a in result:
         str = a['createDate']
         str = CommonUtil.rssDateFormat(str)
         a['createDateString'] = str      
           
     request.setAttribute("topic_list", result)
     response.setContentType("text/xml; charset=UTF-8")
     return "/WEB-INF/ftl/site_rss_topic.ftl"
Exemplo n.º 29
0
  def article(self):
      qry = ArticleQuery(""" a.articleId, a.title, a.createDate, u.loginName, u.trueName, u.userIcon, subj.subjectName,
                           a.articleAbstract, a.articleContent, a.lastModified                           
                            """)
      userId = request.getParameter("userId")
      
      if(request.getParameter("userId") != None):
          qry.userId = int(userId)
          request.setAttribute("showType", "user")
                 
      qry.orderType = 0
      result = qry.query_map(20)
      #print "result = ", result
      for a in result:
          str = a['lastModified']
          str = CommonUtil.rssDateFormat(str)
          a['lastModifiedString'] = str      

                
      request.setAttribute("article_list", result)
      response.setContentType("text/xml; charset=UTF-8")
      return "/WEB-INF/ftl/site_rss_article.ftl"
Exemplo n.º 30
0
  def photo(self):
      qry = PhotoQuery(""" p.photoId, p.title, p.createDate, p.lastModified, p.href,
                          u.loginName, u.userIcon, u.trueName, sc.name                                                     
                            """)
      userId = request.getParameter("userId")      
      if(request.getParameter("userId") != None):
          qry.userId = int(userId)
          request.setAttribute("showType", "user")
    
      qry.orderType = 0
      result = qry.query_map(20)
      #print "result = ", result
      #return
      for a in result:
          str = a['lastModified']
          str = CommonUtil.rssDateFormat(str)
          a['lastModifiedString'] = str         

                
      request.setAttribute("photo_list", result)
      
      response.setContentType("text/xml; charset=UTF-8")
      return "/WEB-INF/ftl/site_rss_photo.ftl"