Exemplo n.º 1
0
def AjaxCategoryMoveOrder(request):
    chkpr = CheckPOST(['dct', 'mvid'], request.GET.keys())
    if not chkpr == "":
        return JsonResponse({"code": 400, "msg": "Error Args."})
    dct = request.GET.get('dct')
    mvid = request.GET.get('mvid')
    try:
        curo = BlogCategoty.objects.get(id=mvid)
    except BlogCategoty.DoesNotExist:
        return JsonResponse({"code": 404, "msg": "object Not Found."})
    if dct == "up":
        neo = curo.order - 1
    elif dct == "dn":
        neo = curo.order + 1
    try:
        nexto = BlogCategoty.objects.get(order=neo)
    except BlogCategoty.DoesNotExist:
        return JsonResponse({"code": 300, "msg": "Attached Limit."})
    except BlogCategoty.MultipleObjectsReturned:
        return JsonResponse({
            "code":
            500,
            "isec":
            "500@AjaxChpOcMv$100",
            "msg":
            "Internal Server Error, Please Contact With Website Master or Admin."
        })
    o1 = nexto.order
    o2 = curo.order
    nexto.order = o2
    curo.order = o1
    nexto.save()
    curo.save()
    return JsonResponse({"code": 200, "msg": "OK."})
Exemplo n.º 2
0
def SetCommentsReview(request,cmid):
	try:
		lmo = BlogComment.objects.get(cmid=cmid)
	except BlogComment.DoesNotExist:
		return JsonResponse({"stat":"err","type":"DoesNotExist"})
	logic = request.GET.get('val')
	bl = (logic == "true")
	lmo.reviewed = bl
	lmo.save()
	return JsonResponse({"stat":"ok","type":"OK"})
Exemplo n.º 3
0
def DelComments(request,cmid):
	try:
		lmo = BlogComment.objects.get(cmid=cmid)
	except BlogComment.DoesNotExist:
		return JsonResponse({"stat":"err","type":"DoesNotExist"})
	if request.GET.get('veryfycode') == TIIHASH(lmo.fromuser,lmo.fromuser):
		lmo.delete()
	else:
		return JsonResponse({"stat":"err","type":"VerificationError"})
	return JsonResponse({"stat":"ok","type":"OK"})
Exemplo n.º 4
0
def LeaveMsgDel(request, cmid):
    try:
        lmo = LeaveMsg.objects.get(cmid=cmid)
    except LeaveMsg.DoesNotExist:
        return JsonResponse({"stat": "err", "type": "DoesNotExist"})
    if request.GET.get('veryfycode') == TIIHASH(lmo.title, lmo.fromuser):
        lmo.delete()
    else:
        return JsonResponse({"stat": "err", "type": "VerificationError"})
    return JsonResponse({"stat": "ok", "type": "OK"})
Exemplo n.º 5
0
def AjaxGetUserID(request, uname):
    uobj = zlauth.GetUserByName(uname)
    if uobj == None:
        return JsonResponse({"code": 404, "nick": u"(用户不存在)", "uid": "0"})
    else:
        return JsonResponse({
            "code": 200,
            "nick": u"%s<%s>" % (uobj.nick, uobj.name),
            "uid": unicode(uobj.id)
        })
Exemplo n.º 6
0
def SysVarConfAjaxEdit(request):
    if request.method == "POST":
        chkpr = CheckPOST(['key', 'value'], request.POST.keys())
        if not chkpr == "":
            return JsonResponse({"code": "400", "errmsg": "Invalid Args."})
        r = RedisConfigHandler(settings.CFG_REDIS, "pichublog")
        r.set(request.POST['key'], request.POST['value'])
        return JsonResponse({"code": "200"})
    else:
        return JsonResponse({"code": "400", "errmsg": "Invalid Args."})
