Example #1
0
def deletepage():
	form=request.form
	pagelist=[]
	for item in form:
		pagelist.append(int(item))
	for item in pagelist:
		post=Post.all().filter('post_id',item).get()
		if post:
			post.remove()
	Tag.updatecache()
	Post.updatecache()
	return json.dumps({'status':1})
Example #2
0
def deletepage():
    form = request.form
    pagelist = []
    for item in form:
        pagelist.append(int(item))
    for item in pagelist:
        post = Post.all().filter('post_id', item).get()
        if post:
            post.remove()
    Tag.updatecache()
    Post.updatecache()
    return json.dumps({'status': 1})
Example #3
0
def setting():
    if request.method == 'GET':
        post_id = User.POST_ID
        postnumberhome = User.PER_PAGE_IN_HOME
        postnumberadmin = User.PER_PAGE_IN_ADMIN
        showtagnumber = User.SHOW_TAG_NUMBER
        showtagsearchnumber = User.SHOW_TAGSEARCH_NUMBER
        showlinknumber = User.SHOW_LINK_NUMBER
        mediainadmin = User.MEDIA_IN_ADMIN
        commentinadmin = User.COMMENT_IN_ADMIN
        commentinsidebar = User.COMMENT_IN_SIDEBAR
        announcelength = User.ANNOUNCELENGTH
        return render_template('admin/setting.html',
                               post_id=post_id,
                               postnumberhome=postnumberhome,
                               postnumberadmin=postnumberadmin,
                               showtagnumber=showtagnumber,
                               showtagsearchnumber=showtagsearchnumber,
                               showlinknumber=showlinknumber,
                               mediainadmin=mediainadmin,
                               commentinadmin=commentinadmin,
                               commentinsidebar=commentinsidebar,
                               announcelength=announcelength)
    else:
        needupdate = False
        form = request.form
        one = User.all().get()
        one.postnumberhome = int(form['postnumberhome'])
        one.postnumberadmin = int(form['postnumberadmin'])
        one.showtagnumber = int(form['showtagnumber'])
        one.showmediaadmin = int(form['mediainadmin'])
        one.commentinadmin = int(form['commentinadmin'])
        one.commentinsidebar = int(form['commentinsidebar'])
        one.announcelength = int(form['announcelength'])
        if int(form['showtagsearchnumber']) != one.showtagsearchnumber:
            needupdate = True
        one.showtagsearchnumber = int(form['showtagsearchnumber'])
        one.showlinknumber = int(form['showlinknumber'])
        one.post_id = int(form['post_id'])
        another = Post.all().filter('post_id', int(form['post_id'])).get()
        if not another:
            one.post_id = -1

        one.put()
        User.updatecache(one)
        Tag.updatecache()
        Comment.updatecache()
        Link.updatecache()

        return json.dumps({'message': 'success'})
Example #4
0
def updatepost():
	form =request.args
#	print request.data
	if form.has_key('post_id'):
		post=Post.getone(form['post_id'])
		post.title=form['title']
		post.content=urllib.unquote(request.data).decode('utf-8')
		post.settags(form['tags'])
		post.update_time=int(time.time())
		if form['posttype']=='saveonly':
			post.saveonly=True
		else :
			post.saveonly=False
		if form.has_key('allowcomment') and form['allowcomment']=='on':
			post.allowcomment=True
		else :
			post.allowcomment=False
		post.put_into()
		Tag.updatecache()
		return json.dumps({'message':'success','post_id':form['post_id']})
	return "no such key exsits"
Example #5
0
def updatepost():
    form = request.args
    #	print request.data
    if form.has_key('post_id'):
        post = Post.getone(form['post_id'])
        post.title = form['title']
        post.content = urllib.unquote(request.data).decode('utf-8')
        post.settags(form['tags'])
        post.update_time = int(time.time())
        if form['posttype'] == 'saveonly':
            post.saveonly = True
        else:
            post.saveonly = False
        if form.has_key('allowcomment') and form['allowcomment'] == 'on':
            post.allowcomment = True
        else:
            post.allowcomment = False
        post.put_into()
        Tag.updatecache()
        return json.dumps({'message': 'success', 'post_id': form['post_id']})
    return "no such key exsits"
Example #6
0
def newpost():
    form = request.args
    newpost = Post(title=form['title'],
                   content=urllib.unquote(request.data).decode('utf-8'),
                   num_lookup=0)
    if form['posttype'] == 'saveonly':
        newpost.saveonly = True
    else:
        newpost.saveonly = False
    if form.has_key('allowcomment') and form['allowcomment'] == 'on':
        newpost.allowcomment = True
    else:
        newpost.allowcomment = False
    newpost.post_id = Post.properid()
    newpost.settags(form['tags'])
    newpost.create_date = int(time.time())
    newpost.update_time = newpost.create_date
    newpost.put_into()
    Tag.updatecache()
    Post.updatecache()
    #return json.dumps({'message':newpost.content,'post_id':newpost.post_id})
    return json.dumps({'message': 'success', 'post_id': newpost.post_id})
Example #7
0
def newpost():
	form=request.args
	newpost=Post(title=form['title'],
				content=urllib.unquote(request.data).decode('utf-8'),
				num_lookup=0
				)
	if form['posttype']=='saveonly':
		newpost.saveonly=True
	else :
		newpost.saveonly=False
	if form.has_key('allowcomment') and form['allowcomment']=='on':
		newpost.allowcomment=True
	else :
		newpost.allowcomment=False
	newpost.post_id=Post.properid()
	newpost.settags(form['tags'])
	newpost.create_date=int(time.time())
	newpost.update_time=newpost.create_date
	newpost.put_into()
	Tag.updatecache()
	Post.updatecache()
	#return json.dumps({'message':newpost.content,'post_id':newpost.post_id})
	return json.dumps({'message':'success','post_id':newpost.post_id})