Example #1
0
def login(request):
    if utility.HasPostData(request, "ok"):
        username = utility.GetPostData(request, "username")
        password = utility.GetPostData(request, "password")

        user = auth.authenticate(username=username, password=password)
        if user is not None:
            try:
                # userProfile=user.get_profile()
                currentUserProfile = UserProfile.objects.get(user=user)
            except:
                common.createUserProfile(user)
            try:
                blog = Blog.objects.get(user_id=user.id)
            except:
                common.createBlog(user)

            if user.is_active:
                auth.login(request, user)
                return HttpResponseRedirect("/")
            else:
                return HttpResponseRedirect("")
        else:
            return HttpResponseRedirect("")
    else:
        return utility.my_render_to_response(request, "login.html", locals())
Example #2
0
def home(request,uid):
	uid=int(uid)
	userInfos=common.Users(request,uid)
	
	guestBlog=userInfos["guestblog"]
	try:
		myModules=guestBlog.modules.split(",")
	except:
		myModules=''.split(",")

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

	moduleList=modules.GetModuleList(moduleParams)

	template = 'default'
	if guestBlog:
		#更新用户文章总数
		guestBlog.todayviews+=1
		guestBlog.totalviews+=1
		guestBlog.save()
		template = guestBlog.template

	articleList=Article.objects.order_by("-createtime").filter(user_id=uid).filter(status=1)
	
	return utility.my_render_to_response(request,"Skins/"+ template +"/home.html",locals())
Example #3
0
def index(request, uid=-1):
    userInfos = common.Users(request, -1)
    userProfile = userInfos[2]

    if utility.HasPostData(request, "ok"):

        userProfile.blog_domain = utility.GetPostData(request, "blog_domain")
        userProfile.blog_title = utility.GetPostData(request, "blog_title")
        userProfile.blog_keywords = utility.GetPostData(
            request, "blog_keywords")
        userProfile.blog_about = utility.GetPostData(request, "blog_about")
        userProfile.blog_announcement = utility.GetPostData(
            request, "blog_announcement")
        userProfile.blog_template = utility.GetPostData(
            request, "blog_template")
        userProfile.blog_css = utility.GetPostData(request, "blog_css")
        userProfile.blog_headhtml = utility.GetPostData(
            request, "blog_headhtml")
        userProfile.blog_footerhtml = utility.GetPostData(
            request, "blog_footerhtml")

        #userProfile.createtime=datetime.datetime.now()
        #userProfile.stat_articles=0
        #userProfile.stat_views=0
        #userProfile.stat_comments=0

        userProfile.save()

        return HttpResponseRedirect('/')
    else:
        return utility.my_render_to_response(request, "pub/profile.html",
                                             locals())
Example #4
0
def login(request):
    if utility.HasPostData(request,"ok"):
        username=utility.GetPostData(request,"username")
        password=utility.GetPostData(request,"password")

        user=auth.authenticate(username=username,password=password)
        if user is not None:
            try:
                userProfile=UserProfile.objects.get(user_id=user.id)
            except:
                common.createUserProfile(user)
            try:
                blog=Blog.objects.get(user_id=user.id)
            except:
                common.createBlog(user)

            if user.is_active:
                auth.login(request,user)
                return HttpResponseRedirect('/')
            else:
                return HttpResponseRedirect('')
        else:
            return HttpResponseRedirect('')
    else:
        return utility.my_render_to_response(request,"login.html",locals())
Example #5
0
def add(request, *arg, **kwarg):
    uid = int(-1)
    userInfos = common.Users(request, uid)

    categoryList = common.categoryList(userInfos[1].id)

    if request.POST.has_key('ok'):
        cateId = int(utility.GetPostData(request, 'category'))
        category = Category.objects.get(
            id=utility.GetPostData(request, 'category'))

        title = utility.GetPostData(request, 'title')
        pic = utility.GetPostData(request, 'pic')
        tags = utility.GetPostData(request, 'tags')
        summary = utility.GetPostData(request, 'summary')
        content = utility.GetPostData(request, 'content')
        status = int(utility.GetPostData(request, 'status'))

        if summary == "":
            tempContent = utility.RemoveTags(content)
            summary = tempContent[0:200] if len(
                tempContent) > 200 else tempContent
        else:
            summary = utility.RemoveTags(summary)

        articleInfo = Article(category=category)
        articleInfo.createTime = datetime.datetime.now()
        if category.id != 1:
            category.articles += 1
            category.save()

        articleInfo.category = category
        articleInfo.title = title
        articleInfo.pic = pic
        articleInfo.tags = tags
        articleInfo.summary = summary
        articleInfo.content = content
        articleInfo.createTime = datetime.datetime.now()
        articleInfo.views = 0
        articleInfo.comments = 0
        articleInfo.goods = 0
        articleInfo.bads = 0
        articleInfo.status = status
        articleInfo.user_id = request.user.id
        articleInfo.user_name = request.user.username

        articleInfo.save()

        userProfile = userInfos[2]
        userProfile.stat_articles += 1
        userProfile.save()

        return HttpResponseRedirect('/%d/' % request.user.id)
    else:

        articleInfo = Article()

        return utility.my_render_to_response(request, "pub/articleedit.html",
                                             locals())
