Пример #1
0
 def delete(self):
     if self.params.key:
         item = Role.get(self.params.key)
         if item:
             item.delete()
             self.status = 'Role is deleted!'
         else:
             self.status = 'Role does not exist'
     else:
         self.status = 'Key was not Provided!'
     self.redirect(RoleController.get_url())
Пример #2
0
 def delete(self):
     if self.params.key:
         item = Role.get(self.params.key)
         if item:
             item.delete()
             self.status = "Role is deleted!"
         else:
             self.status = "Role does not exist"
     else:
         self.status = "Key was not Provided!"
     self.redirect(RoleController.get_url())
Пример #3
0
 def edit(self):
     self.SetTemplate(templateName="Role_shw.html")
     if self.params.key:
         item = Role.get(self.params.key)
         if item:
             return {"op": "upd", "RoleForm": RoleForm(instance=item)}
         else:
             self.status = "Role does not exists"
             self.redirect(RoleController.get_url())
     else:
         self.status = "Key not provided"
         return {"op": "ins", "RoleForm": RoleForm()}
Пример #4
0
 def list(self):
     self.SetTemplate(templateName='Role_lst.html')
     results =None
     index = 0; count=1000
     try:
         index = int(self.params.index)
         count = int(self.params.count)
     except:
         pass
     result = {'RoleList': Role.all().fetch(limit=count, offset=index)}
     result.update(locals())
     self.respond(result)
Пример #5
0
 def list(self):
     self.SetTemplate(templateName='Role_lst.html')
     results = None
     index = 0
     count = 1000
     try:
         index = int(self.params.index)
         count = int(self.params.count)
     except:
         pass
     result = {'RoleList': Role.all().fetch(limit=count, offset=index)}
     result.update(locals())
     self.respond(result)
Пример #6
0
 def show(self):
     self.SetTemplate(templateName='Role_shw.html')
     if self.params.key:
         item = Role.get(self.params.key)
         if item:
             result = {'op': 'upd', 'RoleForm': RoleForm(instance=item)}
             self.respond(result)
         else:
             self.status = 'Role does not exists'
             self.redirect(RoleController.get_url())
     else:
         self.status = 'Key not provided'
         self.respond({'op': 'ins', 'RoleForm': RoleForm()})
Пример #7
0
 def show(self):
     self.SetTemplate(templateName='Role_shw.html')
     if self.params.key:
         item = Role.get(self.params.key)
         if item:
             result = {'op':'upd', 'RoleForm': RoleForm(instance=item)}
             self.respond(result)
         else:
             self.status = 'Role does not exists'
             self.redirect(RoleController.get_url())
     else:
         self.status = 'Key not provided'
         self.respond({'op':'ins' ,'RoleForm':RoleForm()})
Пример #8
0
 def insert(self):
     instance = None
     if self.params.key:
         instance = Role.get(self.params.key)
     form = RoleForm(data=self.request.POST, instance=instance)
     if form.is_valid():
         result = form.save(commit=False)
         result.put()
         self.status = 'Role is saved'
         self.redirect(RoleController.get_url())
     else:
         self.SetTemplate(templateName='Role_shw.html')
         self.status = 'Form is not Valid'
         result = {'op': 'upd', 'RoleForm': form}
         self.respond(result)
Пример #9
0
 def save(self):
     instance = None
     if self.params.key:
         instance = Role.get(self.params.key)
     form = RoleForm(data=self.request.POST, instance=instance)
     if form.is_valid():
         result = form.save(commit=False)
         result.put()
         self.status = "Role is saved"
         self.redirect(RoleController.get_url())
     else:
         self.SetTemplate(templateName="Role_shw.html")
         self.status = "Form is not Valid"
         result = {"op": "upd", "RoleForm": form}
         self.respond(result)
Пример #10
0
 def insert(self):
     instance = None
     if self.params.key:
         instance = Role.get(self.params.key)
     form=RoleForm(data=self.request.POST, instance=instance)
     if form.is_valid():
         result=form.save(commit=False)
         result.put()
         self.status = 'Role is saved'
         self.redirect(RoleController.get_url())
     else:
         self.SetTemplate(templateName = 'Role_shw.html')
         self.status = 'Form is not Valid'
         result = {'op':'upd', 'RoleForm': form}
         self.respond(result)