Ejemplo n.º 1
0
class group_action_list(ActionExecutor, ShowGroupBase, RequestMixiner,
                        ResponseMixiner, PageCheckMixiner):
    def __init__(self):
        self.params = ParamUtil(request)
        self.group_svc = __jitar__.groupService

    def execute(self):
        response.setContentType("text/html; charset=UTF-8")
        groupName = request.getAttribute("groupName")
        if groupName == None or groupName == "":
            return ""

        group = group_svc.getGroupByName(groupName)
        if group == None:
            return self.notFound()

        page = self.getGroupIndexPage(group)
        page = {
            "pageId": 0,
            "layoutId": 2,  # 固定是布局2
            "isSystemPage": "true",
            "owner": "user",
            "title": "",
            "skin": page.skin
        }

        # 构造widgets .
        widgets = [{
            "id": "1",
            "pageId": 0,
            "columnIndex": 1,
            "title": u"协作组信息",
            "module": "group_info",
            "ico": "",
            "data": ""
        }]
        self.getGroupInfo(group.groupName)
        request.setAttribute("widget_list", widgets)
        request.setAttribute("widgets", widgets)
        request.setAttribute("page", page)
        pager = self.params.createPager()
        pager.itemName = u"活动"
        pager.itemUnit = u"个"
        pager.pageSize = 20
        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, u.trueName, u.loginName
                            """)
        qry.ownerType = "group"
        qry.status = 0
        qry.ownerId = group.groupId
        #print "qry = ", str(qry.ownerId)
        pager.totalRows = qry.count()
        action_list = qry.query_map(pager)

        request.setAttribute("pager", pager)
        request.setAttribute("action_list", action_list)
        request.setAttribute("group", group)
        return "/WEB-INF/group/default/group_action_list.ftl"
Ejemplo n.º 2
0
class evaluation_stats(ActionResult, SubjectMixiner, EvaluationBase):
    def __init__(self):
        self.params = ParamUtil(request)

    def execute(self):
        if self.canManage() == False:
            self.addActionError(u"需要系统内容管理员进行管理。")
            return self.ERROR

        cmd = self.params.safeGetStringParam("cmd")
        if cmd == "": cmd = "list"
        if cmd == "list":
            self.list()

        return "/WEB-INF/ftl/evaluation/evaluation_stats.ftl"

    def list(self):
        qry = EvaluationPlanQuery(
            "ev.evaluationPlanId, ev.evaluationYear, ev.evaluationSemester, ev.evaluationTimes, ev.metaSubjectId, ev.metaGradeId, ev.startDate, ev.endDate, ev.userCount, ev.enabled, ev.attendUserCount, ev.evaluationCount"
        )
        pager = self.params.createPager()
        pager.itemName = u"评课活动"
        pager.itemUnit = u"个"
        pager.totalRows = qry.count()
        pager.pageSize = 20
        evaluation_list = qry.query_map(pager)
        request.setAttribute("pager", pager)
        request.setAttribute("evaluation_list", evaluation_list)
        self.putSubjectList()
        self.putGradeList()
Ejemplo n.º 3
0
class user_select_bottom:
    def __init__(self):
        self.params = ParamUtil(request)

    def execute(self):
        # 选择类型,单选还是多选?type:1单选,0多选
        type = self.params.safeGetStringParam("type")
        idTag = self.params.safeGetStringParam("idTag")
        titleTag = self.params.safeGetStringParam("titleTag")
        backType = self.params.safeGetStringParam("back")

        qry = UserQuery(
            " u.userId, u.loginName, u.trueName, u.createDate, unit.unitName, unit.unitTitle "
        )
        qry.orderType = 0
        qry.userStatus = 0
        pager = self.params.createPager()
        pager.itemName = u"用户"
        pager.itemUnit = u"个"
        pager.pageSize = 20
        pager.totalRows = qry.count()
        user_list = qry.query_map(pager)
        request.setAttribute("pager", pager)
        request.setAttribute("user_list", user_list)
        request.setAttribute("type", type)
        request.setAttribute("idTag", idTag)
        request.setAttribute("titleTag", titleTag)
        request.setAttribute("back", backType)
        return "/WEB-INF/common/user_select_bottom.ftl"
Ejemplo n.º 4
0
  def get_tag_list(self):
    # 投影查询字段.
    qry = TagQuery(""" tag.tagId, tag.tagName, tag.refCount, tag.refCount, tag.viewCount """)
    qry.disabled = False
    param = ParamUtil(request)
    pager = param.createPager()
    pager.itemName = u"标签"
    pager.itemUnit = u"个"
    pager.totalRows = qry.count()
    pager.pageSize = 20
    tag_list = qry.query_map(pager)
    request.setAttribute("pager", pager)
    return tag_list

    #最大和最小refCount.
    MaxRefCount = 1
    MinRefCount = 1
    
    # 产生随机标签大小, 用于构造出标签云, 页面上写 style='font-size:${fontSize} px'.
    for tag in tag_list:
      if MaxRefCount < tag["refCount"] : MaxRefCount = tag["refCount"] 
      if MinRefCount > tag["refCount"] : MinRefCount = tag["refCount"]
    
    #print "MinRefCount = " ,MinRefCount
    #print "MaxRefCount = " ,MaxRefCount
    for tag in tag_list:
        if MaxRefCount == MinRefCount :
            tag["fontSize"] = 0
        else :
            tag["fontSize"] = ((tag["refCount"] - MinRefCount) * 6) / (MaxRefCount - MinRefCount)        
        if tag["fontSize"] < 0 : tag["fontSize"] = 0
        if tag["fontSize"] > 6 : tag["fontSize"] = 6

    # DEBUG: print "tag_list = ", tag_list
    return tag_list
Ejemplo n.º 5
0
class showVideoList:
    def __init__(self):
        self.params = ParamUtil(request)
        self.categoryName = None
        self.type = "new"
        self.video_svc = __spring__.getBean("videoService")

    def execute(self):
        vid = self.params.getIntParam("vid")

        self.type = self.params.getStringParam("type")
        if self.type == None or self.type == "":
            self.type = "new"

        if (vid != None) and (vid != 0):
            video = self.video_svc.findById(vid)
            self.categoryName = video.staple
        else:
            self.categoryName = self.params.getStringParam("categoryName")

        request.setAttribute("categoryName", self.categoryName)
        request.setAttribute("categoryShowTitle", u"所有视频")
        if ((self.categoryName != None) and (self.categoryName != "")):
            request.setAttribute("categoryShowTitle",
                                 self.categoryName + u"分类下的所有视频")
        else:
            if self.type == "new":
                request.setAttribute("categoryShowTitle", u"最新视频")
            if self.type == "hot":
                request.setAttribute("categoryShowTitle", u"视频排行")

        request.setAttribute("type", type)

        self.get_video_with_pager()

        # 页面导航高亮为 'video'
        request.setAttribute("head_nav", "video")

        return "/WEB-INF/ftl/show_video_list.ftl"

    def get_video_with_pager(self):
        pager = self.params.createPager()
        pager.itemName = u"视频"
        pager.itemUnit = u"个"
        pager.pageSize = 24
        qry = VideoQuery(
            """ v.videoId, v.title, v.createDate, v.href, v.userId, u.loginName, u.nickName, v.summary,v.flvThumbNailHref """
        )
        if ((self.categoryName != None) and (self.categoryName != "")):
            qry.sysCateTitle = self.categoryName
        if self.type == "new":
            qry.orderType = 1
        elif self.type == "hot":
            qry.orderType = 2
        else:
            qry.orderType = 0
        pager.totalRows = qry.count()
        video_list = qry.query_map(pager)
        request.setAttribute("video_list", video_list)
        request.setAttribute("pager", pager)
Ejemplo n.º 6
0
class myaction(BaseAction):
    act_svc = __jitar__.actionService

    def execute(self):
        self.params = ParamUtil(request)
        self.out = response.writer
        if self.loginUser == None:
            self.addActionError(u"请先<a href='../../login.jsp'>登录</a>")
            return self.ERROR

        if request.getMethod() == "POST":
            return self.actionPost()
        else:
            qry = ActionUserUnitQuery(
                """ actu.actionUserId, actu.actionId, actu.actionUserId, actu.title,actu.startDateTime,actu.createDate,
                                              actu.actionUserStatus, actu.actionStatus, actu.ownerType, actu.ownerId
                                         """)
            qry.userId = self.loginUser.userId
            pager = self.params.createPager()
            pager.itemName = u"活动"
            pager.itemUnit = u"个"
            pager.pageSize = 10
            pager.totalRows = qry.count()
            user_action = qry.query_map(pager)
            request.setAttribute("user_action", user_action)
            request.setAttribute("pager", pager)
            return "/WEB-INF/ftl/action/myaction.ftl"

    def actionPost(self):
        ErrMsg = ""
        cmd = self.params.getStringParam("cmd")
        guids = self.params.safeGetIntValues("guid")
        if guids.size() < 1:
            self.addActionError(u"请先选择一个活动")
            self.addActionLink(u"返回", "myaction.py")
            return self.ERROR
        for actId in guids:
            action = self.act_svc.getActionByActionUserId(actId)
            if action.status != 0:
                ErrMsg = ErrMsg + u"<li>名为 " + action.title + u" 的活动不是一个正常状态。无法进行操作."
                continue
            if cmd == "attend":
                qry = """ UPDATE ActionUser Set status = 1 WHERE actionUserId = :actionUserId """
                command = Command(qry)
                command.setInteger("actionUserId", actId)
                command.update()
            if cmd == "quit":
                qry = """ UPDATE ActionUser Set status = 2 WHERE actionUserId = :actionUserId"""
                command = Command(qry)
                command.setInteger("actionUserId", actId)
                command.update()
            if cmd == "leave":
                qry = """ UPDATE ActionUser Set status = 3 WHERE actionUserId = :actionUserId """
                command = Command(qry)
                command.setInteger("actionUserId", actId)
                command.update()
        if ErrMsg == "": ErrMsg = u"操作已完成"
        self.addActionMessage(ErrMsg)
        self.addActionLink(u"返回", "myaction.py")
        return self.SUCCESS
Ejemplo n.º 7
0
    def execute(self):
        site_config = SiteConfig()
        site_config.get_config()

        param = ParamUtil(request)
        columnId = param.safeGetIntParam("columnId")
        jitarColumnService = __spring__.getBean("jitarColumnService")
        jitarColumn = jitarColumnService.getJitarColumnById(columnId)
        if jitarColumn == None:
            request.setAttribute("NoJitarColumn", "")
            return "/WEB-INF/ftl/jimo/moreColumnNews.ftl"

        self.pager = param.createPager()
        self.pager.itemName = u""
        self.pager.itemUnit = u"条"
        self.pager.pageSize = 20

        qry = JitarColumnNewsQuery(
            "jcn.columnNewsId, jcn.columnId, jcn.title, jcn.picture, jcn.createDate"
        )
        qry.published = True
        qry.columnId = columnId
        self.pager.totalRows = qry.count()
        news_list = qry.query_map(self.pager)
        request.setAttribute("news_list", news_list)
        request.setAttribute("pager", self.pager)
        request.setAttribute("jitarColumn", jitarColumn)

        return "/WEB-INF/ftl/jimo/moreColumnNews.ftl"
Ejemplo n.º 8
0
class admin_action_comment_list(BaseAdminAction):
    def __init__(self):
        self.params = ParamUtil(request)

    def execute(self):
        if self.loginUser == None:
            self.out.println(u"请先<a href='../../login.jsp'>登录</a>,然后才能管理活动")
            return
        accessControlService = __spring__.getBean("accessControlService")
        if False == accessControlService.isSystemContentAdmin(self.loginUser):
            ActionError(
                u"没有管理权限。<a href='' onclick='window.history.back();return false;'>返回</a>"
            )
            return ActionResult.ERROR

        self.pager = self.params.createPager()
        self.pager.itemName = u"活动"
        self.pager.itemUnit = u"个"
        qry = ActionCommentQuery(""" actr.actionReplyId, actr.actionId,
                                actr.topic, actr.createDate, actr.content, actr.addIp, act.title,u.loginName,u.trueName
                                """)

        self.pager.totalRows = qry.count()
        action_comment_list = qry.query_map(self.pager)
        request.setAttribute("action_comment_list", action_comment_list)
        request.setAttribute("pager", self.pager)
        response.setContentType("text/html; charset=UTF-8")
        return "/WEB-INF/ftl/action/admin_action_comment_list.ftl"
Ejemplo n.º 9
0
class searchUser0:  
  cfg_svc = __jitar__.configService

  def __init__(self):
    self.params = ParamUtil(request)  
    return

  def execute(self):
    self.config = self.cfg_svc.getConfigure()
      
    # 用户
    self.userList()
    
    # 机构列表.
    self.get_units_list()

    singleuser = self.params.getIntParam("singleuser")  #1 用户单选 2 用户多选
    if singleuser == None:
      singleuser = 1
      
    inputUser_Id = self.params.getStringParam("inputUser_Id")
    inputUserName_Id = self.params.getStringParam("inputUserName_Id")
    inputLoginName_Id = self.params.getStringParam("inputLoginName_Id")
    request.setAttribute("singleuser", singleuser)
    request.setAttribute("inputUser_Id", inputUser_Id)
    request.setAttribute("inputUserName_Id", inputUserName_Id)
    request.setAttribute("inputLoginName_Id", inputLoginName_Id)
    # 返回
    response.contentType = "text/html; charset=UTF-8"
    return "/WEB-INF/ftl/searchUserList0.ftl"

  def userList(self):
    unitId = self.params.getIntParamZeroAsNull("unitId")
    userName = self.params.getStringParam("userName")
    qry = UserQuery2(" u.userId, u.loginName, u.userIcon, u.gender, u.blogName, u.trueName, u.unitId,  unit.unitName, unit.unitTitle ")
    qry.userStatus = 0
    qry.kk = userName
    pager = self.createPager()
    pager.totalRows = qry.count()
    user_list = qry.query_map(pager) 
    request.setAttribute("unitId", unitId)
    request.setAttribute("user_list", user_list)
    request.setAttribute("userName", userName)
    request.setAttribute("pager", pager)

  # 机构列表.
  def get_units_list(self):
    hql = """SELECT new Map(ut.unitId as unitId, ut.unitTitle as unitTitle) 
         FROM Unit ut 
         ORDER BY ut.unitName """     
    unit_list = Command(hql).open()
    request.setAttribute("unit_list", unit_list)

  def createPager(self):
    # private 构造人员的缺省 pager.
    pager = self.params.createPager()
    pager.itemName = u"用户"
    pager.itemUnit = u"个"
    pager.pageSize = 10
    return pager
Ejemplo n.º 10
0
class admin_specialsubject_list(ActionExecutor):
    def __init__(self):
        self.params = ParamUtil(request)

    def execute(self):
        if self.loginUser == None:
            self.addActionError(u"请先登录。")
            return self.LOGIN

        accessControlService = __spring__.getBean("accessControlService")
        if False == accessControlService.isSystemContentAdmin(self.loginUser):
            self.addActionError(u"管理专题需要管理员权限。")
            return self.ERROR

        if request.getMethod() == "POST":
            ss_svc = __spring__.getBean("specialSubjectService")
            guids = self.params.safeGetIntValues("guid")
            for g in guids:
                ss_svc.deleteSpecialSubjectById(g)

        qry = SpecialSubjectQuery(
            """ ss.specialSubjectId, ss.logo, ss.title,ss.createUserId, ss.createDate,ss.expiresDate """
        )
        pager = self.params.createPager()
        pager.itemName = u"专题"
        pager.itemUnit = u"个"
        pager.pageSize = 20
        pager.totalRows = qry.count()
        ss_list = qry.query_map(pager)
        request.setAttribute("ss_list", ss_list)
        request.setAttribute("pager", pager)
        return "/WEB-INF/ftl/specialsubject/admin_specialsubject_list.ftl"
Ejemplo n.º 11
0
class chatMsgList(ActionExecutor):
    def __init__(self):
        self.params = ParamUtil(request)
        self.usermessage_svc = __spring__.getBean("chatMessageService")

    def execute(self):
        roomId = self.params.safeGetIntParam("roomId")
        if roomId == None or roomId == 0:
            roomId = 1

        qry = ChatMsgQuery(
            """ roomId as roomId,senderId as senderId,senderName as senderName,receiverId as receiverId,receiverName as receiverName,talkContent as talkContent,sendDate as sendDate,faceImg as faceImg,senderColor as senderColor,receiverColor as receiverColor """
        )
        qry.roomId = str(roomId)
        pager = self.params.createPager()
        pager.itemName = u"信息"
        pager.itemUnit = u"个"
        pager.pageSize = 20
        pager.totalRows = qry.count()
        msgList = qry.query_map(pager)
        request.setAttribute("pager", pager)
        request.setAttribute("msgList", msgList)
        request.setAttribute("list_type", u"搜索")
        request.setAttribute("roomId", roomId)
        return "/WEB-INF/ftl/chat/chatMsgList.ftl"
Ejemplo n.º 12
0
class admin_action_list(BaseAdminAction):
    def __init__(self):
        self.params = ParamUtil(request)

    def execute(self):
        if self.loginUser == None:
            self.out.println(u"请先<a href='../../login.jsp'>登录</a>,然后才能管理活动")
            return
        accessControlService = __spring__.getBean("accessControlService")
        if False == accessControlService.isSystemContentAdmin(self.loginUser):
            ActionError(u"没有管理权限.")
            return ActionResult.ERROR

        self.pager = self.params.createPager()
        self.pager.itemName = u"活动"
        self.pager.itemUnit = u"个"
        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,u.loginName,u.trueName
                            """)

        self.pager.totalRows = qry.count()
        action_list = qry.query_map(self.pager)
        request.setAttribute("action_list", action_list)
        request.setAttribute("pager", self.pager)
        response.setContentType("text/html; charset=UTF-8")
        return "/WEB-INF/ftl/action/admin_action_list.ftl"
