Example #1
0
def profile_or_home():
    try:
        if web.input().profile:
            return web.seeother("/profile/%s" % web.input().profile)
    except:
        pass
    return web.seeother('/home')
Example #2
0
    def POST(self, slug):
        if not users.is_current_user_admin():
            return web.seeother("/")

        forum = Forum(key_name=slug)
        i = web.input()
        forum.slug = slug
        forum.name = i.name
        forum.description = i.description
        forum.put()
        return web.seeother("%s/forum" % slug)
Example #3
0
 def GET(self, key):
     try:
         if web.input().login:
             return web.seeother(users.create_login_url("/welcome?profile=%s" % key))
     except:
         pass
     profile = Profile.get(key)
     nonce = uuid.uuid4().hex
     goog = users.get_current_user()
     if profile:
         return render.profile(profile, nonce, goog)
     else:
         return web.seeother('/')
Example #4
0
    def POST(self, slug):
        if not users.is_current_user_admin():
            return web.seeother('/')
        key = db.Key.from_path('Page', slug)
        page = Page.get(key)
        if page == None:
            page = Page(key_name=slug)

        i = web.input()
        page.slug = slug
        page.title = i.title
        page.body = i.body
        page.put()
        return web.seeother(slug)
Example #5
0
    def POST(self, slug):
        if not users.is_current_user_admin():
            return web.seeother('/')
        key = db.Key.from_path('Page', slug)
        page = Page.get(key)
        if page == None:
            page = Page(key_name=slug)

        i = web.input()
        page.slug = slug
        page.title = i.title
        page.body = i.body
        page.put()
        return web.seeother(slug)
Example #6
0
    def POST(self, slug):
        if not users.is_current_user_admin():
            return web.seeother("/")
        key = db.Key.from_path("Page", slug)
        page = Page.get(key)
        if not page:
            page = Page(key_name=slug)

        i = web.input()
        page.slug = slug
        page.title = i.title
        page.body = i.body
        page.metaDescription = i.metaDescription
        page.put()
        return web.seeother(slug)
Example #7
0
    def POST(self):
        user = db.GqlQuery("SELECT * FROM User WHERE goog = :1", users.get_current_user()).get()
        if not user:
            valid_name_regexp = re.compile(r"[a-z]+[a-z_0-9]+")
            if not valid_name_regexp.match(web.input().name):
                return web.seeother('/welcome')
            user = User(key_name=web.input().name)
            user.goog = users.get_current_user()
            user.name = web.input().name
            if user.put():
                return web.seeother("/users/%s" % user.name)
            else:
                return web.seeother('/welcome')

        return web.seeother("/users/%s" % user.name)
Example #8
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)
Example #9
0
 def POST(self, name):
     page = db.GqlQuery("SELECT * FROM Page WHERE name = :1", name).get()
     if not page:
         page = Page(name=name)
     page.body = web.input().body
     page.updated = datetime.datetime.now()
     page.put()
     PageVersion(page=page, body=page.body).put()
     return web.seeother('/wiki/'+page.name)
Example #10
0
    def POST(self):
        user = db.GqlQuery("SELECT * FROM User WHERE goog = :1", users.get_current_user()).get()
        if not user:
            user = User()
            user.goog = users.get_current_user()
            user.name = web.input().name
            user.put()  # FIXME: uniq on name

        return web.seeother("/")
Example #11
0
 def GET(self, slug):
     user = users.get_current_user()
     if user:
         key = db.Key.from_path('Forum', slug)
         forum = Forum.get(key)
         if forum:
             return render.forumNewTopic(forum)
     else:
         return web.seeother(users.create_login_url('%s/forum/new' % slug))
Example #12
0
 def GET(self, name):
     page = db.GqlQuery("SELECT * FROM Page WHERE name = :1", name).get()
     if page:
         versions = page.pageversion_set.order('-created').fetch(10,1)
         more_versions = len(versions) == 10
         versions = versions[:9]
         return render.show(page, versions, more_versions)
     else:
         return web.seeother('/wiki/e/'+name)
Example #13
0
    def GET(self):
        goog = users.get_current_user()
        if not goog:
            return web.seeother(users.create_login_url('/settings'))

        user = db.GqlQuery("SELECT * FROM User WHERE goog = :1", goog).get()
        if not user:
            return render_no_layout.settings()
        else:
            return render_no_layout.thanks()
