Beispiel #1
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'})
 def list(self):
     return self._as_json([x.as_dict() for x in User.all()])
 def list(self):
     return self._as_json([x.as_dict() for x in User.all()])