Ejemplo n.º 13
0
class admin_unit_manager(BaseAdminAction, SubjectMixiner):
    def execute(self):
        if self.loginUser == None:
            return ActionResult.LOGIN
        accessControlService = __spring__.getBean("accessControlService")
        if accessControlService.isSystemAdmin(self.loginUser) == False:
            if accessControlService.checkUserAccessControlIsExists(
                    self.loginUser.userId, AccessControl.OBJECTTYPE_SUPERADMIN,
                    0
            ) == False and accessControlService.checkUserAccessControlIsExists(
                    self.loginUser.userId,
                    AccessControl.OBJECTTYPE_SYSTEMUSERADMIN,
                    0) == False:  # 没有用户管理权.
                self.addActionError(u"您不具有用户管理权限, 或未经审核?")
                return ActionResult.ERROR

        self.params = ParamUtil(request)

        if request.getMethod() == "POST":
            self.accessControlService = __spring__.getBean(
                "accessControlService")
            guids = self.params.safeGetIntValues("guid")
            for g in guids:
                accessControl = self.accessControlService.getAccessControlById(
                    g)
                if accessControl != None:
                    self.accessControlService.deleteAccessControl(
                        accessControl)

        self.get_admin_list()
        ObjectType = [
            u"未知的权限", u"系统超级管理员", u"系统用户管理员", u"系统内容管理员", u"机构系统管理员",
            u"机构用户管理员", u"机构内容管理员", u"学科系统管理员", u"学科用户管理员", u"学科内容管理员",
            u"元学科内容管理员"
        ]

        request.setAttribute("ObjectType", ObjectType)
        return "/WEB-INF/ftl/admin/admin_unit_manager.ftl"

    def get_admin_list(self):
        qry = AccessControlQuery(
            "ac.accessControlId, ac.userId, ac.objectType, ac.objectId, ac.objectTitle, u.loginName,u.trueName,u.unitId"
        )
        qry.custormAndWhere = "(ac.objectType = 4 or ac.objectType = 5 or ac.objectType = 6)"
        qry.orderType = 1
        pager = self.createPager()
        pager.totalRows = qry.count()
        admin_list = qry.query_map(pager)
        request.setAttribute("pager", pager)
        request.setAttribute("admin_list", admin_list)

    def createPager(self):
        # pager.
        pager = self.params.createPager()
        pager.itemName = u"管理员"
        pager.itemUnit = u"名"
        pager.pageSize = 30
        return pager
