def POST(self): from brave.notes.core.session import session form = self.form() error = "" if form.validates(): category = form['category'].value query = dict(user=session.user) query[b'title'] = category cat = Category.objects(**query).first() if not cat: cat = Category(session.user, category) cat.save() raise web.seeother(settings['path'] + '/categories', absolute=True) else: error = "Category already exists!" else: for k in form.inputs: if k.note != None: error = k.note break return render.addcategory(Category.objects.GetCategories(session.user), error)
def GET(self): from brave.notes.core.session import session return render.addcategory(Category.objects.GetCategories(session.user), "")