Ejemplo n.º 1
0
 def get(self, page_id=None, **kwargs):
     """Return a page to edit or an empty form to create"""
     template = 'admin/page/new.html'
     context = {
         'form': self.form,
     }
     # render edit
     if page_id is not None:
         page = Page.get_by_id(page_id)
         if page:
             self.form = PageForm(obj=page)
             context.update({ 'form': self.form })
             template = 'admin/page/edit.html'
         else:
             return redirect('admin/page/')
     # render new
     return self.render_response(template, **context)
Ejemplo n.º 2
0
 def get(self, page_id=None, **kwargs):
     """Return a page to edit or an empty form to create"""
     template = 'admin/page/new.html'
     context = {
         'form': self.form,
     }
     # render edit
     if page_id is not None:
         page = Page.get_by_id(page_id)
         if page:
             self.form = PageForm(obj=page)
             context.update({'form': self.form})
             template = 'admin/page/edit.html'
         else:
             return redirect('admin/page/')
     # render new
     return self.render_response(template, **context)
Ejemplo n.º 3
0
 def post(self, page_id=None, **kwargs):
     """Handle submitted form data"""
     # validate form
     if self.form.validate():
         title = self.form.title.data
         content = self.form.content.data
         live = self.form.live.data
         language = self.form.language.data
         # saving edited
         if page_id:
             page = Page.get_by_id(page_id)
             page.title = title
             page.content = content
             page.live = live
             page.language = language
         # creating new
         else:
             page = Page(title=title, content=content, live=live, language=language)
         if page.put():
             return redirect('admin/page')
     return self.get(**kwargs)
Ejemplo n.º 4
0
 def post(self, page_id=None, **kwargs):
     """Handle submitted form data"""
     # validate form
     if self.form.validate():
         title = self.form.title.data
         content = self.form.content.data
         live = self.form.live.data
         language = self.form.language.data
         # saving edited
         if page_id:
             page = Page.get_by_id(page_id)
             page.title = title
             page.content = content
             page.live = live
             page.language = language
         # creating new
         else:
             page = Page(title=title,
                         content=content,
                         live=live,
                         language=language)
         if page.put():
             return redirect('admin/page')
     return self.get(**kwargs)