Exemplo n.º 1
0
    def post(self):
        title = self.request.get("title")
        art = self.request.get("art")

        if art and title:
            a = Art(title = title, art = art)
            coords = utils.get_coords(self.request.remote_addr)
            if coords:
                a.coords = coords

            a.put()
            utils.top_arts(True)

            self.redirect("/course_work/unit3/ASCIIChan")
        else:
            error = "We need both title and some artwork!"
            self.render_ASCII_page(title,art,error) 
Exemplo n.º 2
0
    def render_ASCII_page(self, title="", art = "", error = ""):
        valid_cookie = self.request.cookies.get('user_id')
        if valid_cookie:
            import globals 
            if globals.users != None:

                arts = utils.top_arts()
                img_url = None
                points = filter(None, (a.coords for a in arts))
        
                if points:
                    img_url = utils.gmaps_img(points)
        
                self.render("ASCIIChan.html", title = title, art = art, error = error, arts = arts, img_url = img_url, user = globals.users)
        else:
            self.redirect('/')