def search(self, searchItem, *args, **kwargs): self.SetTemplate(templateName="Product_index.html") return { "ProductList": Product.gql("WHERE Categories = :s", s=searchItem).fetch(limit=100, offset=0) }
def search(self, searchCondition=None, *args, **kwargs): self.SetTemplate(templateName='index.html') mySearch = urllib.unquote(searchCondition or self.params.searchCondition) if mySearch: self.respond({'results':Product.all().fetch(limit=1000, offset=0)}) else: self.status= "No Condition given, so no results displayed!" self.respond()
def edit(self, *args): if self.params.key: item = Product.get(self.params.key) if item: return {'op':'update', 'ProductForm': ProductForm(instance=item)} else: self.status = 'Product does not exists' self.redirect(ProductController.get_url()) else: return {'op':'insert' ,'ProductForm':ProductForm()}
def search(self, searchCondition=None, *args, **kwargs): self.SetTemplate(templateName='index.html') mySearch = urllib.unquote(searchCondition or self.params.searchCondition) if mySearch: self.respond( {'results': Product.all().fetch(limit=1000, offset=0)}) else: self.status = "No Condition given, so no results displayed!" self.respond()
def details(self, *args): if self.params.key: item = Product.get(self.params.key) if item: return {'op':'update', 'Product': item} else: self.status = 'Product does not exists' self.redirect(ProductController.get_url()) else: self.status = 'Key not provided' self.redirect(ProductController.get_url())
def delete(self,*args): if self.params.key: item = Product.get(self.params.key) if item: item.delete() self.status ='Product is deleted!' else: self.status='Product does not exist' else: self.status = 'Key was not Provided!' self.redirect(ProductController.get_url())
def details(self, *args): if self.params.key: item = Product.get(self.params.key) if item: return {'op': 'update', 'Product': item} else: self.status = 'Product does not exists' self.redirect(ProductController.get_url()) else: self.status = 'Key not provided' self.redirect(ProductController.get_url())
def delete(self, *args): if self.params.key: item = Product.get(self.params.key) if item: item.delete() self.status = 'Product is deleted!' else: self.status = 'Product does not exist' else: self.status = 'Key was not Provided!' self.redirect(ProductController.get_url())
def edit(self, *args): if self.params.key: item = Product.get(self.params.key) if item: return { 'op': 'update', 'ProductForm': ProductForm(instance=item) } else: self.status = 'Product does not exists' self.redirect(ProductController.get_url()) else: return {'op': 'insert', 'ProductForm': ProductForm()}
def index(self, *args): self.SetTemplate(templateName="Product_index.html") results =None index = 0; count=20 try: index = int(self.params.index) count = int(self.params.count) except: pass nextIndex = index+count; previousIndex = index<=0 and -1 or (index-count>0 and 0 or index-count) result = {'ProductList': Product.all().fetch(limit=count, offset=index)} result.update(locals()) return result
def save(self, *args): instance = None if self.params.key: instance = Product.get(self.params.key) form=ProductForm(data=self.request.POST, instance=instance) if form.is_valid(): result=form.save(commit=False) result.put() self.status = 'Product is saved' self.redirect(ProductController.get_url()) else: self.SetTemplate(templateName = 'Product_edit.html') self.status = 'Form is not Valid' return {'op':'upd', 'ProductForm': form}
def save(self, *args): instance = None if self.params.key: instance = Product.get(self.params.key) form = ProductForm(data=self.request.POST, instance=instance) if form.is_valid(): result = form.save(commit=False) result.put() self.status = 'Product is saved' self.redirect(ProductController.get_url()) else: self.SetTemplate(templateName='Product_edit.html') self.status = 'Form is not Valid' return {'op': 'upd', 'ProductForm': form}
def index(self, *args): self.SetTemplate(templateName="Product_index.html") results = None index = 0 count = 20 try: index = int(self.params.index) count = int(self.params.count) except: pass nextIndex = index + count previousIndex = index <= 0 and -1 or (index - count > 0 and 0 or index - count) result = { 'ProductList': Product.all().fetch(limit=count, offset=index) } result.update(locals()) return result
def search(self, searchItem, *args, **kwargs): self.SetTemplate(templateName="Product_index.html") return {"ProductList":Product.gql("WHERE Categories = :s", s=searchItem).fetch(limit=100, offset=0)}