Ejemplo n.º 14
0
class channel_placard(ChannelPage):
    def __init__(self):
        ChannelPage.__init__(self)
        self.params = ParamUtil(request)
        self.channelPageService = __spring__.getBean("channelPageService")        
        self.templateProcessor = __spring__.getBean("templateProcessor")
        self.channel = None
        
    def execute(self):
        channelId = self.params.safeGetIntParam("channelId")
        if channelId == 0:
            self.addActionError(u"您所访问的页面不存在!")
            return ActionResult.ACCESS_ERROR
        self.channel = self.channelPageService.getChannel(channelId)
        if self.channel == None:
            self.addActionError(u"无法加载指定的页面!")
            return ActionResult.ACCESS_ERROR
        map = HashMap()
        map.put("channel", self.channel)
        map.put("head_nav", "placard")
        
        # 输出页头
        headerContent = self.GenerateContentFromTemplateString(self.channel.headerTemplate)
        footerContent = self.GenerateContentFromTemplateString(self.channel.footerTemplate)        
        # 输出主体部分:    
        qry = PlacardQuery("""  pld.id, pld.title, pld.createDate """)
        qry.objType = 19
        qry.objId = channelId
        pager = self.createPager()
        pager.totalRows = qry.count()
        placard_list = qry.query_map(pager)
            
        map.put("placard_list", placard_list)
        map.put("pager", pager)

        if self.channel.skin == None :
            skin = "template1"
        elif self.channel.skin == "" :
            skin = "template1"
        else:
            skin = self.channel.skin
            
        mainContent = self.templateProcessor.processTemplate(map, "/WEB-INF/channel/" + skin + "/channel_placard.ftl", "utf-8")
        
        out = response.getWriter()
        if headerContent == "" and footerContent == "" and mainContent == "":
            out.println(u"该频道没有指定模板,无法显示页面内容。")
            return
        out.println(headerContent)
        out.println(mainContent)
        out.println(footerContent)
        
    def createPager(self):
        pager = self.params.createPager()
        pager.itemName = u"公告"
        pager.itemUnit = u"篇"
        pager.pageSize = 20
        return pager