Exemplo n.º 7
0
def AddComments(request,ID):
	try:
		bpo = BlogPost.objects.get(id=ID)
	except BlogPost.DoesNotExist:
		kwvars = {
		"request":request,
		"ctlist":BlogCategoty.objects.all().order_by('order'),
		}
		return render_to_response('home/post.err.html',kwvars,RequestContext(request))
	if bpo.freecomment:
		pmhc = True
	else:
		pmhc = False
		for hgp in thisuser.group:
			if hgp in bpo.commentgrp:
				if not thisuser in bpo.commentuex:
					pmhc = True
				break
		if not pmhc:
			if thisuser in bpo.commentuin:
				pmhc = True
	if not pmhc:
		messages.error(request,u"<b>作者只允许指定身份的人评论本文,您不在此列。</b>")
		return HttpResponseRedirect(reverse('pichublog_postview',args=(ID,)))
	if request.method == "POST":
		if request.auth.islogin:
			chkpr=CheckPOST(['content'],request.POST.keys())
			if not chkpr == "" :
				return JsonResponse({"code":400,"msg":"Error Args."})
		else:
			chkpr=CheckPOST(['content','nick','website','mail','title'],request.POST.keys())
			if not chkpr == "" :
				return JsonResponse({"code":400,"msg":"Error Args."})
		if request.auth.islogin:
			content = request.POST.get('content')
			stk = request.auth.cookie.get('zl2_token')
			BlogComment.objects.create(post=bpo,cmid=BigIntUniqueID(),anonymou=False,stoken=stk,fromuser=request.auth.user,content=content,reviewed=True)
			return HttpResponseRedirect(reverse('pichublog_postview',args=(ID,)))
		else:
			capt = request.POST.get('captcha')
			if not CheckCaptcha(request,capt):
				messages.error(request,u"<b>验证码错误</b>")
				return HttpResponseRedirect(reverse('pichublog_postview',args=(ID,)))
			content = request.POST.get('content')
			nick = request.POST.get('nick')
			mail = request.POST.get('mail')
			web = request.POST.get('website')
			stk = request.auth.cookie.get('zl2_token')
			rws = not boolFastConfGet('CommentsReviewSwitch',default=True)
			LeaveMsg.objects.create(post=bpo,cmid=BigIntUniqueID(),anonymou=True,stoken=stk,fromuser=nick,mail=mail,website=web,content=content,reviewed=rws)
			return HttpResponseRedirect(reverse('pichublog_postview',args=(ID,)))
	else:
		return HttpResponse("405 Method Not Allowed")
Exemplo n.º 8
0
def SysVarConfAjaxToggle(request):
    if request.method == "POST":
        chkpr = CheckPOST(['key'], request.POST.keys())
        if not chkpr == "":
            return JsonResponse({"code": "400", "errmsg": "Invalid Args."})
        r = RedisConfigHandler(settings.CFG_REDIS, "pichublog")
        c = r.get(request.POST['key'])
        if c == "True":
            r.set_bool(request.POST['key'], False)
        elif c == "False":
            r.set_bool(request.POST['key'], True)
        else:
            return JsonResponse({"code": "505", "errmsg": "Not Boolean Field"})
        return JsonResponse({"code": "200"})
    else:
        return JsonResponse({"code": "400", "errmsg": "Invalid Args."})
Exemplo n.º 9
0
def LeaveMsgAdd(request):
    if request.method == "POST":
        if request.auth.islogin:
            chkpr = CheckPOST(['content'], request.POST.keys())
            if not chkpr == "":
                return JsonResponse({"code": 400, "msg": "Error Args."})
        else:
            chkpr = CheckPOST(['content', 'nick', 'website', 'mail', 'title'],
                              request.POST.keys())
            if not chkpr == "":
                return JsonResponse({"code": 400, "msg": "Error Args."})
        if request.auth.islogin:
            content = request.POST.get('content')
            title = request.POST.get('title')
            stk = request.auth.cookie.get('zl2_token')
            LeaveMsg.objects.create(cmid=BigIntUniqueID(),
                                    title=title,
                                    anonymou=False,
                                    stoken=stk,
                                    fromuser=request.auth.user,
                                    content=content,
                                    reviewed=True)
            return HttpResponseRedirect(reverse('pichublog_msgboard'))
        else:
            capt = request.POST.get('captcha')
            if not CheckCaptcha(request, capt):
                messages.error(request, u"<b>验证码错误</b>")
                return HttpResponseRedirect(reverse('pichublog_msgboard'))
            content = request.POST.get('content')
            nick = request.POST.get('nick')
            mail = request.POST.get('mail')
            web = request.POST.get('website')
            title = request.POST.get('title')
            stk = request.auth.cookie.get('zl2_token')
            rws = not boolFastConfGet('LeaveMsgReviewSwitch', default=True)
            LeaveMsg.objects.create(cmid=BigIntUniqueID(),
                                    title=title,
                                    anonymou=True,
                                    stoken=stk,
                                    fromuser=nick,
                                    mail=mail,
                                    website=web,
                                    content=content,
                                    reviewed=rws)
            return HttpResponseRedirect(reverse('pichublog_msgboard'))
    else:
        return HttpResponse("405 Method Not Allowed")