def execute(self): logging.info("dict: %s" % self.__dict__) response = {} if self.files: added = [] for upload in self.files.getlist("upload[]"): logging.info("upload %s" % upload) m = Picture() m.upload_content(upload) m.put() Picture.get(m.key()) added.append(m) response["added"] = self.get_files_and_dirs(added) else: response = Command.get_error( "Faild to upload picture, maximum upload data must not exceed 2.5MB" ) # settings.py:FILE_UPLOAD_MAX_MEMORY_SIZE import pprint logging.info("Uploae resposne: \n%s" % pprint.pformat(response)) return response
def image_delete(request, key): if not key: return redirect(image_list) if request.POST.get('confirmation') == 'yes': m = Picture.get(key) if m: m.delete() Picture.get(key) # for refreshing purposes http://stackoverflow.com/questions/15773892/should-i-expect-stale-results-after-redirect-on-local-environment if request.POST.get('confirmation'): return redirect(image_list) return render_to_response("confirmation.html", {}, context_instance=RequestContext(request))
def execute(self): logging.info("dict: %s" % self.__dict__) response = {} if self.is_param_true("target") and self.is_param_true("name"): m = Picture.get(self.get("target")) m.title = self.get("name") m.put() Picture.get(m.key()) else: Command.get_error("Invalid backend configuration") import pprint logging.info("resposne: \n%s" % pprint.pformat(response)) return response
def image_upload(request): if request.method == 'POST': formset = UploadFileForm(request.POST, request.FILES) if formset.is_valid(): movie = Picture() movie.upload_content(request.FILES['file']) movie.put() Picture.get(movie.key()) return redirect(image_list) else: formset = UploadFileForm() return render_to_response("image_upload.html", { "formset" : formset }, context_instance=RequestContext(request))
def image_add(request): formset = None urlfetch = request.POST.get('urlfetch') if urlfetch: movie = Picture() movie.fetch_content(urlfetch) movie.put() Picture.get(movie.key()) return redirect(image_list) else: formset = AddImmageForm() return render_to_response("image_add.html", { "formset" : formset }, context_instance=RequestContext(request))
def execute(self): logging.info("dict: %s" % self.__dict__) response = {} if self.is_param_true("targets[]"): removed = [] for key in self.getlist("targets[]"): m = Picture.get(key) m.delete() Picture.get(m.key()) removed.append(key) response["removed"] = removed else: response = Command.get_error("Invalid backend configuration: faild to remove picture") import pprint logging.info("Rm resposne: \n%s" % pprint.pformat(response)) return response
def execute(self): logging.info("dict: %s" % self.__dict__) response = {} if self.is_param_true("targets[]"): removed = [] for key in self.getlist("targets[]"): m = Picture.get(key) m.delete() Picture.get(m.key()) removed.append(key) response["removed"] = removed else: response = Command.get_error( "Invalid backend configuration: faild to remove picture") import pprint logging.info("Rm resposne: \n%s" % pprint.pformat(response)) return response
def execute(self): logging.info("dict: %s" % self.__dict__) response = {} if self.is_param_true("init"): response['api'] = self.get_api() response['options'] = self.get_options() response['uplMaxSize'] = "16M" if self.is_param_true("tree"): response['files'] = self.get_files_and_dirs(Picture.get_all()) response['files'].append(self.get_cwd()) elif self.is_param_true("target"): response['files'] = self.get_target(self.target) response['cwd'] = self.get_cwd() import pprint logging.info("resposne: \n%s" % pprint.pformat(response)) return response
def image_list(request): return render_to_response("image_list.html", { "images" : Picture.get_all(), }, context_instance=RequestContext(request))