Esempio n. 1
0
def show(request,uid=-1,aid=-1,*arg,**kwarg):
    uid=int(uid)
    userInfos=common.Users(request,uid)

    guestBlog=userInfos["guestblog"]

    myModules=guestBlog.modules.split(",")
    moduleParams={}
    for myModule in myModules:
        moduleParams.setdefault(myModule,{"uid":uid})

    moduleList=modules.GetModuleList(moduleParams)
    

    articleInfo=Article.objects.get(id=aid)

    

    if request.POST.has_key('ok'):
        username = utility.GetPostData(request,'username')
        content = utility.GetPostData(request,'content')

        comment=Comment()
        comment.article=articleInfo
        comment.content=content
        comment.user_id=userInfos["currentuser"].id
        comment.username=username
        comment.createtime=datetime.datetime.now()
        comment.save()

        articleInfo.comments+=1

        guestBlog=userInfos["guestblog"]
        guestBlog.comments+=1
        guestBlog.save()

    commentList=Comment.objects.filter(article_id=aid)

    #更新文章浏览量
    articleInfo.views+=1
    articleInfo.save()

    return utility.my_render_to_response(request,"Skins/"+guestBlog.template+"/show.html",locals())
Esempio n. 2
0
    def PostContext(self, **kwargs):
        pid= utility.ToInt(utility.GetDicData(kwargs,"pid"),0)

        if self.HasPostData("ok") and pid>0:
            pageInfo=self.GetPage(pid)
            if pageInfo is None:
                return locals()

            username = self.GetPostData('username')
            email = self.GetPostData('email')
            title = self.GetPostData('title')
            content = self.GetPostData('content')
            
            commentInfo=Comment()
            commentInfo.obj_id=pid
            commentInfo.obj_type="page"
            commentInfo.title=title
            commentInfo.content=content
            commentInfo.createtime=datetime.datetime.now()
            commentInfo.user_id=0
            commentInfo.username=username
            commentInfo.email=email

            commentInfo.save()

            pageInfo.comments+=1
            pageInfo.save()    
Esempio n. 3
0
    def PostContext(self, **kwargs):
        pid = utility.ToInt(utility.GetDicData(kwargs, "pid"), 0)

        if self.HasPostData("ok") and pid > 0:
            pageInfo = self.GetPage(pid)
            if pageInfo is None:
                return locals()

            username = self.GetPostData('username')
            email = self.GetPostData('email')
            title = self.GetPostData('title')
            content = self.GetPostData('content')

            commentInfo = Comment()
            commentInfo.obj_id = pid
            commentInfo.obj_type = "page"
            commentInfo.title = title
            commentInfo.content = content
            commentInfo.createtime = datetime.datetime.now()
            commentInfo.user_id = 0
            commentInfo.username = username
            commentInfo.email = email

            commentInfo.save()

            pageInfo.comments += 1
            pageInfo.save()
Esempio n. 4
0
def show(request, uid=-1, aid=-1, *arg, **kwarg):
    uid = int(uid)
    userInfos = common.Users(request, uid)
    print userInfos
    guestBlog = userInfos["guestblog"]

    myModules = guestBlog.modules.split(",")
    moduleParams = {}
    for myModule in myModules:
        moduleParams.setdefault(myModule, {"uid": uid})
    moduleList = modules.GetModuleList(moduleParams)

    articleInfo = Article.objects.get(id=aid)

    if request.POST.has_key('ok'):
        username = utility.GetPostData(request, 'username')
        content = utility.GetPostData(request, 'content')

        if len(content) > 200:
            return render(request, 'message.html', locals())

        comment = Comment()
        comment.article = articleInfo
        comment.content = content
        comment.user_id = userInfos["currentuser"].id
        comment.username = username
        comment.createtime = datetime.datetime.now()
        comment.save()

        articleInfo.comments += 1

        guestBlog = userInfos["guestblog"]
        guestBlog.comments += 1
        guestBlog.save()
    # 获取评论列表
    commentList = Comment.objects.filter(article_id=aid)

    # 更新文章浏览量
    articleInfo.views += 1
    articleInfo.save()

    if userInfos["currentuser"]:
        try:
            greatInfo = Great.objects.filter(
                article_id=aid, user_id=userInfos["currentuser"].id)
        except:
            greatInfo = None
        #点赞功能
        if request.POST.has_key('support'):
            greatInf = Great()
            greatInf.great = 1
            greatInf.user_id = userInfos["currentuser"].id
            greatInf.article_id = aid
            greatInf.save()
            articleInfo.goods += 1
            articleInfo.save()

            #            print '/%d/show/%d' % (request.user.id,aid)
            text = '/%d/show/%d' % (request.user.id, int(aid))
            return HttpResponseRedirect(text)

    #转发

    return utility.my_render_to_response(
        request, "Skins/" + guestBlog.template + "/show.html", locals())