Example #6
0
def listdraft(request, uid):
    uid = int(uid)
    userInfos = common.Users(request, uid)
    categoryList = common.categoryList(userInfos[1].id)

    articleList = Article.objects.order_by("-createTime").filter(
        user_id=userInfos[1].id).filter(status=0)
    return utility.my_render_to_response(request, "pub/articlelist.html",
                                         locals())
Example #7
0
def fork(request, uid=-1):

    if utility.HasPostData(request, "ok"):
        print 123456789

        return HttpResponseRedirect('/')
    else:
        return utility.my_render_to_response(request, "modules/profile.html",
                                             locals())
Example #8
0
def listdraft(request,uid):
	uid=int(uid)
	userInfos=common.Users(request,uid)
	currentUser=userInfos["currentuser"]

	categoryList=common.categoryList(currentUser.id)

	articleList=Article.objects.order_by("-createtime").filter(user_id=currentUser.id).filter(status=0)
	return utility.my_render_to_response(request,"pub/articlelist.html",locals())
Example #9
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())
Example #10
0
def index(request,uid,cid=-1):
    uid=int(-1)
    userInfos=common.Users(request,uid)
    currentUser=userInfos["currentuser"]
   
    categoryList=common.categoryList(currentUser.id)
    
    if request.POST.has_key('ok'):
        return add(request)
    else:
        return utility.my_render_to_response(request,"pub/category.html",locals())
Example #11
0
def index(request,uid,cid=-1):
    uid=int(-1)
    userInfos=common.Users(request,uid)
    currentUser=userInfos["currentuser"]
   
    categoryList=common.categoryList(currentUser.id)
    
    if request.POST.has_key('ok'):
        return add(request)
    else:
        return utility.my_render_to_response(request,"pub/category.html",locals())
Example #12
0
def security(request,uid=-1):
    userInfos=common.Users(request,-1)
    userProfile=userInfos[2]

    if utility.HasPostData(request,"ok"):
        userProfile.avatar=utility.SaveFile(request.FILES['avatar'],'avatar/')
      
        userProfile.save()

        return HttpResponseRedirect('/')
    else:
        return utility.my_render_to_response(request,"pub/profile/security.html",locals())
Example #13
0
def list(request, uid):
    uid = int(uid)
    userInfos = common.Users(request, uid)
    currentUser = userInfos["currentuser"]

    categoryList = common.categoryList(currentUser.id)

    articleList = Article.objects.order_by("-createtime").filter(
        user_id=currentUser.id)

    return utility.my_render_to_response(request, "pub/articlelist.html",
                                         locals())
Example #14
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())
Example #15
0
def index(request):
    userInfos = common.Users(request, -1)

    viewTopArticleList = common.viewTopArticleList()
    commentTopArticleList = common.commentTopArticleList()
    newTopArticleList = common.newTopArticleList()
    newTopUserList = common.newTopUserList()

    categoryList = common.categoryList()

    articleList = Article.objects.order_by("-createTime").all()

    return utility.my_render_to_response(request, "index.html", locals())
Example #16
0
def security(request, uid=-1):
    userInfos = common.Users(request, -1)
    userProfile = userInfos[2]

    if utility.HasPostData(request, "ok"):
        userProfile.avatar = utility.SaveFile(request.FILES['avatar'],
                                              'avatar/')

        userProfile.save()

        return HttpResponseRedirect('/')
    else:
        return utility.my_render_to_response(request,
                                             "pub/profile/security.html",
                                             locals())
Example #17
0
def register(request):
    if utility.HasPostData(request, "ok"):
        username = utility.GetPostData(request, "username")
        password = utility.GetPostData(request, "password")
        email = utility.GetPostData(request, "email")
        user = User.objects.create_user(username, email, password)
        user.first_name = username
        user.save()

        createUserProfile(user)

        return HttpResponseRedirect('/')
    else:
        return utility.my_render_to_response(request, "register.html",
                                             locals())
