def wikipageview(pagetitle): if(not is_pagetitle_valid(pagetitle)): abort(404) page = get_page(pagetitle) data = { "pagetitle": pagetitle } if(page is not None): data["page"] = page return render_template('wikipage.view.html', data=data)
def wikipagesave(pagetitle): if(not is_pagetitle_valid(pagetitle)): abort(404) try: page = get_page(pagetitle) if(page is not None): page.content = request.form['content'] else: page = models.WikiPage(request.form['content']) page.save() return redirect('/' + page.title) except ValidationError as e: # Here set field Error and make a POST request to /edit return "ValidationError: " + e.message, 500
def wikipageedit(pagetitle): if(not is_pagetitle_valid(pagetitle)): abort(404) data = { "pagetitle": pagetitle } if(request.method == 'POST'): data['content'] = request.form['content'] else: page = get_page(pagetitle) if(page is not None): data["page"] = page return render_template('wikipage.edit.html', data=data)
def test_query_page(self): a = models.WikiPage("# Hello") a.save() self.assertIsNotNone(models.get_page("Hello")) self.assertIsNone(models.get_page("Lolilol"))