Example #1
0
 def init_unit_nav(self, unit):
     unitId = unit.unitId
     siteNavService = __spring__.getBean("siteNavService")
     siteNameArray = [
         u"总站首页", u"机构首页", u"机构文章", u"机构资源", u"机构图片", u"机构视频", u"机构工作室"
     ]
     siteUrlArray = [
         "py/subjectHome.action", "", "article/", "resource/", "photo/",
         "video/", "blog/"
     ]
     siteHightlightArray = [
         "index", "unit", "unit_article", "unit_resource", "unit_photo",
         "unit_video", "unit_user"
     ]
     for i in range(0, len(siteNameArray)):
         #先判断是否存在
         siteNav = siteNavService.getSiteNavByName(
             SiteNav.SITENAV_OWNERTYPE_UNIT, unit.unitId, siteNameArray[i])
         if siteNav == None:
             siteNav = SiteNav()
             siteNav.setSiteNavName(siteNameArray[i])
             siteNav.setIsExternalLink(False)
             siteNav.setSiteNavUrl(siteUrlArray[i])
             siteNav.setSiteNavIsShow(True)
             siteNav.setSiteNavItemOrder(i)
             siteNav.setCurrentNav(siteHightlightArray[i])
             siteNav.setOwnerType(SiteNav.SITENAV_OWNERTYPE_UNIT)
             siteNav.setOwnerId(unit.unitId)
             siteNavService.saveOrUpdateSiteNav(siteNav)
Example #2
0
    def save(self):
        # 得到页面的 unitId,如果出现网络问题或从地址栏非法输入而获得失败的,则提示'未找到...'
        unitId = self.params.safeGetIntParam("unitId", 0)

        if unitId > 0:
            # 根据'unitId'获得其对应的机构对象.
            unit = self.unitService.findUnitById(unitId)
        else:
            unit = Unit()

        # 设置新的数据.
        self.setUnit(unit)

        #检查是否存在同名的机构
        unitTemp = self.unitService.getAllUnitOrChildUnitList(None)
        if self.checkExistUnit(unitTemp, unit) == True:
            self.addActionError(u"同名的机构已经存在")
            return ActionResult.ERROR

        # 保存
        self.unitService.saveOrUpdateUnit(unit)

        # 添加导航
        #print "unitId", unitId
        if unitId < 1:
            siteNameArray = [
                u"总站首页", u"机构首页", u"机构文章", u"机构资源", u"机构图片", u"机构视频", u"机构工作室"
            ]
            siteUrlArray = [
                "py/subjectHome.action", "", "article/", "resource/", "photo/",
                "video/", "blog/"
            ]
            siteHightlightArray = [
                "index", "unit", "unit_article", "unit_resource", "unit_photo",
                "unit_video", "unit_user"
            ]
            siteNavService = __spring__.getBean("siteNavService")
            for i in range(0, len(siteNameArray)):
                #先判断是否存在
                siteNav = siteNavService.getSiteNavByName(
                    SiteNav.SITENAV_OWNERTYPE_UNIT, unit.unitId,
                    siteNameArray[i])
                if siteNav == None:
                    siteNav = SiteNav()
                    siteNav.setSiteNavName(siteNameArray[i])
                    siteNav.setIsExternalLink(False)
                    siteNav.setSiteNavUrl(siteUrlArray[i])
                    siteNav.setSiteNavIsShow(True)
                    siteNav.setSiteNavItemOrder(i)
                    siteNav.setCurrentNav(siteHightlightArray[i])
                    siteNav.setOwnerType(SiteNav.SITENAV_OWNERTYPE_UNIT)
                    siteNav.setOwnerId(unit.unitId)
                    siteNavService.saveOrUpdateSiteNav(siteNav)

        # 返回.
        self.addActionLink(u"返回", "javascript:history.go(-1)")
        self.addActionLink(u"机构管理", "?cmd=list")
        return ActionResult.SUCCESS