Example #18
0
def show(request,uid=-1,aid=-1,*arg,**kwarg):
	uid=int(uid)
	userInfos=common.Users(request,uid)

	guestBlog=userInfos["guestblog"]
	try:
		myModules=guestBlog.modules.split(",")
	except:
		myModules = ''.split(',')
	moduleParams={}
	for myModule in myModules:
		moduleParams.setdefault(myModule,{"uid":uid})

	moduleList=modules.GetModuleList(moduleParams)
	

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

	

	template = 'default'
	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

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

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

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

	return utility.my_render_to_response(request,"Skins/"+template+"/show.html",locals())
Example #19
0
def register(request):
    if utility.HasPostData(request,"ok"):
        username=utility.GetPostData(request,"username")
        password=utility.GetPostData(request,"password")
        email=utility.GetPostData(request,"email")

        user=User.objects.create_user(username,email,password)
        user.first_name=username
        user.save()

        common.createUserProfile(user)
        common.createBlog(user)

        return HttpResponseRedirect('/')
    else:
        return utility.my_render_to_response(request,"register.html",locals())
Example #20
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())
Example #21
0
def tags(request, uid, cid):
    uid = int(uid)
    userInfos = common.Users(request, uid)
    templateName = templateName = userInfos[5].blog_template

    viewTopArticleList = common.viewTopArticleList(uid)
    commentTopArticleList = common.commentTopArticleList(uid)
    newTopArticleList = common.newTopArticleList(uid)
    newTopUserList = common.newTopUserList()

    categoryList = common.categoryList(uid)

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

    return utility.my_render_to_response(request, templateName + "/home.html",
                                         locals())
Example #22
0
def base(request,uid=-1):
    userInfos=common.Users(request,-1)
    currentUserProfile=userInfos["currentuserprofile"]

    if utility.HasPostData(request,"ok"):
        currentUserProfile.nickname=utility.GetPostData(request,"nickname")
        currentUserProfile.realname=utility.GetPostData(request,"realname")
        currentUserProfile.gender=utility.GetPostData(request,"gender")
        currentUserProfile.birthday=utility.GetPostData(request,"birthday")
        currentUserProfile.birthcity=utility.GetPostData(request,"birthcity")
        currentUserProfile.residecity=utility.GetPostData(request,"residecity")
      
        currentUserProfile.save()

        return HttpResponseRedirect('/')
    else:
        return utility.my_render_to_response(request,"pub/profile/base.html",locals())
Example #23
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())
Example #24
0
def avatar(request,uid=-1):
    userInfos=common.Users(request,-1)
    currentUserProfile=userInfos["currentuserprofile"]
    #000/00/01
    if utility.HasPostData(request,"ok"):
        avatarPath=("%d" %currentUserProfile.user_id).rjust(7,"0")
        dir1=avatarPath[0:3]
        dir2=avatarPath[3:5]
        fileName=avatarPath[5:7]
        path="%s/%s/%s/" %("avatar",dir1,dir2)

        currentUserProfile.avatar=utility.SaveFile(request.FILES['avatar'],path,fileName)
      
        currentUserProfile.save()

        return HttpResponseRedirect('/')
    else:
        return utility.my_render_to_response(request,"pub/profile/avatar.html",locals())
Example #25
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())
Example #26
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())
Example #27
0
def blog(request, uid=-1):
    userInfos = common.Users(request, -1)
    currentBlog = userInfos["currentblog"]

    allModules = {}
    for key, value in modules.moduleList.items():
        allModules.setdefault(key, value["name"])

    tempModules = currentBlog.modules.split(",")
    myModules = {}
    for tempModule in tempModules:
        moduleName = modules.GetModuleName(tempModule)
        if moduleName:
            myModules.setdefault(tempModule, moduleName)

    if utility.HasPostData(request, "ok"):
        currentBlog.domain = utility.GetPostData(request, "domain")
        currentBlog.title = utility.GetPostData(request, "title")
        currentBlog.description = utility.GetPostData(request, "description")
        currentBlog.keywords = utility.GetPostData(request, "keywords")
        currentBlog.about = utility.GetPostData(request, "about")
        currentBlog.announcement = utility.GetPostData(request, "announcement")

        tempModules = utility.GetPostData(request, "modules").split(",")
        retModules = ""
        dot = ""
        for key in tempModules:
            if modules.moduleList.has_key(key):
                retModules += dot + key
                dot = ","

        currentBlog.modules = retModules
        currentBlog.template = utility.GetPostData(request, "template")
        currentBlog.css = utility.GetPostData(request, "css")
        currentBlog.headhtml = utility.GetPostData(request, "headhtml")
        currentBlog.footerhtml = utility.GetPostData(request, "footerhtml")

        currentBlog.save()

        return HttpResponseRedirect('/')
    else:
        return utility.my_render_to_response(request, "pub/config/blog.html",
                                             locals())
