Ejemplo n.º 1
0
def focus(request, uid):
    uid = int(uid)
    #print uid
    userInfos = common.Users(request, uid)
    #print userInfos
    #print uid
    print userInfos["currentuser"].id
    #得到关注列表
    focusList = common.Relations(request, uid)
    starProfile = focusList["starList"]
    for starInfo in starProfile:
        print starInfo.nickname
# guestBlog=userInfos["guestblog"]
    focusnum = Relation.objects.filter(fans_id=uid).count()
    fansnum = Relation.objects.filter(star_id=uid).count()

    myModules = ["profile", "hotarticlelist", "newarticlelist"]
    #myModules = ["profile"]
    moduleParams = {}
    for myModule in myModules:
        moduleParams.setdefault(myModule, {})
    moduleList = modules.GetModuleList(moduleParams)

    # 关注功能
    if userInfos["currentuser"]:
        print userInfos["currentuser"].id
        print uid
        try:
            focusInfo = Relation.objects.filter(
                star_id=uid, fans_id=userInfos["currentuser"].id)
        except:
            focusInfo = None

    if request.POST.has_key('focus'):
        relationInfo = Relation()
        relationInfo.star_id = uid
        relationInfo.fans_id = userInfos["currentuser"].id
        relationInfo.save()
        text = '/%d' % (uid)
        return HttpResponseRedirect(text)

    #取消关注
    if request.POST.has_key('nofocus'):
        Relation.objects.filter(star_id=uid,
                                fans_id=userInfos["currentuser"].id).delete()
        text = '/%d' % (uid)
        return HttpResponseRedirect(text)
    #更新用户文章总数
    #guestBlog.todayviews+=1
    #guestBlog.totalviews+=1
    #guestBlog.save()
    #articleList=Article.objects.order_by("-createtime").filter(user_id=uid).filter(status=1)
    #print articleList

    return utility.my_render_to_response(request, "focusList.html", locals())
Ejemplo n.º 2
0
def home(request, uid):
    uid = int(uid)
    print uid
    userInfos = common.Users(request, uid)
    print userInfos
    print uid
    print userInfos["currentuser"].id
    guestBlog = userInfos["guestblog"]
    focusnum = Relation.objects.filter(fans_id=uid).count()
    fansnum = Relation.objects.filter(star_id=uid).count()

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

    moduleList = modules.GetModuleList(moduleParams)
    # 关注功能
    if userInfos["currentuser"]:
        print userInfos["currentuser"].id
        print uid
        try:
            focusInfo = Relation.objects.filter(
                star_id=uid, fans_id=userInfos["currentuser"].id)
        except:
            focusInfo = None

    if request.POST.has_key('focus'):
        relationInfo = Relation()
        relationInfo.star_id = uid
        relationInfo.fans_id = userInfos["currentuser"].id
        relationInfo.save()
        text = '/%d' % (uid)
        return HttpResponseRedirect(text)

    #取消关注
    if request.POST.has_key('nofocus'):
        Relation.objects.filter(star_id=uid,
                                fans_id=userInfos["currentuser"].id).delete()
        text = '/%d' % (uid)
        return HttpResponseRedirect(text)
    #更新用户文章总数
    guestBlog.todayviews += 1
    guestBlog.totalviews += 1
    guestBlog.save()

    articleList = Article.objects.order_by("-createtime").filter(
        user_id=uid).filter(status=1)
    print articleList

    return utility.my_render_to_response(
        request, "Skins/" + guestBlog.template + "/home.html", locals())
Ejemplo n.º 3
0
def channel(request, cid=-1):
    userInfos = common.Users(request, 1)

    myModules = ["newuserlist", "hotarticlelist", "newarticlelist"]
    moduleParams = {}
    for myModule in myModules:
        moduleParams.setdefault(myModule, {})

    moduleList = modules.GetModuleList(moduleParams)

    articleList = Article.objects.order_by("-createtime").filter(
        channel1_id=cid)

    channelList = Channel.objects.all()
    currentChannel = Channel.objects.get(id=cid)
    childrenChannel = Channel.objects.filter(parent_id=cid)

    return utility.my_render_to_response(request, "channel.html", locals())
Ejemplo n.º 4
0
def tags(request, uid, cid):
    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)

    articleList = Article.objects.order_by("-createtime").filter(
        user_id=uid).filter(category_id=cid).filter(status=1)

    return utility.my_render_to_response(
        request, "Skins/" + guestBlog.template + "/home.html", locals())
Ejemplo n.º 5
0
def index(request):
    userInfos = common.Users(request, -1)

    myModules = ["newuserlist", "hotarticlelist", "newarticlelist"]
    moduleParams = {}
    for myModule in myModules:
        moduleParams.setdefault(myModule, {})

    moduleList = modules.GetModuleList(moduleParams)

    channelIds = {1, 2, 3}
    #channelIds.add()
    articleList = {}
    for channelId in channelIds:
        channel = Channel.objects.get(id=channelId)
        if channel:
            retValue = Article.objects.order_by("-createtime").filter(
                channel1_id=channelId)
            articleList.setdefault(channel, retValue)

    return utility.my_render_to_response(request, "index.html", locals())
Ejemplo n.º 6
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())