def edit(self, *args):
     if len(args)>1 and args[1]:
         item = Profile.gql("WHERE ProfileName = :p", p=args[1]).get()
         if item:
             return {'op':'update', 'ProfileForm': ProfileForm(instance=item)}
         else:
             self.status = 'Profile does not exists'
             self.redirect(ProfileController.get_url(args[1]))
     else:
         return {'op':'insert' ,'ProfileForm':ProfileForm()}
 def delete(self,*args):    
     if args[1]:
         item = Profile.gql("WHERE ProfileName= :p", p=args[1]).get()
         if item:
             item.delete()
             self.status ='Profile is deleted!'
         else:
             self.status='Profile does not exist'
     else:
         self.status = 'Key was not Provided!'
     self.redirect(ProfileController.get_url())
Example #3
0
 def delete(self, *args):
     if args[1]:
         item = Profile.gql("WHERE ProfileName= :p", p=args[1]).get()
         if item:
             item.delete()
             self.status = 'Profile is deleted!'
         else:
             self.status = 'Profile does not exist'
     else:
         self.status = 'Key was not Provided!'
     self.redirect(ProfileController.get_url())
Example #4
0
 def edit(self, *args):
     if len(args) > 1 and args[1]:
         item = Profile.gql("WHERE ProfileName = :p", p=args[1]).get()
         if item:
             return {
                 'op': 'update',
                 'ProfileForm': ProfileForm(instance=item)
             }
         else:
             self.status = 'Profile does not exists'
             self.redirect(ProfileController.get_url(args[1]))
     else:
         return {'op': 'insert', 'ProfileForm': ProfileForm()}
 def index(self, *args):
     self.SetTemplate(templateName="Profile_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 = {'ProfileList': Profile.all().fetch(limit=count, offset=index)}
     result.update(locals())
     return result
 def save(self, *args):
     instance = None
     if args[1]:
         instance = Profile.gql("WHERE ProfileName = :p", p=args[1]).get()
     form=ProfileForm(data=self.request.POST, instance=instance)
     if form.is_valid():
         result=form.save(commit=False)
         result.put()
         self.status = 'Profile is saved'
         self.redirect(ProfileController.get_url(result.ProfileName))
     else:
         self.SetTemplate(templateName = 'Profile_edit.html')
         self.status = 'Form is not Valid'
         return {'op':'update', 'ProfileForm': form}
Example #7
0
 def save(self, *args):
     instance = None
     if args[1]:
         instance = Profile.gql("WHERE ProfileName = :p", p=args[1]).get()
     form = ProfileForm(data=self.request.POST, instance=instance)
     if form.is_valid():
         result = form.save(commit=False)
         result.put()
         self.status = 'Profile is saved'
         self.redirect(ProfileController.get_url(result.ProfileName))
     else:
         self.SetTemplate(templateName='Profile_edit.html')
         self.status = 'Form is not Valid'
         return {'op': 'update', 'ProfileForm': form}
Example #8
0
 def index(self, *args):
     self.SetTemplate(templateName="Profile_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 = {
         'ProfileList': Profile.all().fetch(limit=count, offset=index)
     }
     result.update(locals())
     return result