Example #28
0
def blog(request,uid=-1):
    userInfos=common.Users(request,-1)
    currentBlog=userInfos["currentblog"]

    allModules={}
    for key,value in modules.moduleList.items():
        allModules.setdefault(key,value["name"])

    tempModules=currentBlog.modules.split(",")
    myModules={}
    for tempModule in tempModules:
        moduleName=modules.GetModuleName(tempModule)
        if moduleName:
            myModules.setdefault(tempModule,moduleName)


    if utility.HasPostData(request,"ok"):
        currentBlog.domain=utility.GetPostData(request,"domain")
        currentBlog.title=utility.GetPostData(request,"title")
        currentBlog.description=utility.GetPostData(request,"description")
        currentBlog.keywords=utility.GetPostData(request,"keywords")
        currentBlog.about=utility.GetPostData(request,"about")
        currentBlog.announcement=utility.GetPostData(request,"announcement")

        tempModules=utility.GetPostData(request,"modules").split(",")
        retModules=""
        dot=""
        for key in tempModules:
            if modules.moduleList.has_key(key):
                retModules+=dot+key
                dot=","

        currentBlog.modules=retModules
        currentBlog.template=utility.GetPostData(request,"template")
        currentBlog.css=utility.GetPostData(request,"css")
        currentBlog.headhtml=utility.GetPostData(request,"headhtml")
        currentBlog.footerhtml=utility.GetPostData(request,"footerhtml")
  
        currentBlog.save()

        return HttpResponseRedirect('/')
    else:
        return utility.my_render_to_response(request,"pub/config/blog.html",locals())
Example #29
0
def info(request,uid=-1):
    userInfos=common.Users(request,-1)
    currentUserProfile=userInfos["currentuserprofile"]

    if utility.HasPostData(request,"ok"):
        currentUserProfile.affectivestatus=utility.GetPostData(request,"affectivestatus")
        currentUserProfile.lookingfor=utility.GetPostData(request,"lookingfor")
        currentUserProfile.bloodtype=utility.GetPostData(request,"bloodtype")
        currentUserProfile.site=utility.GetPostData(request,"site")
        currentUserProfile.bio=utility.GetPostData(request,"bio")
        currentUserProfile.interest=utility.GetPostData(request,"interest")
        currentUserProfile.sightml=utility.GetPostData(request,"sightml")
        currentUserProfile.timeoffset=utility.GetPostData(request,"timeoffset")

        currentUserProfile.save()

        return HttpResponseRedirect('/')
    else:
        return utility.my_render_to_response(request,"pub/profile/info.html",locals())
Example #30
0
def edit(request,uid,cid):
    uid=int(-1)
    userInfos=common.Users(request,uid)
    currentUser=userInfos["currentuser"]

    name=utility.GetPostData(request,"name")
    sortnum=utility.GetPostData(request,"sortnum")

    if request.POST.has_key('ok'):
        categoryInfo=Category.objects.get(id=cid)
        categoryInfo.name=name
        categoryInfo.sortnum=sortnum
        categoryInfo.save()

        return HttpResponseRedirect(categoryroot %currentUser.id)

    else:
        categoryInfo=Category.objects.get(id=cid)
        return utility.my_render_to_response(request,"pub/category.html",locals())
Example #31
0
def contact(request,uid=-1):
    userInfos=common.Users(request,-1)
    currentUserProfile=userInfos["currentuserprofile"]

    if utility.HasPostData(request,"ok"):
        currentUserProfile.qq=utility.GetPostData(request,"qq")
        currentUserProfile.msn=utility.GetPostData(request,"msn")
        currentUserProfile.taobao=utility.GetPostData(request,"taobao")
        currentUserProfile.email=utility.GetPostData(request,"email")
        currentUserProfile.phone=utility.GetPostData(request,"phone")
        currentUserProfile.mobile=utility.GetPostData(request,"mobile")
        currentUserProfile.address=utility.GetPostData(request,"address")
        currentUserProfile.zipcode=utility.GetPostData(request,"zipcode")

        currentUserProfile.save()

        return HttpResponseRedirect('/')
    else:
        return utility.my_render_to_response(request,"pub/profile/contact.html",locals())
