Exemplo n.º 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)
Exemplo n.º 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
Exemplo n.º 3
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"设置机构导航执行完毕,本页面执行一次就可以了。")
Exemplo n.º 5
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"设置学科导航执行完毕,本页面执行一次就可以了。")
Exemplo n.º 6
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()