def post(self, secret, key): hacker = hacker_page.getHacker(secret) if hacker is None: logging.error("Attempted to change hacker's uploaded" + key + " but no hacker with key: " + secret) return self.redirect('/') newFiles = map(lambda f: f.key(), self.get_uploads(key)) multipleFileUpload = self.request.get('multiple') == "true" if multipleFileUpload: existingFiles = getattr(hacker, key, []) value = existingFiles + newFiles elif len(newFiles) > 0: existingFile = getattr(hacker, key, None) if existingFile: blobstore.delete(existingFile) value = newFiles[0] else: value = None setattr(hacker, key, value) hacker_page.putHacker(hacker) downloadLinks = map(getDownloadLink, newFiles) fileNames = getFileNames(newFiles) self.response.write(json.dumps({"downloadLinks": downloadLinks, "fileNames" : fileNames}))
def post(self, secret): hacker = hacker_page.getHacker(secret) if hacker is None: logging.error("Attempted to change hacker's uploaded" + key + " but no hacker with key: " + secret) return self.response.write("failure") key = self.request.get('key') files = getattr(hacker, key, []) files.remove(self.request.get('blobKey')) setattr(hacker, key, files) blobstore.delete(self.request.get('blobKey')) hacker_page.putHacker(hacker)