Example #32
0
def edit(request,uid,cid):
    uid=int(-1)
    userInfos=common.Users(request,uid)
    currentUser=userInfos["currentuser"]

    name=utility.GetPostData(request,"name")
    sortnum=utility.GetPostData(request,"sortnum")

    if request.POST.has_key('ok'):
        categoryInfo=Category.objects.get(id=cid)
        categoryInfo.name=name
        categoryInfo.sortnum=sortnum
        categoryInfo.save()

        return HttpResponseRedirect(categoryroot %currentUser.id)

    else:
        categoryInfo=Category.objects.get(id=cid)
        return utility.my_render_to_response(request,"pub/category.html",locals())
Example #33
0
def base(request, uid=-1):
    userInfos = common.Users(request, -1)
    currentUserProfile = userInfos["currentuserprofile"]

    if utility.HasPostData(request, "ok"):
        currentUserProfile.nickname = utility.GetPostData(request, "nickname")
        currentUserProfile.realname = utility.GetPostData(request, "realname")
        currentUserProfile.gender = utility.GetPostData(request, "gender")
        currentUserProfile.birthday = utility.GetPostData(request, "birthday")
        currentUserProfile.birthcity = utility.GetPostData(
            request, "birthcity")
        currentUserProfile.residecity = utility.GetPostData(
            request, "residecity")

        currentUserProfile.save()

        return HttpResponseRedirect('/')
    else:
        return utility.my_render_to_response(request, "pub/profile/base.html",
                                             locals())
Example #34
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())
Example #35
0
def contact(request, uid=-1):
    userInfos = common.Users(request, -1)
    currentUserProfile = userInfos["currentuserprofile"]

    if utility.HasPostData(request, "ok"):
        currentUserProfile.qq = utility.GetPostData(request, "qq")
        currentUserProfile.msn = utility.GetPostData(request, "msn")
        currentUserProfile.taobao = utility.GetPostData(request, "taobao")
        currentUserProfile.email = utility.GetPostData(request, "email")
        currentUserProfile.phone = utility.GetPostData(request, "phone")
        currentUserProfile.mobile = utility.GetPostData(request, "mobile")
        currentUserProfile.address = utility.GetPostData(request, "address")
        currentUserProfile.zipcode = utility.GetPostData(request, "zipcode")

        currentUserProfile.save()

        return HttpResponseRedirect('/')
    else:
        return utility.my_render_to_response(request,
                                             "pub/profile/contact.html",
                                             locals())
Example #36
0
def avatar(request, uid=-1):
    userInfos = common.Users(request, -1)
    currentUserProfile = userInfos["currentuserprofile"]
    #000/00/01
    if utility.HasPostData(request, "okkk"):
        avatarPath = ("%d" % currentUserProfile.user_id).rjust(7, "0")
        dir1 = avatarPath[0:3]
        dir2 = avatarPath[3:5]
        fileName = avatarPath[5:7]
        path = "%s/%s/%s/" % ("avatar", dir1, dir2)

        currentUserProfile.avatar = utility.SaveFile(request.FILES['avatar'],
                                                     path, fileName)

        currentUserProfile.save()

        return HttpResponseRedirect('/')
    else:
        return utility.my_render_to_response(request,
                                             "pub/profile/avatar.html",
                                             locals())
Example #37
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())
Example #38
0
def show(request, uid=-1, aid=-1, *arg, **kwarg):
    uid = int(uid)
    userInfos = common.Users(request, uid)

    templateName = templateName = userInfos[5].blog_template

    viewTopArticleList = common.viewTopArticleList(uid)
    commentTopArticleList = common.commentTopArticleList(uid)
    newTopArticleList = common.newTopArticleList(uid)
    newTopUserList = common.newTopUserList()

    categoryList = common.categoryList(uid)

    articleInfo = Article.objects.get(id=aid)
    title = articleInfo.title
    content = articleInfo.content
    articleInfo.views += 1
    if not articleInfo.createTime:
        articleInfo.createTime = datetime.datetime.now()

    articleInfo.save()

    return utility.my_render_to_response(request, templateName + "/show.html",
                                         locals())
