def post(self): form = CreateTodoForm() if form.validate_on_submit(): data = get_dict(request.form, 'topic', 'start', 'end', 'desc') todo = Todo(**data) todo.poster = ObjectId(session["user_id"]) try: todo.save() except: return redirect(url_for('todo.create')) return redirect(url_for('todo.list'))
def createTodo(self, payload): auth = sec.context.get_auth() newTodo = Todo( title=payload.get("title"), description=payload.get("description"), createdBy=auth.user_id ) try: newTodo.save() except ValidationError as error: errorMessage = { "msg": str(error) } return json.dumps(errorMessage) return newTodo.to_json()
def add(): form = request.form t = Todo(form) t.save() return redirect(url_for('todo.index'))