Ejemplo n.º 1
0
 def genWebparts(self, unit):
     unit_webpart_list = self.unitService.getUnitWebpartList(unit.unitId)
     if len(unit_webpart_list) == 0:
         moduleName = [
             u"机构文章", u"机构图片", u"机构资源", u"机构视频", u"图片新闻", u"机构协作组", u"最新动态",
             u"最新公告", u"统计信息", u"调查投票", u"机构学科", u"机构集备", u"友情链接"
         ]
         i = 0
         for m in moduleName:
             i = i + 1
             unitWebpart = UnitWebpart()
             unitWebpart.setModuleName(m)
             unitWebpart.setDisplayName(m)
             unitWebpart.setRowIndex(i)
             unitWebpart.setVisible(True)
             unitWebpart.setSystemModule(True)
             unitWebpart.setUnitId(unit.getUnitId())
             if m == u"机构文章" or m == u"机构资源" or m == u"机构视频" or m == u"机构集备":
                 unitWebpart.setWebpartZone(4)
             elif m == u"图片新闻" or m == u"友情链接" or m == u"机构协作组":
                 unitWebpart.setWebpartZone(3)
             elif m == u"图片模块":
                 unitWebpart.setWebpartZone(2)
             elif m == u"机构学科":
                 unitWebpart.setWebpartZone(1)
             else:
                 unitWebpart.setWebpartZone(5)
             self.unitService.saveOrUpdateUnitWebpart(unitWebpart)
Ejemplo n.º 2
0
 def execute(self):
     self.unitService = __spring__.getBean("unitService")
     unit_list = self.unitService.getAllUnitOrChildUnitList(None, [False])
     for unit in unit_list:
         unit_webpart_list = self.unitService.getUnitWebpartList(
             unit.unitId)
         if len(unit_webpart_list) == 0:
             moduleName = [
                 u"机构文章", u"机构图片", u"机构资源", u"机构视频", u"图片新闻", u"机构协作组",
                 u"最新动态", u"最新公告", u"统计信息", u"调查投票", u"机构学科", u"机构集备",
                 u"友情链接"
             ]
             i = 0
             for m in moduleName:
                 i = i + 1
                 unitWebpart = UnitWebpart()
                 unitWebpart.setModuleName(m)
                 unitWebpart.setRowIndex(i)
                 unitWebpart.setVisible(True)
                 unitWebpart.setSystemModule(True)
                 unitWebpart.setUnitId(unit.getUnitId())
                 if m == u"机构文章" or m == u"机构资源" or m == u"机构视频" or m == u"机构集备":
                     unitWebpart.setWebpartZone(4)
                 elif m == u"图片新闻" or m == u"友情链接" or m == u"机构协作组":
                     unitWebpart.setWebpartZone(3)
                 elif m == u"图片模块":
                     unitWebpart.setWebpartZone(2)
                 else:
                     unitWebpart.setWebpartZone(5)
                 self.unitService.saveOrUpdateUnitWebpart(unitWebpart)
     self.params = ParamUtil(request)
     unitId = self.params.safeGetIntParam("unitId")
     if unitId > 0:
         response.sendRedirect("../index.py?unitId=" + str(unitId))
         return
     else:
         return "/WEB-INF/ftl/success.ftl"
Ejemplo n.º 3
0
    def execute(self):
        if self.loginUser == None:
            return self.LOGIN

        if self.unitService == None:
            self.addActionError(
                u"无法加载组织机构服务,请检查 applicationContext.xml 配置文件,是否缺少 unitService 节点。"
            )
            return self.ERROR

        self.unit = self.getUnit()
        if self.unit == None:
            self.addActionError(u"您所访问的机构不存在!")
            return self.ERROR

        if self.isUnitAdmin() == False:
            self.addActionError(u"你没有管理的权限。")
            return self.ERROR

        webpartId = self.params.safeGetIntParam("webpartId")
        if webpartId == 0:
            unitWebpart = UnitWebpart()
            unitWebpart.setUnitId(self.unit.unitId)
            unitWebpart.setRowIndex(0)
            unitWebpart.setSystemModule(False)
            unitWebpart.setVisible(True)
            unitWebpart.setShowCount(6)
            unitWebpart.setShowType(1)
            unitWebpart.setPartType(1)
        else:
            unitWebpart = self.unitService.getUnitWebpartById(webpartId)

        if request.getMethod() == "POST":
            moduleName = self.params.safeGetStringParam("moduleName")
            webpartZone = self.params.safeGetIntParam("webpartZone")
            sysCateId = self.params.safeGetIntParam("sysCateId")
            showCount = self.params.safeGetIntParam("showCount")
            if showCount == 0:
                showCount = 6
            if "" == moduleName:
                self.addActionError(u"请输入模块名称。")
                return self.ERROR

            if 0 == webpartZone:
                self.addActionError(u"请选择模块位置。")
                return self.ERROR
            if sysCateId == 0:
                self.addActionError(u"请选择一个系统分类。")
                return self.ERROR

            unitWebpart.setModuleName(moduleName)
            unitWebpart.setDisplayName(moduleName)

            unitWebpart.setWebpartZone(webpartZone)
            unitWebpart.setContent(None)
            unitWebpart.setCateId(sysCateId)
            unitWebpart.setShowCount(showCount)
            self.unitService.saveOrUpdateUnitWebpart(unitWebpart)
            response.sendRedirect("unit_custorm.py?unitId=" +
                                  str(self.unit.unitId))

        request.setAttribute("unitWebpart", unitWebpart)
        request.setAttribute("unit", self.unit)
        self.get_article_cate_list()
        return "/WEB-INF/unitsmanage/add_sys_module.ftl"
Ejemplo n.º 4
0
 def execute(self):
     unitService = __spring__.getBean("unitService")
     us = unitService.getAllUnitOrChildUnitList(None, [False])
     for u in us:
         unitWebpart = UnitWebpart()
         unitWebpart.setModuleName(u"机构学科")
         unitWebpart.setDisplayName(u"机构学科")
         unitWebpart.setSystemModule(True)
         unitWebpart.setUnitId(u.unitId)
         unitWebpart.setWebpartZone(1)
         unitWebpart.setRowIndex(1)
         unitWebpart.setContent(None)
         unitWebpart.setVisible(True)
         unitWebpart.setPartType(0)
         unitWebpart.setShowType(0)
         #print u.unitId
         unitService.saveOrUpdateUnitWebpart(unitWebpart)
     response.getWriter().println(u"<h1>ok,请勿重复执行。</h1>")