Example #39
0
def info(request, uid=-1):
    userInfos = common.Users(request, -1)
    currentUserProfile = userInfos["currentuserprofile"]

    if utility.HasPostData(request, "ok"):
        currentUserProfile.affectivestatus = utility.GetPostData(
            request, "affectivestatus")
        currentUserProfile.lookingfor = utility.GetPostData(
            request, "lookingfor")
        currentUserProfile.bloodtype = utility.GetPostData(
            request, "bloodtype")
        currentUserProfile.site = utility.GetPostData(request, "site")
        currentUserProfile.bio = utility.GetPostData(request, "bio")
        currentUserProfile.interest = utility.GetPostData(request, "interest")
        currentUserProfile.sightml = utility.GetPostData(request, "sightml")
        currentUserProfile.timeoffset = utility.GetPostData(
            request, "timeoffset")

        currentUserProfile.save()

        return HttpResponseRedirect('/')
    else:
        return utility.my_render_to_response(request, "pub/profile/info.html",
                                             locals())
Example #40
0
def test(request):
    return utility.my_render_to_response(request, "test.html", locals())
Example #41
0
def edit(request,uid,aid):
	uid=int(uid)
	userInfos=common.Users(request,uid)
	currentUser=userInfos["currentuser"]

	categoryList=common.categoryList(currentUser.id)
	channelList=Channel.objects.all()

	articleInfo=Article.objects.get(id=aid)
	oldCategory=articleInfo.category
	oldStatus=articleInfo.status

	if request.POST.has_key('ok'):
		channel1Id=int(utility.GetPostData(request,'channel1',0))
		channel2Id=int(utility.GetPostData(request,'channel2',0))
		cateId=int(utility.GetPostData(request,'category'))
		category=Category.objects.get(id=utility.GetPostData(request,'category'))

		title = utility.GetPostData(request,'title')
		pic = utility.GetPostData(request,'pic')
		tags=utility.GetPostData(request,'tags')
		summary=utility.GetPostData(request,'summary')
		content = utility.GetPostData(request,'content')
		status = utility.GetPostData(request,'status')

		ishome=utility.GetPostData(request,'ishome')
		isrecommend = utility.GetPostData(request,'isrecommend')
		istop = utility.GetPostData(request,'istop')
		isoriginal=utility.GetPostData(request,'isoriginal')
		cancomment = utility.GetPostData(request,'cancomment')
		password = utility.GetPostData(request,'password')

		if summary=="":
			tempContent=utility.RemoveTags(content)
			summary=tempContent[0:200] if len(tempContent)>200 else tempContent
		else:
			summary=utility.RemoveTags(summary)

		articleInfo.channel1_id=channel1Id
		articleInfo.channel2_id=channel2Id
		articleInfo.category=category
		articleInfo.title = title
		articleInfo.pic=pic
		articleInfo.tags=tags
		articleInfo.summary=summary
		articleInfo.content = content
		#articleInfo.createtime=datetime.datetime.now()
		#articleInfo.views=0
		#articleInfo.comments=0
		#articleInfo.goods=0
		#articleInfo.bads=0
		articleInfo.status=1 if status else 0
		#articleInfo.user_id=request.user.id
		#articleInfo.username=request.user.username

		articleInfo.ishome=1 if ishome else 0
		articleInfo.isrecommend=1 if isrecommend else 0
		articleInfo.istop=1 if istop else 0
		articleInfo.isoriginal=1 if isoriginal else 0
		articleInfo.cancomment=1 if cancomment else 0
		articleInfo.password=password

		if oldCategory != category:
			#不是未分类,并且已经发布
			if category.id !=1 and status:
				category.articles+=1
				category.save()
			#不是未分类,并且已经是草稿
			if oldCategory.id!=1 and oldStatus:
				oldCategory.articles=oldCategory.articles-1 if oldCategory.articles>1 else 0
				oldCategory.save()
		else:
			if not status:
				category.articles-=1
				category.save()

		articleInfo.save()

		return HttpResponseRedirect('/%d/' %request.user.id)
	else:
		return utility.my_render_to_response(request,"pub/articleedit.html",locals())