Example #3
0
    def execute(self):
        self.channelId = self.params.safeGetIntParam("channelId")
        self.channel = self.channelPageService.getChannel(self.channelId)
        if self.channel == None:
            self.addActionError(u"不能加载频道对象。")
            return self.ERROR

        if self.isSystemAdmin() == False and self.isChannelSystemAdmin(
                self.channel) == False:
            self.addActionError(u"你无权管理本频道。")
            return self.ERROR
        siteNavId = self.params.safeGetIntParam("siteNavId")
        siteNav = self.siteNavService.getSiteNavById(siteNavId)

        if request.getMethod() == "POST":
            siteName = self.params.safeGetStringParam("siteName")
            siteUrl = self.params.safeGetStringParam("siteUrl")
            siteShow = self.params.safeGetIntParam("siteShow")
            siteOrder = self.params.safeGetIntParam("siteOrder")
            if siteName == "":
                self.addActionError(u"请输入导航名称.")
                return self.ERROR

            if siteUrl == "" and siteNav != None and siteNav.isExternalLink == True:
                self.addActionError(u"请输入导航地址.")
                return self.ERROR
            if siteNav == None:
                siteNav = SiteNav()
                siteNav.setIsExternalLink(True)
                siteNav.setOwnerType(3)
                siteNav.setOwnerId(self.channel.channelId)
            if siteNav.isExternalLink == True:
                siteNav.setSiteNavUrl(siteUrl)
            siteNav.setSiteNavName(siteName)
            if siteShow == 1:
                siteNav.setSiteNavIsShow(True)
            else:
                siteNav.setSiteNavIsShow(False)

            siteNav.setSiteNavItemOrder(siteOrder)
            self.siteNavService.saveOrUpdateSiteNav(siteNav)
            cache = __jitar__.cacheProvider.getCache('sitenav')
            if cache != None:
                cache_list = cache.getAllKeys()
                cache_key = "channel_nav_" + str(self.channel.channelId)
                for c in cache_list:
                    if c == cache_key:
                        cache.remove(c)
            self.addActionMessage(u"您成功编辑了一个自定义导航: " + siteName)
            self.addActionLink(
                u"返回",
                "channelnav.py?channelId=" + str(self.channel.channelId))
            return self.SUCCESS

        if siteNav != None:
            request.setAttribute("siteNav", siteNav)
        return "/WEB-INF/ftl/channel/channelnav_add.ftl"
Example #4
0
    def execute(self):
        if self.loginUser == None:
            return self.LOGIN        
        self.unit = self.getUnit()
        if self.unit == None:
            self.addActionError(u"您所访问的机构不存在!")
            return ActionResult.ERROR
        if self.isUnitAdmin() == False:
            self.addActionError(u"你没有管理的权限。")
            return ActionResult.ERROR
        
        siteNavId = self.params.safeGetIntParam("siteNavId")
        siteNav = self.siteNavService.getSiteNavById(siteNavId)        
        if request.getMethod() == "POST":
            siteName = self.params.safeGetStringParam("siteName")
            siteUrl = self.params.safeGetStringParam("siteUrl")
            #currentNav = self.params.safeGetStringParam("crtNav")
            siteShow = self.params.safeGetIntParam("siteShow")
            #siteType = self.params.safeGetIntParam("siteType")
            siteOrder = self.params.safeGetIntParam("siteOrder")
            if siteName == "":
                self.addActionError(u"请输入导航名称.")
                return ActionResult.ERROR
            
            if siteUrl == "" and siteNav != None and siteNav.isExternalLink == True:
                self.addActionError(u"请输入导航地址.")
                return ActionResult.ERROR            
            if siteNav == None:
                siteNav = SiteNav()
                siteNav.setIsExternalLink(True)
                siteNav.setOwnerType(1)
                siteNav.setOwnerId(self.unit.unitId)
            if siteNav.isExternalLink == True:
                siteNav.setSiteNavUrl(siteUrl)                
            siteNav.setSiteNavName(siteName)            
            if siteShow == 1:
                siteNav.setSiteNavIsShow(True)
            else:
                siteNav.setSiteNavIsShow(False)

            siteNav.setSiteNavItemOrder(siteOrder)
            self.siteNavService.saveOrUpdateSiteNav(siteNav)
            cache = __jitar__.cacheProvider.getCache('sitenav')
            if cache != None:                    
                cache_list = cache.getAllKeys()
                cache_key = "unit_nav_" + str(self.unit.unitId)
                for c in cache_list:
                    if c == cache_key:
                        cache.remove(c)
            self.addActionMessage(u"您成功编辑了一个自定义导航: " + siteName)
            self.addActionLink(u"返回", "unit_sitenav.py?unitId=" + str(self.unit.unitId))
            return ActionResult.SUCCESS
        
        if siteNav != None:
            request.setAttribute("siteNav", siteNav)            
        return "/WEB-INF/unitsmanage/site_nav_add.ftl"
