Ejemplo n.º 1
0
 def execute(self):
     self.loginName = request.getAttribute("loginName")
     # 加载当前用户对象.
     self.user = user_svc.getUserByLoginName(self.loginName)
     request.setAttribute("user", self.user)
     
     pager = self.params.createPager()  
     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
                         """)
     qry.ownerType = "user"
     qry.status = 0
     qry.createUserId = self.user.userId
     pager.setPageSize(16)        
     pager.itemName = u"活动"
     pager.itemUnit = u"个"
     action_list = qry.query_map(pager)
     pager.totalRows = action_list.size()
     
     #print "group_list = " , group_list
     request.setAttribute("action_list", action_list)        
     request.setAttribute("pager",pager)        
     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).first()
     #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 = JSONObject.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)
     
     response.setContentType("text/html; charset=UTF-8")
     return "/WEB-INF/user/default/user_actions.ftl"
 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 = JSONObject.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(20)        
     pager.itemName = u"备课"
     pager.itemUnit = u"个"
     course_list = qry.query_map(pager)
     pager.totalRows = qry.count()
     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"
Ejemplo n.º 3
0
 def execute(self):
     if self.loginUser == None:
         response.sendRedirect("../login.jsp")
         return None
     page = self.page_svc.getUserIndexPage(self.login_user)
     if page == None:
         self.addActionError(u"没有找到您的首页。")
         return ActionResult.ERROR
     if request.getMethod() == "POST":
         bgcolor = self.params.getStringParam("bgcolor")
         logo = self.params.getStringParam("logo")
         logoheight = self.params.getStringParam("logoheight")
         titletop = self.params.getStringParam("titletop")
         titleleft = self.params.getStringParam("titleleft")
         titledisplay = self.params.getStringParam("titledisplay")
         jstring = '{"bgcolor":"' + bgcolor + '","logo":"' + logo + '","logoheight":"' + logoheight + '","titleleft":"' + titleleft + '","titletop":"' + titletop + '","titledisplay":"' + titledisplay + '"}'
         jsObj = JSONObject.parse(jstring)
         self.page_svc.setPageCustomSkin(page, jsObj.toString())
         self.addActionMessage(u"自定义设置已保存")
         return ActionResult.SUCCESS
     else:
         if page.customSkin != None:
             customSkin = JSONObject.parse(page.customSkin)
             color = customSkin["bgcolor"]
             if len(color) > 0 and color[0:1] == "#": color = color[1:6]
             request.setAttribute("color", color)
             request.setAttribute("customSkin", customSkin)
         else:
             customSkin = {
                 "bgcolor": "",
                 "logo": "",
                 "logoheight": "",
                 "titledisplay": "",
                 "titleleft": "",
                 "titletop": ""
             }
             request.setAttribute("customSkin", customSkin)
         return "/WEB-INF/ftl/user/user_custom_info.ftl"
Ejemplo n.º 4
0
    def getSystemPageWithUserSkin(self, pk, user):
        # 得到此系统页面.
        sys_page = page_svc.getPageByKey(pk)
        if sys_page == None: return None

        # 得到用户个人主页.
        index_page = page_svc.getUserIndexPage(user._getUserObject())

        # 创建新页面.
        new_page = sys_page._getPageObject().clone()
        if index_page != None:
            new_page.skin = index_page.skin
            new_page.customSkin = index_page.customSkin
            if index_page.customSkin != None:
                customSkin = JSONObject.parse(index_page.customSkin)
                request.setAttribute("customSkin", customSkin)
        return new_page
Ejemplo n.º 5
0
    def getPrepareCoursePageWithCustomSkin(self, prepareCourse):
        cache_key = "prepareCourse_page_" + str(prepareCourse.prepareCourseId)
        page = cache.get(cache_key)
        if page == None:
            index_pk = PageKey(ObjectType.OBJECT_TYPE_PREPARECOURSE,
                               prepareCourse.prepareCourseId, 'index')
            page = page_svc.getPageByKey(index_pk)
            if page != None:
                cache.put(cache_key, page)
            #清空测试
            #cache.remove(cache_key)
        if page == None:
            page = self.createPrepareCourseIndexPage(prepareCourse)  #添加一个页面

        if page.customSkin != None:
            customSkin = JSONObject.parse(page.customSkin)
            request.setAttribute("customSkin", customSkin)
        return page
Ejemplo n.º 6
0
 def execute(self):
   self.loginName = request.getAttribute("loginName")
   # 得到要工作室主人, 并验证用户状态.
   self.user = user_svc.getUserByLoginName(self.loginName)
   request.setAttribute("user", self.user)
   #print "self.user = "******"self.page = ", self.page
   if self.page == None:
     return self.sendNotFound()
   request.setAttribute("page", self.page)
   if self.page.customSkin != None:
     customSkin = JSONObject.parse(self.page.customSkin)
     request.setAttribute("customSkin", customSkin)
     
   # 显示该页面.
   return self.getWidgetsAndReturn(self.page, self.PAGE_FTL)
Ejemplo n.º 7
0
 def execute(self):
     self.loginName = request.getAttribute("UserName")
     """
     if self.loginUser == None:
         response.sendRedirect(request.getServletContext().getContextPath() + "/u/" + self.loginName + "/html/index.html")
         return
     if self.loginName != self.loginUser.loginName:
         response.sendRedirect(request.getServletContext().getContextPath() + "/u/" + self.loginName + "/html/index.html")
         return
     
     """
     # 得到要工作室主人, 并验证用户状态.
     self.user = user_svc.getUserByLoginName(self.loginName)
     request.setAttribute("user", self.user)
     
     #print "self.user = "******"visitor", self.visitor)
     request.setAttribute("visitor_role", visitor_role)
     
     # 得到用户的首页.
     self.page = self.getUserIndexPage(self.user)
     if self.page == None:
       return self.sendNotFound()    
     request.setAttribute("page", self.page)
     if self.page.customSkin != None:
       customSkin = JSONObject.parse(self.page.customSkin)
       request.setAttribute("customSkin", customSkin)
     
     # 显示该页面.
     request.setAttribute("ru", request.getScheme() + "://" + request.getServerName() + ":" + str(request.getServerPort()) + request.getContextPath())
     return self.getWidgetsAndReturn(self.page, self.PAGE_FTL)
Ejemplo n.º 8
0
    def execute(self):
        self.loginName = request.getAttribute("loginName")
        # 解析 uri.
        if self.parseUri() == False:
            return self.sendNotFound(self.uri)

        # 得到要工作室主人, 并验证用户状态.
        self.user = user_svc.getUserByLoginName(self.loginName)
        request.setAttribute("user", self.user)
        #print "self.user = "******"self.category = ", self.category
        if self.category == None:
            return self.sendNotFound()
        request.setAttribute("category", self.category)

        # 得到资源分类显示页面.
        page = self.getUserResourceCategoryPage(self.user)
        #print "page = ", page
        if page == None:
            return self.sendNotFound()
        if page.customSkin != None:
            customSkin = JSONObject.parse(page.customSkin)
            request.setAttribute("customSkin", customSkin)
        request.setAttribute("page", page)

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

        return "/WEB-INF/user/default/resource_category_index.ftl"
Ejemplo n.º 9
0
    def execute(self):
        self.loginName = request.getAttribute("loginName")
        # 解析 uri.
        if self.parseUri() == False:
            return self.sendNotFound(self.uri)

        writer = response.getWriter()

        # 加载当前用户对象.
        self.user = user_svc.getUserByLoginName(self.loginName)
        request.setAttribute("user", self.user)
        #print "user = "******"loginUser", self.loginUser)

        pager = self.params.createPager()
        qry = FriendQuery(
            """ u.loginName, u.nickName, u.trueName, u.userIcon, u.qq, frd.addTime """
        )
        qry.userId = self.user.userId
        qry.isBlack = False
        qry.orderType = 0
        pager.setPageSize(16)
        pager.itemName = u"好友"
        pager.itemUnit = u"位"
        pager.totalRows = qry.count()
        friend_list = qry.query_map(pager)

        #print "friend_list = " , friend_list
        request.setAttribute("friend_list", friend_list)
        request.setAttribute("pager", pager)
        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: '${self.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 = JSONObject.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)

        response.setContentType("text/html; charset=UTF-8")
        return "/WEB-INF/user/default/user_friends.ftl"
Ejemplo n.º 10
0
    def execute(self):
        self.params = ParamUtil(request)
        self.loginName = request.getAttribute("loginName")
        # 解析 uri
        if self.parseUri() == False:
            return self.sendNotFound(self.uri)

        # 得到要工作室主人, 并验证用户状态
        self.user = user_svc.getUserByLoginName(self.loginName)
        request.setAttribute("user", self.user)
        request.setAttribute("loginUser", self.loginUser)
        #print "self.user = "******"loginUser", self.loginUser)

        # 创建分页对象
        pager = self.params.createPager()
        pager.setPageSize(18)
        qry = VideoQuery(
            """ v.videoId, v.title, v.createDate, v.lastModified, v.flvThumbNailHref, v.href, v.commentCount, v.viewCount, u.nickName, u.loginName, u.userIcon """
        )
        qry.userId = self.user.userId
        qry.isPrivateShow = None
        if self.categoryId != 0:
            qry.userStapleId = self.categoryId

        #print "userStapleId = ", userStapleId
        pager.totalRows = qry.count()
        pager.itemName = u"视频"
        pager.itemUnit = u"个"
        qry.orderType = 0

        result = qry.query_map(pager)
        request.setAttribute("video_list", result)
        request.setAttribute("pager", pager)

        hql = """SELECT new Map(p.skin as skin)
             FROM Page p 
             WHERE p.name = 'index' and p.objId = :userId and p.objType = 1
             """
        pageSkin = Command(hql).setInteger("userId", self.user.userId).first()

        # 构造页面数据,由于页面不是在数据库存在的,这里的数据是虚拟数据.
        #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["skin"]
        }
        request.setAttribute("page", page)
        self.page = self.getUserProfilePage(self.user)
        if self.page.customSkin != None:
            customSkin = JSONObject.parse(self.page.customSkin)
            request.setAttribute("customSkin", customSkin)

        # 构造widgets .
        widgets = [
            {
                "id": "1",
                "pageId": 0,
                "columnIndex": 1,
                "title": u"个人档案",
                "module": "profile",
                "ico": "",
                "data": ""
            }
            #, {"id": "2", "pageId":0, "columnIndex":1, "title":"视频分类", "module":"video_cate", "ico":"", "data":""}
            ,
            {
                "id": "placerholder1",
                "pageId": 0,
                "columnIndex": 2,
                "title": "",
                "module": "placeholder",
                "ico": "",
                "data": ""
            }
        ]

        request.setAttribute("widgets", widgets)
        request.setAttribute("widget_list", widgets)

        response.setContentType("text/html; charset=UTF-8")
        return "/WEB-INF/user/default/user_videos.ftl"
Ejemplo n.º 11
0
    def execute(self):
        if self.loginUser == None:
            response.sendRedirect("../../login.jsp")
            return None
        self.getBaseData()
        self.getBasePrepareCourse()

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

        if self.canManage(self.prepareCourse) == False:
            self.printer.write(u"你无权进行管理。")
            return

        self.prepareCourse = self.getBasePrepareCourse()
        page = self.getPrepareCoursePageWithCustomSkin(self.prepareCourse)

        if page == None:
            self.printer.write(u"没有找到备课首页。")
            return
        if request.getMethod() == "POST":
            cmd = self.params.safeGetStringParam("cmd")
            if cmd == "1":
                bgcolor = self.params.getStringParam("bgcolor")
                logo = self.params.getStringParam("logo")
                logoheight = self.params.getStringParam("logoheight")
                titletop = self.params.getStringParam("titletop")
                titleleft = self.params.getStringParam("titleleft")
                titledisplay = self.params.getStringParam("titledisplay")
                jstring = '{"bgcolor":"' + bgcolor + '","logo":"' + logo + '","logoheight":"' + logoheight + '","titleleft":"' + titleleft + '","titletop":"' + titletop + '","titledisplay":"' + titledisplay + '"}'
                jsObj = JSONObject.parse(jstring)
                self.page_svc.setPageCustomSkin(page, jsObj.toString())
            if cmd == "2":
                bgcolor = ""
                logo = ""
                logoheight = ""
                titletop = ""
                titleleft = ""
                titledisplay = ""
                jstring = '{"bgcolor":"' + bgcolor + '","logo":"' + logo + '","logoheight":"' + logoheight + '","titleleft":"' + titleleft + '","titletop":"' + titletop + '","titledisplay":"' + titledisplay + '"}'
                jsObj = JSONObject.parse(jstring)
                self.page_svc.setPageCustomSkin(page, jsObj.toString())

            cache = __jitar__.cacheProvider.getCache('prepareCourse')
            cache_key = "prepareCourse_page_" + str(self.prepareCourseId)
            cache.remove(cache_key)
            self.printer.write(u"自定义设置已保存。")
            return
        else:
            request.setAttribute("prepareCourse", self.prepareCourse)
            if page.customSkin != None:
                customSkin = JSONObject.parse(page.customSkin)
                color = customSkin["bgcolor"]
                if len(color) > 0 and color[0:1] == "#": color = color[1:6]
                request.setAttribute("color", color)
                request.setAttribute("customSkin", customSkin)
            else:
                customSkin = {
                    "bgcolor": "",
                    "logo": "",
                    "logoheight": "",
                    "titledisplay": "",
                    "titleleft": "",
                    "titletop": ""
                }
                request.setAttribute("customSkin", customSkin)
            return "/WEB-INF/ftl/course/manage_customskin.ftl"
Ejemplo n.º 12
0
 def execute(self):
     self.loginName = request.getAttribute("loginName")
     if self.loginName == None or self.loginName == "":
         return self.sendNotFound(self.uri)
     self.user = userService.getUserByLoginName(self.loginName)
     #print "user = "******"k")
     if k == None or k == "":
         self.addActionError(u"请输入关键字。")
         self.addActionLink(u"返回","../")
         return self.ERROR            
     
     request.setAttribute("user", self.user)
     request.setAttribute("loginUser", self.loginUser)
     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()
     list = []
     list = Command(hql).setInteger("userId", self.user.userId).open(1);
     if list == None :
         pageSkin = None
     else :
         pageSkin = list[0]
     #print "pageSkin = ", pageSkin
     if pageSkin == None or pageSkin == "": pageSkin = "skin1"
     
     # 构造页面数据,由于页面不是在数据库存在的,这里的数据是虚拟数据.
     #pages : [{id: ${page.pageId}, title: '${self.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 = JSONObject.parse(self.page.customSkin)
         request.setAttribute("customSkin", customSkin)
     # 构造widgets .
     widgets = [
                {"id": "1", "pageId":0, "columnIndex":1,"title":u"个人档案","module":"profile", "ico":"", "data":""},                   
                {"id": "2", "pageId":self.page.pageId, "columnIndex":1, "title":u"文章搜索", "module":"blog_search", "ico":"", "data":""} 
               ]
     request.setAttribute("widgets", widgets)
     request.setAttribute("widget_list", widgets)
     
     
     pagingService = __spring__.getBean("pagingService")
     pagingQuery = PagingQuery()
     pagingQuery.keyName = "ArticleId"
     pagingQuery.fetchFieldsName = "*"
     pagingQuery.orderByFieldName = "ArticleId DESC"
     pagingQuery.spName = "findPagingArticleBase"
     pagingQuery.tableName = "HtmlArticleBase"
     pagingQuery.whereClause = "userId = " + str(self.user.userId) + " And HideState = 0 And AuditState = 0 And DraftState = 0 And DelState = 0"
     if k != None and k != "":
         newKey = k.replace("%","[%]").replace("_","[_]").replace("[","[[]")
         pagingQuery.whereClause = pagingQuery.whereClause + " And Title LIKE '%" + newKey + "%'"
     
     #得到记录总数
     count = pagingService.getRowsCount(pagingQuery)
     if count % 20 == 0:
         pageCount = int(count/20)
     else:
         pageCount = int(count/20) + 1
     request.setAttribute("pageCount", pageCount)
     request.setAttribute("k", k)
     response.setContentType("text/html; charset=UTF-8")
     return "/WEB-INF/user/default/user_article_search.ftl"
Ejemplo n.º 13
0
    def execute(self):
        # 解析 uri.
        self.loginName = request.getAttribute("loginName")

        writer = response.getWriter()

        # 加载当前用户对象.
        user = user_svc.getUserByLoginName(self.loginName)
        request.setAttribute("user", user)
        #print "user = "******"loginUser", self.loginUser)

        pager = self.params.createPager()
        qry = GroupMemberQuery(
            """ g.groupName,g.groupId,g.groupTitle,g.groupIcon,gm.joinDate """)
        qry.userId = user.userId
        qry.orderType = 0
        pager.pageSize = 20
        pager.itemName = u"协作组"
        pager.itemUnit = u"个"
        pager.totalRows = qry.count()
        group_list = qry.query_map(pager)

        #print "group_list = " , group_list
        request.setAttribute("group_list", group_list)
        request.setAttribute("pager", pager)
        hql = """SELECT p.skin
             FROM Page p 
             WHERE p.name = 'index' and p.objId = :userId and p.objType = 1
             """
        pageSkin = Command(hql).setInteger("userId", 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(user)
        if self.page.customSkin != None:
            customSkin = JSONObject.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)

        response.setContentType("text/html; charset=UTF-8")
        return "/WEB-INF/user/default/user_groups.ftl"
Ejemplo n.º 14
0
    def execute(self):
        #需要添加到内容:当前用户的首页skin,当前用户的用户对象,当前用户是否登录过.
        writer = response.getWriter()

        photoStapleService = __jitar__.getPhotoStapleService()

        self.params = ParamUtil(request)
        userStapleId = self.params.safeGetIntParam("userStapleId")
        loginName = request.getAttribute("loginName")
        if (loginName == None or loginName == ''):
            writer.println(u"没有该用户。")
            return

        # 加载当前用户对象.
        user = __jitar__.userService.getUserByLoginName(loginName)
        request.setAttribute("user", user)
        if self.canVisitUser(user) == False:
            return self.ACCESS_ERROR

        # loginUser 对象来自基类 BaseAdminAction .
        request.setAttribute("loginUser", self.loginUser)

        # 创建分页对象
        pager = self.params.createPager()
        pager.setPageSize(6)
        qry = PhotoQuery(
            """ p.photoId, p.title, p.createDate, p.lastModified, p.href, p.commentCount,p.viewCount, p.userStaple, 
                           u.nickName, u.loginName, u.userIcon, stap.title as stapleTitle                                       
                            """)
        qry.userId = user.userId
        qry.isPrivateShow = None
        if userStapleId != 0:
            qry.userStapleId = userStapleId
            photoStaple = photoStapleService.findById(userStapleId)
            if photoStaple != None:
                request.setAttribute("photoStaple", photoStaple)

        #print "userStapleId = ", userStapleId
        pager.totalRows = qry.count()
        pager.itemName = u"图片"
        pager.itemUnit = u"张"
        qry.orderType = 0

        result = qry.query_map(pager)
        request.setAttribute("photo_list", result)
        request.setAttribute("pager", pager)

        hql = """SELECT new Map(p.skin as skin)
             FROM Page p 
             WHERE p.name = 'index' and p.objId = :userId and p.objType = 1
             """
        pageSkin = Command(hql).setInteger("userId", user.userId).first()

        # 构造页面数据,由于页面不是在数据库存在的,这里的数据是虚拟数据.
        #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["skin"]
        }
        request.setAttribute("page", page)
        self.page = self.getUserProfilePage(user)
        if self.page.customSkin != None:
            customSkin = JSONObject.parse(self.page.customSkin)
            request.setAttribute("customSkin", customSkin)

        # 构造widgets .
        widgets = [{
            "id": "1",
            "pageId": 0,
            "columnIndex": 1,
            "title": u"个人档案",
            "module": "profile",
            "ico": "",
            "data": ""
        }, {
            "id": "2",
            "pageId": 0,
            "columnIndex": 1,
            "title": u"相册分类",
            "module": "photo_cate",
            "ico": "",
            "data": ""
        }, {
            "id": "placerholder1",
            "pageId": 0,
            "columnIndex": 2,
            "title": "",
            "module": "placeholder",
            "ico": "",
            "data": ""
        }]

        request.setAttribute("widgets", widgets)
        request.setAttribute("widget_list", widgets)

        response.setContentType("text/html; charset=UTF-8")
        return "/WEB-INF/user/default/user_photos.ftl"
Ejemplo n.º 15
0
    def execute(self):
        self.loginName = request.getAttribute("loginName")
        #print "Hello, show_article is executed"
        if self.parseUri() == False:
            return self.sendNotFound(self.uri)

        # 得到用户并验证用户状态
        self.user = user_svc.getUserByLoginName(self.loginName)
        request.setAttribute("user", self.user)
        #print "self.user = "******"accessControlService")
            controlList = accessControlService.getAllAccessControlByUser(
                self.loginUser)
            canView = ((controlList != None)
                       or (self.article.userId == self.loginUser.userId))
        punshScore = pun_svc.getUPunishScore(
            ObjectType.OBJECT_TYPE_ARTICLE.getTypeId(), self.articleId)
        if punshScore != None:
            if punshScore.getScore() < 0:
                request.setAttribute("scoreCreateUserId",
                                     punshScore.getCreateUserId())
                request.setAttribute("scoreCreateUserName",
                                     punshScore.getCreateUserName())
                request.setAttribute("score", -1 * punshScore.getScore())
                request.setAttribute("scoreReason", punshScore.getReason())
                request.setAttribute("scoreDate", punshScore.getPunishDate())
                request.setAttribute("scoreObjId", punshScore.getObjId())
                request.setAttribute("scoreObjTitle", punshScore.getObjTitle())

        # print "访问文章: self.article =", self.article, "by", self.user
        if canView == False:
            if self.article.auditState != Article.AUDIT_STATE_OK:
                return self.sendNotFound()  # TODO: 更好的提示
            elif self.article.draftState:
                return self.sendNotFound()  # TODO: 更好的提示
            elif self.article.delState:
                return self.sendNotFound()  # TODO: 更好的提示

        # 得到此文章的 page. 当前实现使用系统缺省的
        page = self.getUserEntryPage(self.user)
        #print "page = ", page
        if page == None:
            return self.sendNotFound()
        request.setAttribute("page", page)

        self.page = self.getUserProfilePage(self.user)
        if self.page.customSkin != None:
            customSkin = JSONObject.parse(self.page.customSkin)
            request.setAttribute("customSkin", customSkin)

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

        # 获得前一篇文章, 后一篇文章
        self.get_prev_article()

        # 相关文章
        self.getSimilarArticle()

        # 获得评论星级
        self.get_comment_star()

        # 增加访问计数
        art_svc.increaseViewCount(self.article.articleId, 1)

        self.get_System_Category()
        self.get_User_Category()
        #修正计数器加1,页面显示滞后 的问题
        self.article.viewCount += 1
        request.setAttribute("article", self.article)
        return "/WEB-INF/user/default/user_entry.ftl"
Ejemplo n.º 16
0
    def execute(self):
        writer = response.getWriter()

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

        # 加载当前用户对象.
        user = __jitar__.userService.getUserByLoginName(loginName)
        request.setAttribute("user", user)
        if self.canVisitUser(user) == False:
            return self.ACCESS_ERROR

        # loginUser 对象来自基类 BaseAdminAction .
        request.setAttribute("loginUser", self.loginUser)

        # 创建分页对象
        pager = self.params.createPager()
        pager.setPageSize(20)
        qry = LeaveWordQuery(
            """ lwd.title, lwd.content, lwd.loginName, lwd.nickName, lwd.createDate, lwd.reply                             
                            """)
        qry.objId = user.userId
        qry.objType = 1

        pager.totalRows = qry.count()
        pager.itemName = u"留言"
        pager.itemUnit = u"条"
        pager.pageSize = 20

        result = qry.query_map(pager)
        request.setAttribute("user_leaveword_list", result)
        request.setAttribute("pager", pager)

        hql = """SELECT new Map(p.skin as skin)
             FROM Page p 
             WHERE p.name = 'index' and p.objId = :userId and p.objType = 1
             """
        pageSkin = Command(hql).setInteger("userId", user.userId).first()

        # 构造页面数据,由于页面不是在数据库存在的,这里的数据是虚拟数据.
        #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["skin"]
        }
        request.setAttribute("page", page)
        self.page = self.getUserProfilePage(user)
        if self.page.customSkin != None:
            customSkin = JSONObject.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)

        response.setContentType("text/html; charset=UTF-8")
        return "/WEB-INF/user/default/user_leaveword_list.ftl"