Example #42
0
def add(request,*arg,**kwarg):
	uid=int(-1)
	userInfos=common.Users(request,uid)
	currentUser=userInfos["currentuser"]

	categoryList=common.categoryList(currentUser.id)
	channelList=Channel.objects.all()

	if request.POST.has_key('ok'):
		channel1Id=int(utility.GetPostData(request,'channel1',0))
		channel2Id=int(utility.GetPostData(request,'channel1',0))
		cateId=int(utility.GetPostData(request,'category'))
		category=Category.objects.get(id=utility.GetPostData(request,'category'))
		
		title = utility.GetPostData(request,'title')
		pic = utility.GetPostData(request,'pic')
		tags=utility.GetPostData(request,'tags')
		summary=utility.GetPostData(request,'summary')
		content = utility.GetPostData(request,'content')
		status = utility.GetPostData(request,'status')
		
		ishome=utility.GetPostData(request,'ishome')
		isrecommend = utility.GetPostData(request,'isrecommend')
		istop = utility.GetPostData(request,'istop')
		isoriginal=utility.GetPostData(request,'isoriginal')
		cancomment = utility.GetPostData(request,'cancomment')
		password = utility.GetPostData(request,'password')

		if summary=="":
			tempContent=utility.RemoveTags(content)
			summary=tempContent[0:200] if len(tempContent)>200 else tempContent
		else:
			summary=utility.RemoveTags(summary)

		articleInfo=Article(category=category)

		articleInfo.channel1_id=channel1Id
		articleInfo.channel2_id=channel2Id
		articleInfo.category=category
		articleInfo.title = title
		articleInfo.pic=pic
		articleInfo.tags=tags
		articleInfo.summary=summary
		articleInfo.content = content
		articleInfo.createtime=datetime.datetime.now()
		articleInfo.views=0
		articleInfo.comments=0
		articleInfo.goods=0
		articleInfo.bads=0
		articleInfo.status=1 if status else 0
		articleInfo.user_id=currentUser.id
		articleInfo.username=currentUser.username

		articleInfo.ishome=1 if ishome else 0
		articleInfo.isrecommend=1 if isrecommend else 0
		articleInfo.istop=1 if istop else 0
		articleInfo.isoriginal=1 if isoriginal else 0
		articleInfo.cancomment=1 if cancomment else 0
		articleInfo.password=password

		articleInfo.save()

		#更新分类统计信息 不是默认分类并且是发布的文章
		if category.id !=1 and status:
			category.articles+=1
			category.save()

		#更新用户文章统计信息
		currentBlog=userInfos["currentblog"]
		currentBlog.articles+=1
		currentBlog.save()

		if channel1Id>0:
			channel1=Channel.objects.get(id=channel1Id)
			channel1.articles+=1
			channel1.save()
		if channel2Id>0:
			channel2=Channel.objects.get(id=channel2Id)
			channel2.articles+=1
			channel2.save()

		return HttpResponseRedirect('/%d/' %request.user.id)
	else:
		
		articleInfo=Article()

		return utility.my_render_to_response(request,"pub/articleedit.html",locals())
Example #43
0
def test(request):
    return utility.my_render_to_response(request,"test.html",locals())
Example #44
0
def edit(request, uid, aid):
    uid = int(uid)
    userInfos = common.Users(request, uid)
    currentUser = userInfos["currentuser"]

    categoryList = common.categoryList(currentUser.id)
    channelList = Channel.objects.all()

    articleInfo = Article.objects.get(id=aid)
    oldCategory = articleInfo.category_id
    oldStatus = articleInfo.status

    if request.POST.has_key('ok'):
        channel1Id = int(utility.GetPostData(request, 'channel1', 0))
        channel2Id = int(utility.GetPostData(request, 'channel2', 0))
        cateId = int(utility.GetPostData(request, 'category'))
        category = Category.objects.get(
            id=utility.GetPostData(request, 'category'))

        title = utility.GetPostData(request, 'title')
        pic = utility.GetPostData(request, 'pic')
        tags = utility.GetPostData(request, 'tags')
        summary = utility.GetPostData(request, 'summary')
        content = utility.GetPostData(request, 'content')
        status = utility.GetPostData(request, 'status')

        ishome = utility.GetPostData(request, 'ishome')
        isrecommend = utility.GetPostData(request, 'isrecommend')
        istop = utility.GetPostData(request, 'istop')
        isoriginal = utility.GetPostData(request, 'isoriginal')
        cancomment = utility.GetPostData(request, 'cancomment')
        password = utility.GetPostData(request, 'password')

        if summary == "":
            tempContent = utility.RemoveTags(content)
            summary = tempContent[0:200] if len(
                tempContent) > 200 else tempContent
        else:
            summary = utility.RemoveTags(summary)

        articleInfo.channel1_id = channel1Id
        articleInfo.channel2_id = channel2Id
        articleInfo.category_id = cateId
        articleInfo.title = title
        articleInfo.pic = pic
        articleInfo.tags = tags
        articleInfo.summary = summary
        articleInfo.content = content
        #articleInfo.createtime=datetime.datetime.now()
        #articleInfo.views=0
        #articleInfo.comments=0
        #articleInfo.goods=0
        #articleInfo.bads=0
        articleInfo.status = 1 if status else 0
        #articleInfo.user_id=request.user.id
        #articleInfo.username=request.user.username

        articleInfo.ishome = 1 if ishome else 0
        articleInfo.isrecommend = 1 if isrecommend else 0
        articleInfo.istop = 1 if istop else 0
        articleInfo.isoriginal = 1 if isoriginal else 0
        articleInfo.cancomment = 1 if cancomment else 0
        articleInfo.password = password

        if oldCategory != category:
            #不是未分类,并且已经发布
            if category.id != 1 and status:
                category.articles += 1
                category.save()
            #不是未分类,并且已经是草稿
            if oldCategory.id != 1 and oldStatus:
                oldCategory.articles = oldCategory.articles - 1 if oldCategory.articles > 1 else 0
                oldCategory.save()
        else:
            if not status:
                category.articles -= 1
                category.save()

        articleInfo.save()

        return HttpResponseRedirect('/%d/' % request.user.id)
    else:
        return utility.my_render_to_response(request, "pub/articleedit.html",
                                             locals())