Example #5
0
    def execute(self):
        user = self.loginUser
        if user == None:
            return ActionResult.LOGIN
        accessControlService = __spring__.getBean("accessControlService")
        if accessControlService.isSystemAdmin(user) == False:
            self.addActionError(u"没有管理权限.")
            return ActionResult.ERROR

        if accessControlService.isSystemAdmin(self.loginUser) == False:
            self.addActionError(u"只有 超级管理员 用户才可进行配置.")
            return ActionResult.ERROR
        siteNavId = self.params.safeGetIntParam("siteNavId")
        siteNav = self.siteNavService.getSiteNavById(siteNavId)
        #print "siteNavUrl = ", siteNav.isExternalLink

        if request.getMethod() == "POST":
            siteName = self.params.safeGetStringParam("siteName")
            siteUrl = self.params.safeGetStringParam("siteUrl")
            #currentNav = self.params.safeGetStringParam("crtNav")
            siteShow = self.params.safeGetIntParam("siteShow")
            #siteType = self.params.safeGetIntParam("siteType")
            siteOrder = self.params.safeGetIntParam("siteOrder")
            if siteName == "":
                self.addActionError(u"请输入导航名称.")
                return ActionResult.ERROR

            if siteUrl == "" and siteNav != None and siteNav.isExternalLink == True:
                self.addActionError(u"请输入导航地址.")
                return ActionResult.ERROR
            if siteNav == None:
                siteNav = SiteNav()
                siteNav.setIsExternalLink(True)
            if siteNav.isExternalLink == True:
                siteNav.setSiteNavUrl(siteUrl)
            siteNav.setSiteNavName(siteName)
            if siteShow == 1:
                siteNav.setSiteNavIsShow(True)
            else:
                siteNav.setSiteNavIsShow(False)

            siteNav.setSiteNavItemOrder(siteOrder)
            self.siteNavService.saveOrUpdateSiteNav(siteNav)
            self.siteNavService.setNewSiteNav(0, 0)
            return ActionResult.SUCCESS

        if siteNav != None:
            request.setAttribute("siteNav", siteNav)
        return "/WEB-INF/ftl/admin/site_nav_add.ftl"
Example #6
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

        if accessControlService.isSystemAdmin(self.loginUser) == False:
            self.addActionError(u"只有 admin 用户才可进行配置.")
            return ActionResult.ERROR

        unitService = __spring__.getBean("unitService")
        siteNavService = __spring__.getBean("siteNavService")
        #先删除已有的系统导航项目
        siteNavService.deleteSiteNavOfOwnerType(1, None, False)

        unitlist = unitService.getAllUnitOrChildUnitList(None)
        siteNameArray = [
            u"总站首页", u"机构首页", u"机构文章", u"机构资源", u"机构图片", u"机构视频", u"机构工作室"
        ]
        siteUrlArray = [
            "py/subjectHome.action", "", "article/", "resource/", "photo/",
            "video/", "blog/"
        ]
        siteHightlightArray = [
            "index", "unit", "unit_article", "unit_resource", "unit_photo",
            "unit_video", "unit_user"
        ]

        for unit in unitlist:
            for i in range(0, len(siteNameArray)):
                #先判断是否存在
                siteNav = siteNavService.getSiteNavByName(
                    SiteNav.SITENAV_OWNERTYPE_UNIT, unit.unitId,
                    siteNameArray[i])
                if siteNav == None:
                    siteNav = SiteNav()
                    siteNav.setSiteNavName(siteNameArray[i])
                    siteNav.setIsExternalLink(False)
                    siteNav.setSiteNavUrl(siteUrlArray[i])
                    siteNav.setSiteNavIsShow(True)
                    siteNav.setSiteNavItemOrder(i)
                    siteNav.setCurrentNav(siteHightlightArray[i])
                    siteNav.setOwnerType(SiteNav.SITENAV_OWNERTYPE_UNIT)
                    siteNav.setOwnerId(unit.unitId)
                    siteNavService.saveOrUpdateSiteNav(siteNav)
        response.getWriter().println(u"设置机构导航执行完毕,本页面执行一次就可以了。")
    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

        if accessControlService.isSystemAdmin(self.loginUser) == False:
            self.addActionError(u"只有 admin 用户才可进行配置.")
            return ActionResult.ERROR

        unitService = __spring__.getBean("unitService")
        siteNavService = __spring__.getBean("siteNavService")
        #得到全部的缺少导航的单位
        qry = UnitQuery("unit.unitId, unit.unitTitle")
        qry.hasChild = True
        unitlist = qry.query_map(qry.count())

        siteNameArray = [
            u"总站首页", u"机构首页", u"机构文章", u"机构资源", u"机构图片", u"机构视频", u"机构工作室"
        ]
        siteUrlArray = [
            "py/subjectHome.action", "", "article/", "resource/", "photo/",
            "video/", "blog/"
        ]
        siteHightlightArray = [
            "index", "unit", "unit_article", "unit_resource", "unit_photo",
            "unit_video", "unit_user"
        ]

        for unit in unitlist:
            #删除系统导航
            siteNavService.deleteSiteNavOfOwnerType(1, int(unit["unitId"]),
                                                    False)
            for i in range(0, len(siteNameArray)):
                siteNav = SiteNav()
                siteNav.setSiteNavName(siteNameArray[i])
                siteNav.setIsExternalLink(False)
                siteNav.setSiteNavUrl(siteUrlArray[i])
                siteNav.setSiteNavIsShow(True)
                siteNav.setSiteNavItemOrder(i)
                siteNav.setCurrentNav(siteHightlightArray[i])
                siteNav.setOwnerType(1)
                siteNav.setOwnerId(unit["unitId"])
                siteNavService.saveOrUpdateSiteNav(siteNav)
        response.getWriter().println(u"设置机构导航执行完毕,本页面执行一次就可以了。")
