Пример #1
0
 def details(self, *args):
     if self.params.key:
         item = Grouper.get(self.params.key)
         if item:
             return {'op':'update', 'GrouperForm': GrouperForm(instance=item)}
         else:
             self.status = 'Grouper does not exists'
             self.redirect(GrouperController.get_url())
     else:
         self.status = 'Key not provided'
         return {'op':'insert' ,'GrouperForm':GrouperForm()}
Пример #2
0
 def delete(self,*args):
     if self.params.key:
         item = Grouper.get(self.params.key)
         if item:
             item.delete()
             self.status ='Grouper is deleted!'
         else:
             self.status='Grouper does not exist'
     else:
         self.status = 'Key was not Provided!'
     self.redirect(GrouperController.get_url())
Пример #3
0
 def delete(self, *args):
     if self.params.key:
         item = Grouper.get(self.params.key)
         if item:
             item.delete()
             self.status = 'Grouper is deleted!'
         else:
             self.status = 'Grouper does not exist'
     else:
         self.status = 'Key was not Provided!'
     self.redirect(GrouperController.get_url())
Пример #4
0
 def index(self, *args):
     self.SetTemplate(templateName="Grouper_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 = {'GrouperList': Grouper.all().fetch(limit=count, offset=index)}
     result.update(locals())
     return result
Пример #5
0
 def save(self, *args):
     instance = None
     if self.params.key:
         instance = Grouper.get(self.params.key)
     form=GrouperForm(data=self.request.POST, instance=instance)
     if form.is_valid():
         result=form.save(commit=False)
         result.put()
         self.status = 'Grouper is saved'
         self.redirect(GrouperController.get_url())
     else:
         self.SetTemplate(templateName = 'Grouper_edit.html')
         self.status = 'Form is not Valid'
         return {'op':'upd', 'GrouperForm': form}
Пример #6
0
 def details(self, *args):
     if self.params.key:
         item = Grouper.get(self.params.key)
         if item:
             return {
                 'op': 'update',
                 'GrouperForm': GrouperForm(instance=item)
             }
         else:
             self.status = 'Grouper does not exists'
             self.redirect(GrouperController.get_url())
     else:
         self.status = 'Key not provided'
         return {'op': 'insert', 'GrouperForm': GrouperForm()}
Пример #7
0
 def save(self, *args):
     instance = None
     if self.params.key:
         instance = Grouper.get(self.params.key)
     form = GrouperForm(data=self.request.POST, instance=instance)
     if form.is_valid():
         result = form.save(commit=False)
         result.put()
         self.status = 'Grouper is saved'
         self.redirect(GrouperController.get_url())
     else:
         self.SetTemplate(templateName='Grouper_edit.html')
         self.status = 'Form is not Valid'
         return {'op': 'upd', 'GrouperForm': form}
Пример #8
0
 def index(self, *args):
     self.SetTemplate(templateName="Grouper_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 = {
         'GrouperList': Grouper.all().fetch(limit=count, offset=index)
     }
     result.update(locals())
     return result