Example #1
0
 def post(self, pid):
     form = PageAddForm(self)
     current = self.db.query(Post).get(pid)
     form.parent.query = self.db.query(Post).filter(Post.status=='enabled').filter(Post.parent==0).filter(Post.id!=current.id).filter(Post.type=='page').order_by(Post.title)
     if form.validate():
         current.title = form.title.data
         current.content = form.description.data
         current.parent = form.parent.data.id if form.parent.data else 0
         current.order = form.order.data
         self.db.commit()
         return self.redirect('/admin/page/list')
     return self.render("admin/page_edit.html",form=form, current=current)
Example #2
0
 def post(self, pid):
     form = PageAddForm(self)
     current = self.db.query(Post).get(pid)
     form.parent.query = self.db.query(Post).filter(
         Post.status == 'enabled').filter(Post.parent == 0).filter(
             Post.id != current.id).filter(Post.type == 'page').order_by(
                 Post.title)
     if form.validate():
         current.title = form.title.data
         current.content = form.description.data
         current.parent = form.parent.data.id if form.parent.data else 0
         current.order = form.order.data
         self.db.commit()
         return self.redirect('/admin/page/list')
     return self.render("admin/page_edit.html", form=form, current=current)
Example #3
0
 def get(self):
     form = PageAddForm(self)
     form.parent.query = self.db.query(Post).filter_by(type='page',
                                                       status='enabled',
                                                       parent=0).order_by(
                                                           Post.title)
     return self.render('admin/page_add.html', form=form)
Example #4
0
 def post(self):
     form = PageAddForm(self)
     form.parent.query = self.db.query(Post).filter_by(type='page', status='enabled',parent=0).order_by(Post.title)
     if form.validate():
         title = form.title.data
         desc = form.description.data
         parent = form.parent.data.id if form.parent.data else 0
         order = form.order.data if form.parent.data else 0
         page = Post(title=title, content=desc, parent=parent, type='page',
                     author=self.current_user.id, status='enabled',
                     authorname=self.current_user.displayname,
                     order=order,
                     comment_count=0)
         self.db.add(page)
         self.db.commit()
         return self.redirect('/admin/page/list')
     return self.render("admin/page_add.html",form=form)
Example #5
0
 def get(self, pid):
     form = PageAddForm(self)
     current = self.db.query(Post).get(pid)
     #form.parent.query = self.db.query(Page).filter(Page.status=='enabled',Page.parent==0,Page.id!=current.id).order_by(Page.title)
     form.title.process_data(current.title)
     form.description.process_data(current.content)
     form.order.process_data(current.order)
     form.parent.process_data(self.db.query(Post).get(current.parent))
     form.parent.query = self.db.query(Post).filter(
         Post.status == 'enabled').filter(Post.parent == 0).filter(
             Post.id != current.id).filter(Post.type == 'page').order_by(
                 Post.title)
     return self.render('admin/page_edit.html', form=form, current=current)
Example #6
0
 def post(self):
     form = PageAddForm(self)
     form.parent.query = self.db.query(Post).filter_by(type='page',
                                                       status='enabled',
                                                       parent=0).order_by(
                                                           Post.title)
     if form.validate():
         title = form.title.data
         desc = form.description.data
         parent = form.parent.data.id if form.parent.data else 0
         order = form.order.data if form.parent.data else 0
         page = Post(title=title,
                     content=desc,
                     parent=parent,
                     type='page',
                     author=self.current_user.id,
                     status='enabled',
                     authorname=self.current_user.displayname,
                     order=order,
                     comment_count=0)
         self.db.add(page)
         self.db.commit()
         return self.redirect('/admin/page/list')
     return self.render("admin/page_add.html", form=form)
Example #7
0
 def get(self):
     form = PageAddForm(self)
     pages = self.db.query(Post).filter_by(type='page').all()
     return self.render('admin/page.html', form=form, pages=pages)