class group_preparecourseplan_list(ActionExecutor, ShowGroupBase,
                                   RequestMixiner, ResponseMixiner,
                                   PageCheckMixiner):
    def __init__(self):
        self.params = ParamUtil(request)
        self.group_svc = __jitar__.groupService
        self.preparecourse_svc = __jitar__.prepareCourseService

    def execute(self):
        response.setContentType("text/html; charset=UTF-8")
        groupName = request.getAttribute("groupName")
        if groupName == None or groupName == "":
            return self.notFound()

        group = group_svc.getGroupByName(groupName)
        if group == None:
            return self.notFound()

        pager = self.params.createPager()
        qry = PrepareCoursePlanQuery(
            """ pcp.title, pcp.prepareCoursePlanId, pcp.startDate,pcp.endDate,pcp.planContent,pcp.createDate, pcp.defaultPlan """
        )
        qry.groupId = group.groupId
        pager.setPageSize(16)
        pager.itemName = u"备课计划"
        pager.itemUnit = u"个"
        plan_list = qry.query_map(pager)
        pager.totalRows = plan_list.size()

        request.setAttribute("plan_list", plan_list)
        request.setAttribute("pager", pager)

        page = self.getGroupIndexPage(group)
        page = {
            "pageId": 0,
            "layoutId": 2,  # 固定是布局2
            "isSystemPage": "true",
            "owner": "user",
            "title": "",
            "skin": page.skin
        }

        # 构造widgets .
        widgets = [{
            "id": "1",
            "pageId": 0,
            "columnIndex": 1,
            "title": u"协作组信息",
            "module": "group_info",
            "ico": "",
            "data": ""
        }]
        self.getGroupInfo(group.groupName)
        request.setAttribute("widget_list", widgets)
        request.setAttribute("widgets", widgets)
        request.setAttribute("page", page)
        return "/WEB-INF/group/default/group_preparecourseplan_list.ftl"
