Ejemplo n.º 1
0
 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)
     }
Ejemplo n.º 2
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()
Ejemplo n.º 3
0
 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()}
Ejemplo n.º 4
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()
Ejemplo n.º 5
0
 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())
Ejemplo n.º 6
0
 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())
Ejemplo n.º 7
0
 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())
Ejemplo n.º 8
0
 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())
Ejemplo n.º 9
0
 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()}
Ejemplo n.º 10
0
 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
Ejemplo n.º 11
0
 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}
Ejemplo n.º 12
0
 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}
Ejemplo n.º 13
0
 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
Ejemplo n.º 14
0
 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)}