def details(self, *args):
     if self.params.key:
         item = Shop.get(self.params.key)
         if item:
             return {'Shop': item }
         else:
             self.status = 'Shop does not exists'
             self.redirect(ShopController.get_url())
     else:
         self.redirect(ShopController.get_url())
 def edit(self, *args):
     if self.params.key:
         item = Shop.get(self.params.key)
         if item:
             return {'op':'update', 'ShopForm': ShopForm(instance=item)}
         else:
             self.status = 'Shop does not exists'
             self.redirect(ShopController.get_url())
     else:
         return {'op':'insert' ,'ShopForm':ShopForm()}
示例#3
0
 def details(self, *args):
     if self.params.key:
         item = Shop.get(self.params.key)
         if item:
             return {'Shop': item}
         else:
             self.status = 'Shop does not exists'
             self.redirect(ShopController.get_url())
     else:
         self.redirect(ShopController.get_url())
示例#4
0
 def edit(self, *args):
     if self.params.key:
         item = Shop.get(self.params.key)
         if item:
             return {'op': 'update', 'ShopForm': ShopForm(instance=item)}
         else:
             self.status = 'Shop does not exists'
             self.redirect(ShopController.get_url())
     else:
         return {'op': 'insert', 'ShopForm': ShopForm()}
 def delete(self,*args):
     if self.params.key:
         item = Shop.get(self.params.key)
         if item:
             item.delete()
             self.status ='Shop is deleted!'
         else:
             self.status='Shop does not exist'
     else:
         self.status = 'Key was not Provided!'
     self.redirect(ShopController.get_url())
示例#6
0
 def delete(self, *args):
     if self.params.key:
         item = Shop.get(self.params.key)
         if item:
             item.delete()
             self.status = 'Shop is deleted!'
         else:
             self.status = 'Shop does not exist'
     else:
         self.status = 'Key was not Provided!'
     self.redirect(ShopController.get_url())
 def index(self, *args):
     self.SetTemplate(templateName="Shop_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 = {'ShopList': Shop.all().fetch(limit=count, offset=index)}
     result.update(locals())
     return result
 def save(self, *args):
     instance = None
     if self.params.key:
         instance = Shop.get(self.params.key)
     form=ShopForm(data=self.request.POST, instance=instance)
     if form.is_valid():
         result=form.save(commit=False)
         result.put()
         self.status = 'Shop is saved'
         self.redirect(ShopController.get_url())
     else:
         self.SetTemplate(templateName = 'Shop_edit.html')
         self.status = 'Form is not Valid'
         return {'op':'update', 'ShopForm': form}
示例#9
0
 def save(self, *args):
     instance = None
     if self.params.key:
         instance = Shop.get(self.params.key)
     form = ShopForm(data=self.request.POST, instance=instance)
     if form.is_valid():
         result = form.save(commit=False)
         result.put()
         self.status = 'Shop is saved'
         self.redirect(ShopController.get_url())
     else:
         self.SetTemplate(templateName='Shop_edit.html')
         self.status = 'Form is not Valid'
         return {'op': 'update', 'ShopForm': form}
示例#10
0
 def index(self, *args):
     self.SetTemplate(templateName="Shop_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 = {'ShopList': Shop.all().fetch(limit=count, offset=index)}
     result.update(locals())
     return result