Esempio n. 1
0
 def get(self, pid):
     pid = int(pid)
     entity = models.Post.get_by_id(pid)
     ctx = context.default
     ctx['title'] = 'Post Modify'
     ctx['form'] = PostForm(instance=entity).as_p()
     html = kit.render(ctx, 'admin', 'postform.html')
     self.response.out.write(html)
Esempio n. 2
0
 def post(self, pid):
     entity = models.Post.get_by_id(int(pid))
     form = PostForm(data=self.request.POST, instance=entity)
     if form.is_valid():
         entity = form.save(commit=False)
         entity.put()
         self.redirect('/admin/post/edit/' + pid)
     else:
         ctx = context.default
         ctx['title'] = 'Post Modify'
         ctx['form'] = form.as_p()
         html = kit.render(ctx, 'admin', 'postform.html')
         self.response.out.write(html)
Esempio n. 3
0
 def post(self):
     data = PostForm(data=self.request.POST)
     if data.is_valid():
         # Save the data, and redirect to the view page
         entity = data.save(commit=False)
         entity.put()
         pid = entity.key().id()
         self.redirect('/admin/post/edit/' + str(pid))
     else:
         ctx = context.default
         ctx['title'] = 'Post Modify'
         ctx['form'] = data.as_p()
         html = kit.render(ctx, 'admin', 'postform.html')
         self.response.out.write(data)
Esempio n. 4
0
 def get(self):
     html = kit.render(context.default,'admin','home.html')
     self.response.out.write(html)
Esempio n. 5
0
 def get(self):
     ctx = context.default
     ctx['title'] = 'Post Modify'
     ctx['form'] = PostForm().as_p()
     html = kit.render(ctx, 'admin', 'postform.html')
     self.response.out.write(html)