Esempio n. 1
0
 def collection_post(self):
     request = self.request
     db = request.db
     with transaction.manager:
         st = SiteText()
         st.name = request.json['name']
         st.content = request.json['content']
         st.type = 'tutwiki'
         db.add(st)
     st = db.merge(st)
     data = st.serialize()
     data['result'] = 'success'
     return data
Esempio n. 2
0
 def _edit_form_submitted(self, name, page=None):
     edit_page = True
     session = DBSession()
     body = self.request.params['body']
     now = datetime.now()
     if page is None:
         edit_page = False
         page = SiteText(name, body, type='tutwiki')
         page.created = now
     else:
         page.content = body
     page.modified = now
     with transaction.manager:
         session.add(page)
     location = self.url(route='view_page', pagename=name)
     self.response = HTTPFound(location=location)        
Esempio n. 3
0
 def create_site_text(self):
     self._set_menu()
     form = self._edit_site_text_form()
     # check submission
     if 'submit_site_text' in self.request.params:
         valid = self._validate_site_text(form, create=True)
         if not valid:
             return
         transaction.begin()
         entry = SiteText(valid['name'], valid['content'])
         self.request.db.add(entry)
         transaction.commit()
         self.layout.content = 'Submitted for approval.'
     else:
         self.layout.content = form.render()
         self.layout.subheader = 'Please edit content'