Ejemplo n.º 16
0
class manage_createPrepareCourse_common_comment(PrepareCoursePageService):
    def __init__(self):
        self.params = ParamUtil(request)
        self.printer = response.getWriter()        
        self.pc_svc = __jitar__.getPrepareCourseService()
        self.user_svc = __jitar__.getUserService()
        self.commentService = __jitar__.getCommentService()
        
    def execute(self):
        if self.loginUser == None:            
            self.printer.write(u"请先<a href='../../login.jsp'>登录</a>,然后才能进行管理")
            return
        
        self.getBaseData()
        self.prepareCourseId = self.params.getIntParam("prepareCourseId")
        if self.prepareCourseId == 0:
            self.printer.write(u"无效的备课标识。")
            return
    
        self.prepareCourse = self.pc_svc.getPrepareCourse(self.prepareCourseId)
        if self.prepareCourse == None:
            self.printer.write(u"没有加载到所请求的备课。")
            return
        
        if self.canManage(self.prepareCourse) == False:
            self.printer.write(u"您无权管理本备课。")
            return
        
        if request.getMethod() == "POST":
            self.deleteComment()
            
        self.getCommentList()        
        request.setAttribute("loginUser", self.loginUser)
        request.setAttribute("prepareCourse", self.prepareCourse)
        return "/WEB-INF/ftl/course/manage_createPrepareCourse_common_comment.ftl"

    def getCommentList(self):
        qry = CommentQuery("cmt.id,cmt.userId,cmt.content,cmt.createDate,cmt.userName")
        qry.objType = ObjectType.OBJECT_TYPE_PREPARECOURSE.getTypeId()
        qry.objId = self.prepareCourseId        
        qry.audit = 1
        pager = self.params.createPager()
        pager.itemName = u"评论"
        pager.itemUnit = u"条"
        pager.pageSize = 20
        pager.totalRows = qry.count()
        comment_list = qry.query_map(pager)
        request.setAttribute("comment_list", comment_list)
        request.setAttribute("pager", pager)
        
    def deleteComment(self):
        commentsId = self.params.safeGetIntValues("commentId")
        for id in commentsId:
            refComment = self.commentService.getComment(id)
            if refComment != None:
                self.commentService.deleteComment(refComment)
Ejemplo n.º 17
0
class show_more_group_links(ActionExecutor, ShowGroupBase, RequestMixiner,
                            ResponseMixiner, PageCheckMixiner):
    def execute(self):
        self.params = ParamUtil(request)
        groupService = __jitar__.groupService
        response.setContentType("text/html; charset=UTF-8")
        groupName = request.getAttribute("groupName")
        if groupName == None or groupName == "":
            return ""

        group = groupService.getGroupByName(groupName)
        if group == None:
            return self.notFound()
        page = self.getGroupIndexPage(group)
        page = {
            "pageId": 0,
            "layoutId": 2,  # 固定是布局2
            "isSystemPage": "true",
            "owner": "user",
            "title": "",
            "skin": page.skin
        }

        # 构造widgets .
        widgets = [{
            "id": "1",
            "pageId": 0,
            "columnIndex": 1,
            "title": u"协作组信息",
            "module": "group_info",
            "ico": "",
            "data": ""
        }]

        self.getGroupInfo(group.groupName)
        request.setAttribute("widget_list", widgets)
        request.setAttribute("widgets", widgets)
        request.setAttribute("page", page)

        pager = self.params.createPager()
        pager.itemName = u"链接"
        pager.itemUnit = u"个"
        pager.pageSize = 20

        qry = LinksQuery(
            "lnk.linkId, lnk.title, lnk.linkAddress, lnk.linkIcon")
        qry.objectType = ObjectType.OBJECT_TYPE_GROUP.getTypeId()
        qry.objectId = group.getGroupId()
        pager.totalRows = qry.count()
        link_list = qry.query_map(pager)
        print "link_list=", link_list
        request.setAttribute("link_list", link_list)
        request.setAttribute("pager", pager)
        request.setAttribute("group", group)
        return "/WEB-INF/group/default/show_more_group_links.ftl"
class user_joinedpreparecourse_list(BaseAction, RequestMixiner, ResponseMixiner, PageCheckMixiner):
    def __init__(self):
        self.params = ParamUtil(request)
        
    def execute(self):
        self.loginName = request.getAttribute("loginName")          
        writer = response.getWriter()                
        # 加载当前用户对象.
        self.user = user_svc.getUserByLoginName(self.loginName)
        request.setAttribute("user", self.user)
        hql = """SELECT p.skin
             FROM Page p 
             WHERE p.name = 'index' and p.objId = :userId and p.objType = 1
             """ 
        pageSkin = Command(hql).setInteger("userId", self.user.userId).scalar()
        #print "pageSkin = ", pageSkin
        if pageSkin == None or pageSkin == "": pageSkin = "skin1"
        
        # 构造页面数据,由于页面不是在数据库存在的,这里的数据是虚拟数据.
        #pages : [{id: ${page.pageId}, title: '${user.blogName!?js_string}', layoutId: ${page.layoutId!0} }],
        page = {
                "pageId":0,
                "layoutId":2, # 固定是布局2
                "isSystemPage" : "true", 
                "owner" : "user", 
                "title" :"",
                "skin":pageSkin
                }        
        request.setAttribute("page", page)
        self.page = self.getUserProfilePage(self.user)
        if self.page.customSkin != None:
            customSkin = JSONValue.parse(self.page.customSkin)
            request.setAttribute("customSkin", customSkin)
        
        # 构造widgets .
        widgets = [
                   {"id": "1", "pageId":0, "columnIndex":1,"title":u"个人档案","module":"profile", "ico":"", "data":""},
                   {"id": "placerholder1", "pageId":0, "columnIndex":2,"title":"","module":"placeholder", "ico":"", "data":""}
                  ]
        request.setAttribute("widgets",widgets)
        request.setAttribute("widget_list",widgets)
        #得到当前用户的创建的活动
        pager = self.params.createPager()
        qry = PrepareCourseMemberQuery(""" pc.prepareCourseId,pc.title, pc.createDate,pc.memberCount,pc.articleCount,pc.resourceCount,pc.actionCount,pc.topicCount,pc.topicReplyCount """)
        qry.status = 0
        qry.userId = self.user.userId
        pager.setPageSize(16)        
        pager.itemName = u"备课"
        pager.itemUnit = u"个"
        course_list = qry.query_map(pager)
        pager.totalRows = course_list.size()
        request.setAttribute("course_list", course_list)
        request.setAttribute("pager", pager)
        response.setContentType("text/html; charset=UTF-8")
        return "/WEB-INF/user/default/user_joinedpreparecourse_list.ftl"
