def add(): # Create a new chore form form = TaskForm() # Check for a POST and validate the form data if form.validate_on_submit(): # Create a new chore with the current user as the parent newTask = Task(parent=ndb.Key("User", users.get_current_user().email())) # Fill in the details and insert it into the database newTask.name = form.name.data newTask.description = form.description.data newTask.points = form.points.data newTask.point_type = form.point_type.data newTask.put() # Automatically redirect the user to the chore list return redirect(url_for('.list')) # If not POSTing then display the default new chore form return render_template('tasks/new_task.html', form=form)