Example #14
0
 def POST(self, slug):
     key = db.Key.from_path("Redirect", slug)
     item = Redirect.get(key)
     if not item:
         item = Redirect(key_name=slug)
     i = web.input()
     item.url = i.url
     item.slug = slug
     item.put()
     return web.seeother("/admin")
Example #15
0
 def POST(self):
     i = web.input()
     article = Article()
     article.title = i.title
     article.slug = i.slug
     article.body = i.body
     # article.created = datetime.datetime.strptime(i.created.split('.')[0], '%Y-%m-%d %H:%M:%S')
     article.tags = [x.strip() for x in i.tags.split(",")]
     article.put()
     return web.seeother("/articles/" + article.slug)
Example #16
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())
Example #17
0
 def POST(self, slug):
     i = web.input()
     articles = db.GqlQuery("SELECT * FROM Article WHERE slug = :1", slug)
     article = articles.get()
     article.title = i.title
     article.slug = i.slug
     article.body = i.body
     article.created = datetime.datetime.strptime(i.created.split(".")[0], "%Y-%m-%d %H:%M:%S")
     article.tags = [x.strip() for x in i.tags.split(",")]
     article.put()
     return web.seeother("/articles/" + article.slug)
Example #18
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()))
Example #19
0
    def POST(self, key):
        goog = users.get_current_user()
        if not goog:
            return web.seeother('/')

        profile = Profile.get(key)
        if not profile:
            web.debug("no such profile")
            return web.seeother('/')
        challenge = web.input().challenge
        response = web.input().response
        secret = profile.secret
        expected_response = md5.new(challenge + secret).hexdigest()
        web.debug("response = " + response + ", expected = " + expected_response)
        user = db.GqlQuery("SELECT * FROM User WHERE goog = :1", goog).get()
        if (expected_response == response) and user:
            web.debug("own the profile")
            profile.user = user
            profile.put()
            return web.seeother("/users/%s" % user.name)
        else:
            web.debug("unauthorized")
            web.ctx.status = "401 unauthorized"
            return web.seeother('/')
Example #20
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()))
Example #21
0
 def GET(self, slug):
     key = db.Key.from_path('Redirect', slug)
     redirect = Redirect.get(key)
     if redirect:
         return web.seeother(redirect.url)
     key = db.Key.from_path('Page', slug)
     page = Page.get(key)
     if users.is_current_user_admin():
         if page:
             if web.ctx.query == '':
                 return render.pageShow(page, slug)
         else:
             page = Page()
         return render.pageEdit(page, slug)
     else:
         if page:
             return render.pageShow(page, slug)
         web.ctx.status = '404 shit happens'
         return render.missing(slug)
Example #22
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()))
Example #23
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)
Example #24
0
 def GET(self):
     user = db.GqlQuery("SELECT * FROM User WHERE goog = :1", users.get_current_user()).get()
     if not user:
         return render.welcome()
     else:
         return web.seeother('/update')
Example #25
0
 def GET(self):
      return web.seeother(users.create_login_url('/'))
Example #26
0
 def GET(self):
     return web.seeother(users.create_login_url('/'))
Example #27
0
 def POST(self):
     i = web.input()
     person = Person()
     person.name = i.name
     person.put()
     return web.seeother('/list')
Example #28
0
 def POST(self):
     i = web.input()
     person = Person()
     person.name = i.name
     person.put()
     return web.seeother('/list')
Example #29
0
 def GET(self):
     return web.seeother(users.create_login_url("/welcome"))
Example #30
0
    def GET(self):
        user = db.GqlQuery("SELECT * FROM User WHERE goog = :1", users.get_current_user()).get()
        if not user:
            web.seeother("/login")

        return render.user(user)
Example #31
0
    def GET(self):
        user = getUser()
        if not user:
            return web.seeother('/login')

        return render.user(user)
Example #32
0
 def GET(self):
     return web.seeother(users.create_logout_url("/"))
Example #33
0
 def GET(self, key):
     comment = Comment.get(key)
     article = comment.article
     comment.delete()
     return web.seeother("/articles/" + article.slug)