class manage_createPrepareCourse_private_comment(PrepareCoursePageService):
    def __init__(self):
        self.params = ParamUtil(request)
        self.printer = response.getWriter()        
        self.pc_svc = __jitar__.getPrepareCourseService()
        self.user_svc = __jitar__.getUserService()
        
    def execute(self):
        if self.loginUser == None:            
            self.printer.write(u"请先<a href='../../login.jsp'>登录</a>,然后才能进行管理")
            return
        
        self.getBaseData()
        self.prepareCourseId = self.params.getIntParam("prepareCourseId")
        if self.prepareCourseId == 0:
            self.printer.write(u"无效的备课标识。")
            return
    
        self.prepareCourse = self.pc_svc.getPrepareCourse(self.prepareCourseId)
        if self.prepareCourse == None:
            self.printer.write(u"没有加载到所请求的备课。")
            return
        
        if self.canManage(self.prepareCourse) == False:
            self.printer.write(u"您无权管理本备课。")
            return
        
        if request.getMethod() == "POST":
            self.deleteComment()
            
        self.getPrepareCoursePrivateCommentList()        
        request.setAttribute("loginUser", self.loginUser)
        request.setAttribute("prepareCourse", self.prepareCourse)
        return "/WEB-INF/ftl/course/manage_createPrepareCourse_private_comment.ftl"

    def getPrepareCoursePrivateCommentList(self):
        pager = self.params.createPager()
        pager.itemName = u"评论"
        pager.itemUnit = u"条"
        qry = PrepareCoursePrivateCommentQuery(""" pcpc.prepareCoursePrivateCommentId,pcpc.title,pcpc.content,pcpc.createDate,pcpc.commentUserId,pcpc.commentedUserId """)
        qry.prepareCourseId = self.prepareCourseId
        pager.totalRows = qry.count()
        comment_list = qry.query_map(pager)
        request.setAttribute("pager",pager)
        request.setAttribute("comment_list",comment_list)
        return
    
    def deleteComment(self):
        guid = self.params.safeGetIntValues("prepareCoursePrivateCommentId")
        for id in guid:
            self.pc_svc.deletePrepareCoursePrivateComment(id)
class manage_createPrepareCourse_reply(PrepareCoursePageService):
    def __init__(self):
        self.params = ParamUtil(request)
        self.printer = response.getWriter()
        self.pc_svc = __jitar__.getPrepareCourseService()
        self.user_svc = __jitar__.getUserService()

    def execute(self):
        self.getBaseData()
        self.prepareCourseId = self.params.getIntParam("prepareCourseId")
        if self.prepareCourseId == 0:
            self.printer.write(u"无效的备课标识。")
            return

        self.prepareCourse = self.pc_svc.getPrepareCourse(self.prepareCourseId)
        if self.prepareCourse == None:
            self.printer.write(u"没有加载到所请求的备课。")
            return

        if self.canManage(self.prepareCourse) == False:
            self.printer.write(u"您无权管理本备课。")
            return

        if request.getMethod() == "POST":
            cmd = self.params.safeGetStringParam("cmd")
            if cmd == "delete":
                prepareCourseTopicReplyId = self.params.safeGetIntValues(
                    "prepareCourseTopicReplyId")
                for id in prepareCourseTopicReplyId:
                    self.pc_svc.deletePrepareCourseTopicReply(
                        self.prepareCourseId, id)

        pager = self.params.createPager()
        pager.itemName = u"回复"
        pager.itemUnit = u"个"
        qry = PrepareTopicReplyQuery(
            """ pctr.prepareCourseTopicReplyId, pctr.prepareCourseTopicId, pctr.prepareCourseStageId, pctr.title, pctr.createDate, pctr.userId,
                                    pctr.content,pct.title as pctTitle
                                    """)

        qry.prepareCourseId = self.prepareCourse.prepareCourseId
        pager.totalRows = qry.count()
        reply_list = qry.query_map(pager)

        request.setAttribute("pager", pager)
        request.setAttribute("reply_list", reply_list)
        request.setAttribute("prepareCourse", self.prepareCourse)

        response.setContentType("text/html; charset=UTF-8")
        return "/WEB-INF/ftl/course/manage_createPrepareCourse_reply.ftl"
class admin_specialsubject_video_list(ActionExecutor):
    def __init__(self):
        self.params = ParamUtil(request)
        self.specialSubjectId = 0

    def execute(self):
        if self.loginUser == None:
            self.addActionError(u"请先登录。")
            return self.LOGIN

        accessControlService = __spring__.getBean("accessControlService")
        if False == accessControlService.isSystemContentAdmin(self.loginUser):
            self.addActionError(u"管理专题需要管理员权限。")
            return self.ERROR

        self.specialSubjectId = self.params.safeGetIntParam("specialSubjectId")

        if self.specialSubjectId == 0:
            self.addActionError(u"无效的专题标识。")
            return self.ERROR

        if request.getMethod() == "POST":
            videoService = __spring__.getBean("videoService")

            guid = self.params.safeGetIntValues("guid")
            for g in guid:
                video = videoService.findById(g)
                if video != None:
                    video.setSpecialSubjectId(None)
                    videoService.updateVideo(video)

        qry = VideoQuery(
            """ v.title, v.videoId, v.userId, v.createDate, v.flvHref, v.flvThumbNailHref """
        )
        qry.specialSubjectId = self.specialSubjectId
        pager = self.params.createPager()
        pager.itemName = u"视频"
        pager.itemUnit = u"个"
        pager.pageSize = 20
        pager.totalRows = qry.count()
        video_list = qry.query_map(pager)
        request.setAttribute("video_list", video_list)
        request.setAttribute("pager", pager)

        userUrlPattern = request.getSession().getServletContext(
        ).getInitParameter("userUrlPattern")
        if userUrlPattern != None and userUrlPattern != "":
            request.setAttribute("userUrlPattern", userUrlPattern)
        return "/WEB-INF/ftl/specialsubject/admin_specialsubject_video_list.ftl"
