def get(self): "Responds to GET requets with the admin interface" # query the datastore for images owned by # the current user. You can't see anyone elses images # in the admin test = geturl("http://org-images.appspot.com/remote/upload/image/[valid key]") # add valid realmkey url = test.get_url() user = users.get_current_user() realms = RealmKeys.all() images = Image.all().filter("user ="******"-date") cssfilesq = File.all() jscriptfilesq = File.all() cssfiles = cssfilesq.filter("content_type =", "text/css").order("-date") jscriptfiles = jscriptfilesq.filter("content_type =", "text/x-c").order("-date") blobs = BlobFile.all() blobs.filter("user ="******"-date") # we are enforcing loggins so we know we have a user # we need the logout url for the frontend logout = users.create_logout_url("/") # prepare the context for the template context = { "testurl": url, "blobuploadurl": blobstore.create_upload_url("/upload/blob"), "blobs": blobs, "cssfiles": cssfiles, "jscriptfiles": jscriptfiles, "images": images, "logout": logout, "realms": realms, } # calculate the template path path = os.path.join(os.path.dirname(__file__), "templates", "index.html") # render the template with the provided context self.response.out.write(template.render(path, context))
def post(self, key): checkkey = UploadRequestKeys.get(key) if not checkkey: self.error(404) if checkkey.expire_date < datetime.now(): self.error(404) img = self.request.get("img") # if we don't have image data we'll quit now if not img: return None try: width = int(self.request.get("width")) hight = int(self.request.get("height")) except ValueError: image_content = img else: image_content = images.resize(img, width, height) original_content = img thumb_content = images.resize(img, 100, 100) image = Image() image.image = db.Blob(image_content) image.original = db.Blob(original_content) image.thumb = db.Blob(thumb_content) image.user = users.get_current_user() image.realm = RealmKeys.get(checkkey.realm_key) image.put() checkkey.delete() # self.response.out.write(simplejson.dumps({'img_url'::})) context = { "image": True, "img_url": "http://org-images.appspot.com/i/img?id=%s" % image.key(), "thumb_url": "http://org-images.appspot.com/i/thumb?id=%s" % image.key(), } path = os.path.join(os.path.dirname(__file__), "templates", "show_links.html") # render the template with the provided context self.response.out.write(template.render(path, context))
def post(self): realm = RealmKeys() realm.realm_name = self.request.get("realm_name") realm.put() self.redirect("/")