Example #45
0
def transfer(request, uid, aid):
    uid = int(uid)
    userInfos = common.Users(request, uid)
    currentUser = userInfos["currentuser"]

    categoryList = common.categoryList(currentUser.id)
    channelList = Channel.objects.all()

    articleInfo = Article.objects.get(id=aid)
    oldCategory = articleInfo.category_id
    oldStatus = articleInfo.status

    if request.POST.has_key('ok'):
        channel1Id = int(utility.GetPostData(request, 'channel1', 0))
        channel2Id = int(utility.GetPostData(request, 'channel2', 0))
        cateId = int(utility.GetPostData(request, 'category'))
        category = Category.objects.get(
            id=utility.GetPostData(request, 'category'))

        title = utility.GetPostData(request, 'title')
        pic = utility.GetPostData(request, 'pic')
        tags = utility.GetPostData(request, 'tags')
        summary = utility.GetPostData(request, 'summary')
        content = utility.GetPostData(request, 'content')
        status = utility.GetPostData(request, 'status')

        ishome = utility.GetPostData(request, 'ishome')
        isrecommend = utility.GetPostData(request, 'isrecommend')
        istop = utility.GetPostData(request, 'istop')
        isoriginal = utility.GetPostData(request, 'isoriginal')
        cancomment = utility.GetPostData(request, 'cancomment')
        password = utility.GetPostData(request, 'password')

        if summary == "":
            tempContent = utility.RemoveTags(content)
            summary = tempContent[0:200] if len(
                tempContent) > 200 else tempContent
        else:
            summary = utility.RemoveTags(summary)

        articleInfo.channel1_id = channel1Id
        articleInfo.channel2_id = channel2Id
        articleInfo.category_id = cateId
        articleInfo.title = title
        articleInfo.pic = pic
        articleInfo.tags = tags
        articleInfo.summary = summary
        articleInfo.content = content
        articleInfo.createtime = datetime.datetime.now()
        articleInfo.views = 0
        articleInfo.comments = 0
        articleInfo.goods = 0
        articleInfo.bads = 0
        articleInfo.status = 1 if status else 0
        articleInfo.user_id = request.user.id
        articleInfo.username = request.user.username

        articleInfo.ishome = 1 if ishome else 0
        articleInfo.isrecommend = 1 if isrecommend else 0
        articleInfo.istop = 1 if istop else 0
        articleInfo.isoriginal = 1 if isoriginal else 0
        articleInfo.cancomment = 1 if cancomment else 0
        articleInfo.password = password

        articleInfo.save()

        # 更新分类统计信息 不是默认分类并且是发布的文章
        if category.id != 1 and status:
            category.articles += 1
            category.save()

        # 更新用户文章统计信息
        currentBlog = userInfos["currentblog"]
        currentBlog.articles += 1
        currentBlog.save()

        if channel1Id > 0:
            channel1 = Channel.objects.get(id=channel1Id)
            channel1.articles += 1
            channel1.save()
        if channel2Id > 0:
            channel2 = Channel.objects.get(id=channel2Id)
            channel2.articles += 1
            channel2.save()

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

        return HttpResponseRedirect('/%d/' % request.user.id)
    else:
        return utility.my_render_to_response(request, "pub/articleedit.html",
                                             locals())
Example #46
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())