class manage_createPrepareCourse_action(PrepareCoursePageService):
    def __init__(self):
        self.params = ParamUtil(request)
        self.printer = response.getWriter()
        self.pc_svc = __jitar__.getPrepareCourseService()
        self.act_svc = __jitar__.getActionService()

    def execute(self):
        self.getBaseData()
        self.prepareCourseId = self.params.getIntParam("prepareCourseId")
        if self.prepareCourseId == 0:
            self.printer.write(u"无效的备课标识。")
            return

        prepareCourse = self.getBasePrepareCourse()
        if prepareCourse == None:
            self.printer.write(u"没有加载到所请求的备课。")
            return

        if self.canManage(prepareCourse) == False:
            self.printer.write(u"您无权管理本备课。")
            return

        if request.getMethod() == "POST":
            cmd = self.params.safeGetIntParam("cmdtype")
            guid = self.params.safeGetIntValues("guid")
            for actionId in guid:
                self.act_svc.updateActionStatus(cmd, int(actionId))

        pager = self.params.createPager()
        pager.itemName = u"活动"
        pager.itemUnit = u"个"
        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,u.trueName,u.loginName
                            """)
        qry.k = None  #防止右边查询冲突
        qry.ownerType = "preparecourse"
        qry.ownerId = prepareCourse.prepareCourseId
        pager.totalRows = qry.count()
        action_list = qry.query_map(pager)

        request.setAttribute("pager", pager)
        request.setAttribute("action_list", action_list)
        request.setAttribute("prepareCourse", prepareCourse)

        response.setContentType("text/html; charset=UTF-8")
        return "/WEB-INF/ftl/course/manage_createPrepareCourse_action.ftl"
Ejemplo n.º 23
0
    def execute(self):
        # 得到分页
        param = ParamUtil(request)
        self.pager = param.createPager()
        self.pager.itemName = u"公告"
        self.pager.itemUnit = u"条"
        self.pager.pageSize = 20

        qry = PlacardQuery("""  pld.id, pld.title, pld.createDate """)
        qry.objType = 100
        self.pager.totalRows = qry.count()
        card_list = qry.query_map(self.pager)
        request.setAttribute("card_list", card_list)
        request.setAttribute("pager", self.pager)

        return "/WEB-INF/ftl/showPlacardList.ftl"
Ejemplo n.º 24
0
class manage_relatedPrepareCourse(PrepareCoursePageService):
    def __init__(self):
        self.params = ParamUtil(request)
        self.printer = response.getWriter()
        self.pc_svc = __jitar__.getPrepareCourseService()

    def execute(self):
        self.getBaseData()
        self.prepareCourseId = self.params.getIntParam("prepareCourseId")
        if self.prepareCourseId == 0:
            self.printer.write(u"无效的备课标识。")
            return

        prepareCourse = self.getBasePrepareCourse()
        if prepareCourse == None:
            self.printer.write(u"没有加载到所请求的备课。")
            return

        if self.canManage(prepareCourse) == False:
            self.printer.write(u"您无权管理本备课。")
            return

        if request.getMethod() == "POST":
            cmd = self.params.safeGetStringParam("cmd")
            if cmd == "delete":
                prepareCourseTopicIds = self.params.safeGetIntValues("guid")
                for id in prepareCourseTopicIds:
                    self.pc_svc.removeRelatedPrepareCourse(
                        self.prepareCourseId, id)

        pager = self.params.createPager()
        pager.itemName = u"备课"
        pager.itemUnit = u"个"
        qry = PrepareRelatedQuery(
            """ pc.createUserId,pc.leaderId,pc.memberCount,pc.articleCount,pc.resourceCount,
                                    pc.status,pc.actionCount,pc.topicCount,pc.topicReplyCount,pc.viewCount,pc.startDate,pc.endDate,
                                    pc.title, pc.prepareCourseId, pc.createDate, pc.metaSubjectId, pc.gradeId,pc.recommendState
                                     """)
        qry.prepareCourseId = prepareCourse.prepareCourseId
        pager.totalRows = qry.count()
        course_list = qry.query_map(pager)

        request.setAttribute("pager", pager)
        request.setAttribute("preparecourse_list", course_list)
        request.setAttribute("prepareCourse", prepareCourse)
        response.setContentType("text/html; charset=UTF-8")
        return "/WEB-INF/ftl/course/manage_relatedPrepareCourse.ftl"
Ejemplo n.º 25
0
class showGroupTopic(ActionExecutor, ShowGroupBase, RequestMixiner, ResponseMixiner, PageCheckMixiner):
    def __init__(self):                
        self.params = ParamUtil(request)
        self.group_svc = __jitar__.groupService 
        self.bbs_svc = __jitar__.bbsService 
        
    def execute(self):
        groupId =  self.params.getIntParam("groupId")
        topicId =  self.params.getIntParam("topicId")
        if groupId == None or groupId == 0:
            return self.notFound()
        
        group = self.group_svc.getGroup(groupId)
        if group == None:
            return self.notFound()
        
        if self.loginUser == None:
            isMember = None
        else:
            isMember = self.group_svc.getGroupMemberByGroupIdAndUserId(group.groupId, self.loginUser.userId)
        self.getGroupInfo(group.groupName)
        page = self.getGroupIndexPage(group)
        page = {
                "pageId":0,
                "layoutId":8, # 固定是布局
                "isSystemPage" : "true", 
                "owner" : "user", 
                "title" :"",
                "skin":page.skin
                }
        
        pager = self.params.createPager()
        pager.setPageSize(10)
        pager.itemName = u"回复"
        pager.itemUnit = u"条"
        topic = self.bbs_svc.getTopicById(topicId);
        reply_list = self.bbs_svc.getReplyDataTable(topicId, pager)
        request.setAttribute("page", page)
        request.setAttribute("group", group)
        request.setAttribute("topic", topic)
        request.setAttribute("pager", pager)
        request.setAttribute("reply_list", reply_list)
        request.setAttribute("loginUser", self.loginUser)
        request.setAttribute("isMember", isMember)
        
        response.contentType = "text/html; charset=UTF-8"
        return "/WEB-INF/group/default/show_group_topic.ftl"
Ejemplo n.º 26
0
class admin_systemadmin_manager(BaseAdminAction, SubjectMixiner):
    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

        self.params = ParamUtil(request)

        if request.getMethod() == "POST":
            self.accessControlService = __spring__.getBean(
                "accessControlService")
            guids = self.params.safeGetIntValues("guid")
            for g in guids:
                if self.loginUser.userId != g:
                    accessControl = self.accessControlService.getAccessControlById(
                        g)
                    if accessControl != None:
                        self.accessControlService.deleteAccessControl(
                            accessControl)

        self.get_admin_list()
        return "/WEB-INF/ftl/admin/admin_systemadmin_manager.ftl"

    def get_admin_list(self):
        qry = AccessControlQuery(
            "ac.accessControlId, ac.userId, ac.objectType, ac.objectId, ac.objectTitle, u.loginName, u.trueName, u.unitId, u.userIcon"
        )
        qry.custormAndWhere = "(ac.objectType = 1 And ac.objectId = 0)"
        qry.orderType = 1
        pager = self.createPager()
        pager.totalRows = qry.count()
        admin_list = qry.query_map(pager)
        request.setAttribute("pager", pager)
        request.setAttribute("admin_list", admin_list)

    def createPager(self):
        # pager.
        pager = self.params.createPager()
        pager.itemName = u"系统管理员"
        pager.itemUnit = u"名"
        pager.pageSize = 30
        return pager
Ejemplo n.º 27
0
class myjoinedcourse(PrepareCoursePageService):
    def __init__(self):
        self.params = ParamUtil(request)
        self.pc_svc = __jitar__.getPrepareCourseService()
        self.sbj_svc = __jitar__.getSubjectService()
        self.printer = MessagePrint()
        self.out = response.getWriter()

    def execute(self):
        if self.loginUser == None:
            self.out.println(
                u"<a href='../../login.jsp' target='_top'>请先登录。</a>")
            return
        request.setAttribute("userid", self.loginUser.userId)
        if request.getMethod() == "POST":
            return self.coursePost()
        else:
            self.getBaseData()
            qry = PrepareCourseMemberQuery(
                " pc.title, pc.prepareCourseId, pc.createDate,pc.metaSubjectId,pc.gradeId,pc.createUserId,pc.leaderId,pcm.contentType "
            )
            qry.userId = self.loginUser.userId
            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("loginUser", self.loginUser)
            request.setAttribute("preparecourse_list", preparecourse_list)
            request.setAttribute("pager", pager)
            return "/WEB-INF/ftl/course/myjoinedcourse.ftl"

    def coursePost(self):
        guids = self.params.safeGetIntValues("guid")
        if guids.size() < 1:
            ErrMsg = u"请先选择一个课程"
            self.out.write(ErrMsg)
            return
        for pcId in guids:
            self.pc_svc.deletePrepareCourseMember(pcId, self.loginUser.userId)

        response.sendRedirect("myjoinedcourse.py")
        return
Ejemplo n.º 28
0
class admin_subject_manager:
    def execute(self):
        self.params = ParamUtil(request)

        if request.getMethod() == "POST":
            self.accessControlService = __spring__.getBean(
                "accessControlService")
            guids = self.params.safeGetIntValues("guid")
            for g in guids:
                accessControl = self.accessControlService.getAccessControlById(
                    g)
                if accessControl != None:
                    self.accessControlService.deleteAccessControl(
                        accessControl)

        self.get_admin_list()
        ObjectType = [
            u"未知的权限", u"系统超级管理员", u"系统用户管理员", u"系统内容管理员", u"机构系统管理员",
            u"机构用户管理员", u"机构内容管理员", u"学科系统管理员", u"学科用户管理员", u"学科内容管理员",
            u"元学科内容管理员"
        ]
        request.setAttribute("ObjectType", ObjectType)

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

    def get_admin_list(self):
        qry = AccessControlQuery(
            "ac.accessControlId, ac.userId, ac.objectType, ac.objectId, u.loginName,u.trueName,u.unitId"
        )
        qry.custormAndWhere = "(ac.objectType = 7 or ac.objectType = 8 or ac.objectType = 8)"
        qry.orderType = 1
        pager = self.createPager()
        pager.totalRows = qry.count()
        admin_list = qry.query_map(pager)
        request.setAttribute("pager", pager)
        request.setAttribute("admin_list", admin_list)

    def createPager(self):
        # pager.
        pager = self.params.createPager()
        pager.itemName = u"管理员"
        pager.itemUnit = u"名"
        pager.pageSize = 30
        return pager
class admin_specialsubject_article_list(ActionExecutor):
    def __init__(self):
        self.params = ParamUtil(request)
        self.specialSubjectId = 0

    def execute(self):
        if self.loginUser == None:
            self.addActionError(u"请先登录。")
            return self.LOGIN

        accessControlService = __spring__.getBean("accessControlService")
        if False == accessControlService.isSystemContentAdmin(self.loginUser):
            self.addActionError(u"管理专题需要管理员权限。")
            return self.ERROR

        self.specialSubjectId = self.params.safeGetIntParam("specialSubjectId")

        if self.specialSubjectId == 0:
            self.addActionError(u"无效的专题标识。")
            return self.ERROR

        if request.getMethod() == "POST":
            specialSubjectService = __spring__.getBean("specialSubjectService")

            guid = self.params.safeGetIntValues("guid")
            for g in guid:
                specialSubjectService.deleteSubjectArticleByArticleId(g)

        qry = SpecialSubjectArticleQuery(
            """ ssa.title,ssa.articleId,ssa.userId, ssa.loginName,ssa.userTrueName """
        )
        qry.specialSubjectId = self.specialSubjectId
        pager = self.params.createPager()
        pager.itemName = u"文章"
        pager.itemUnit = u"篇"
        pager.pageSize = 20
        pager.totalRows = qry.count()
        sa_list = qry.query_map(pager)
        request.setAttribute("sa_list", sa_list)
        request.setAttribute("pager", pager)

        return "/WEB-INF/ftl/specialsubject/admin_specialsubject_article_list.ftl"
Ejemplo n.º 30
0
class admin_course_list(BaseAdminAction):
    def __init__(self):
        self.params = ParamUtil(request)
        self.pc_svc = __jitar__.getPrepareCourseService()  
    
    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"
    
    def coursePost(self):
        guids = self.params.safeGetIntValues("guid")
        if guids.size() < 1:
            ErrMsg = u"请先选择一个课程"
            self.out.write(ErrMsg)
            return
        for pcId in guids:
            self.pc_svc.deletePrepareCourse(pcId)
        
        response.sendRedirect("admin_course_list.py")
        return