Ejemplo n.º 1
0
 def edit(self, *args):
     if self.params.key:
         item = Galery.get(self.params.key)
         if item:
             return {'op':'update', 'GaleryForm': GaleryForm(instance=item)}
         else:
             self.status = 'Galery does not exists'
             self.redirect(GaleryController.get_url())
     else:
         return {'op':'insert' ,'GaleryForm':GaleryForm()}
Ejemplo n.º 2
0
 def delete(self,*args):
     if self.params.key:
         item = Galery.get(self.params.key)
         if item:
             item.delete()
             self.status ='Galery is deleted!'
         else:
             self.status='Galery does not exist'
     else:
         self.status = 'Key was not Provided!'
     self.redirect(GaleryController.get_url())
Ejemplo n.º 3
0
 def details(self, *args):
     if self.params.key:
         item = Galery.get(self.params.key)
         if item:
             return {'Galery': Galery}
         else:
             self.status = 'Galery does not exists'
             self.redirect(GaleryController.get_url())
     else:
         self.status = 'Key not provided'
         return {'Galery':Galery}
Ejemplo n.º 4
0
 def index(self, *args):
     self.SetTemplate(templateName="Galery_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 = {'GaleryList': Galery.all().fetch(limit=count, offset=index)}
     result.update(locals())
     return result
Ejemplo n.º 5
0
 def save(self, *args):
     instance = None
     if self.params.key:
         instance = Galery.get(self.params.key)
     form=GaleryForm(data=self.request.POST, instance=instance)
     if form.is_valid():
         result=form.save(commit=False)
         result.CreatedBy = self.User
         result.put()
         self.status = 'Galery is saved'
         self.redirect('/galery')
     else:
         self.SetTemplate(templateName = 'Galery_edit.html')
         self.status = 'Form is not Valid'
         return {'op':'update', 'GaleryForm': form}