Example #8
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

        if accessControlService.isSystemAdmin(self.loginUser) == False:
            self.addActionError(u"只有 admin 用户才可进行配置.")
            return ActionResult.ERROR

        subjectService = __spring__.getBean("subjectService")
        siteNavService = __spring__.getBean("siteNavService")
        #先删除已有的系统导航项目
        siteNavService.deleteSiteNavOfOwnerType(2, None, False)

        subjectlist = subjectService.getSubjectList()
        siteNameArray = [
            u"总站首页", u"学科首页", u"文章", u"资源", u"工作室", u"协作组", u"集备", u"视频",
            u"活动", u"专题"
        ]
        siteUrlArray = [
            "py/subjectHome.action", "", "article/", "resource/", "blog/",
            "groups/", "preparecourse/", "video/", "activity/",
            "specialsubject/"
        ]
        siteHightlightArray = [
            "index", "subject", "article", "resource", "blog", "groups",
            "preparecourse", "video", "activity", "specialsubject"
        ]

        for subject in subjectlist:
            for i in range(0, len(siteNameArray)):
                siteNav = SiteNav()
                siteNav.setSiteNavName(siteNameArray[i])
                siteNav.setIsExternalLink(False)
                siteNav.setSiteNavUrl(siteUrlArray[i])
                siteNav.setSiteNavIsShow(True)
                siteNav.setSiteNavItemOrder(i)
                siteNav.setCurrentNav(siteHightlightArray[i])
                siteNav.setOwnerType(2)
                siteNav.setOwnerId(subject.subjectId)
                siteNavService.saveOrUpdateSiteNav(siteNav)
        response.getWriter().println(u"设置学科导航执行完毕,本页面执行一次就可以了。")
Example #9
0
 def addSubjectNav(self):
     siteNameArray = SubjectWebpart.SUBJECT_NAVNAME
     siteUrlArray = SubjectWebpart.SUBJECT_NAVURL
     siteHightlightArray = SubjectWebpart.SUBJECT_NAVHIGHLIGHT
     siteNavService = __spring__.getBean("siteNavService")
     i = 0
     for name in siteNameArray:
         siteNav = SiteNav()
         siteNav.setSiteNavName(siteNameArray[i])
         siteNav.setIsExternalLink(False)
         siteNav.setSiteNavUrl(siteUrlArray[i])
         siteNav.setSiteNavIsShow(True)
         siteNav.setSiteNavItemOrder(i)
         siteNav.setCurrentNav(siteHightlightArray[i])
         siteNav.setOwnerType(2)
         siteNav.setOwnerId(self.subject.getSubjectId())
         siteNavService.saveOrUpdateSiteNav(siteNav)
         i = i + 1
     self.clearcache()