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 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 #6
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}