def send_mail(request, todo_id): todo_id = int(todo_id) todo = Todo.get_by_id(todo_id) message = mail.EmailMessage(sender=request.user.email, subject=todo.shortDescription) message.to = request.user.email message.body = todo.longDescription message.send() request.redirect("go back")
def add_entry(): if not session.get('logged_in'): abort(401) form = TodoForm(request.form) if request.method == 'POST' and form.validate(): db.session.add( Todo(title=request.form['title'], text=request.form['text'])) db.session.commit() flash('成功推送新的任务!') return redirect(url_for('todo.show_entries')) else: flash('请填写标题和内容!') return redirect(url_for('todo.show_entries'))
def create_todo(self, task_name, task_status): todo = Todo(task_name, task_status) db.session.add(todo) db.session.commit() return todo
def todo_list(request, on_page=10, page=1, finished=False): todos = Todo.gql("WHERE author = :1 and finished = :2", request.user, finished) return request.render("todo/todo_list", todos=todos, todos_pages=todos.count())
def delete_todo(request, todo_id): todo_id = int(todo_id) todo = Todo.get_by_id(todo_id) todo.delete() return request.redirect("go back")