Ejemplo n.º 1
0
 def POST(self, key):
     i = web.input()
     comment = Comment.get(key)
     comment.name = i.name
     comment.body = i.body
     comment.body_html = sanitize.html(i.body)
     comment.url = i.url
     comment.put()
     return web.seeother("/articles/" + comment.article.slug)
Ejemplo n.º 2
0
 def GET(self):
     offset = int(web.input().offset)
     comments = Comment.all().fetch(limit=40, offset=offset)
     for comment in comments:
         comment.body_html = sanitize.html(comment.body)
         comment.put()
     cnt = Comment.all().count()
     if offset + 40 < cnt:
         return "<a href='/admin/fix?offset=%s'>next</a>" % (offset + 40)
     else:
         return "done"
Ejemplo n.º 3
0
    def POST(self, key):
        i = web.input()

        topic = Topic.get(key)
        post = Post()
        post.topic = topic
        post.body = i.body
        post.body_html = sanitize.html(i.body)
        post.user = users.get_current_user()
        post.put()
        return web.seeother("/forum/%s" % topic.key())
Ejemplo n.º 4
0
    def POST(self, slug, key):
        i = web.input()

        topic = Topic.get(key)
        post = Post()
        post.topic = topic
        post.body = i.body
        post.body_html = sanitize.html(i.body)
        post.user = users.get_current_user()
        post.put()
        if post.is_saved():
            topic.last_post = post.created
            topic.put()
        return web.seeother("%s/forum/%s" % (slug, topic.key()))
Ejemplo n.º 5
0
    def POST(self, tag):

        i = web.input()

        topic = Topic()
        topic.title = i.title
        topic.tags = [tag]
        topic.user = users.get_current_user()

        topic.put()
        post = Post()
        post.topic = topic
        post.body = i.body
        post.body_html = sanitize.html(i.body)
        post.user = users.get_current_user()
        post.put()
        return web.seeother("/forum/%s/%s" % (tag, topic.key()))
Ejemplo n.º 6
0
    def POST(self):
        i = web.input()
        slug = i.slug
        articles = db.GqlQuery("SELECT * FROM Article WHERE slug = :1", slug)
        article = articles.get()

        #result = captcha.submit(i.recaptcha_challenge_field, i.recaptcha_response_field, PRIV, web.ctx['ip'])
        #if not result.is_valid:
        #    return render.captcha()

        comment = Comment()
        comment.article = article
        comment.name = i.name
        comment.email = i.email
        comment.body = i.body
        # comment.created = datetime.datetime.strptime(i.created.split('.')[0], '%Y-%m-%d %H:%M:%S')
        comment.body_html = sanitize.html(i.body)
        comment.url = sanitize.url(i.url)
        comment.raw = web.data()
        comment.put()
        return web.seeother('/articles/'+article.slug)
Ejemplo n.º 7
0
    def POST(self, slug):
        key = db.Key.from_path('Forum', slug)
        forum = Forum.get(key)
        if not forum:
            return render.seeother('/')

        i = web.input()

        topic = Topic()
        topic.forum = forum
        topic.title = i.title
        topic.user = users.get_current_user()

        topic.put()
        post = Post()
        post.topic = topic
        post.body = i.body
        post.body_html = sanitize.html(i.body)
        post.user = users.get_current_user()
        post.put()
        return web.seeother("%s/forum/%s" % (slug, topic.key()))