Ejemplo n.º 1
0
def index():

    form = TaskForm()

    if form.validate_on_submit():
        data = {}
        data['email'] = form.email.data
        data['firstname'] = form.firstname.data
        data['lastname'] = form.lastname.data
        data['message'] = form.message.data
        duration = int(form.duration.data)
        duration_unit = form.duration_unit.data

        if duration_unit == 'minutes':
            duration = 60
        elif duration_unit == 'hours':
            duration = 3600
        elif duration_unit == 'days':
            duration = 86400

        send_mail.apply_async(args=[data], cuntdown=duration)
        flash(
            f"Email will be sent to  {data['email']} in {duration} {duration_unit}"
        )

        return redirect(url_for('index'))

    return render_template('index.html', form=form)
Ejemplo n.º 2
0
def add_task():
    task = TaskForm()
    if task.validate_on_submit():
        ## 获取数据
        FormData = task.data
        ### 保存数据,需在数据库中建立模型
    else:

        error = task.errors
    return render_template('add_task.html', **locals())
Ejemplo n.º 3
0
def add():
    if not current_user.confirmed:
        return redirect(url_for('unconfirmed'))
    form = TaskForm()
    if form.validate_on_submit():
        task = Task(current_user.id, form.title.data, form.status.data)
        db.session.add(task)
        db.session.commit()
        flash("Add one task.")
        return redirect(url_for("index"))
    return render_template("add.html", form=form)
Ejemplo n.º 4
0
def addtask():
	Taskform = TaskForm()
	if Taskform.is_submitted():
		dt = Taskform.taskdate.data
		if dt < datetime.date(datetime.today()):
			return jsonify({'Error' : 'Can not add task for past' })

		task = Tasks(user = current_user,text = Taskform.text.data, date = dt,category = Taskform.category.data)
		db.session.add(task)
		db.session.commit()
		return jsonify({'Success' : 'Task Added to your calender','id' : task.id })
	return jsonify({'Error' : 'Something Went Wrong, Try Again!','id' : task.id })
Ejemplo n.º 5
0
def add_task():
    task = TaskForm()
    error = {}
    if request.method == 'POST':
        if task.validate_on_submit():
            # 获取数据
            FormData = task.data
    #     保存数据   数据库当中 建立模型
        else:

            error = task.errors
        print(error)
    return render_template('add_task.html', **locals())
Ejemplo n.º 6
0
def change(article_id):
    if not current_user.confirmed:
        return redirect(url_for('unconfirmed'))
    form = TaskForm()
    task = Task.query.filter_by(id=article_id).first_or_404()
    if form.validate_on_submit():
        task.title = form.title.data
        task.status = form.status.data
        db.session.add(task)
        db.session.commit()
        return redirect(url_for("index"))
    form.title.data = task.title
    form.status.data = task.status
    return render_template("modify.html", form=form)
Ejemplo n.º 7
0
def home():
	Taskform = TaskForm()
	DatePostsform = DatePostsForm()
	dt = DatePostsform.date.data
	dt = datetime(dt.year,dt.month,dt.day)
	dt = dt.replace(minute=0, hour=0, second=0, microsecond=0)
	tasks = Tasks.query.filter_by(user = current_user, date = dt)

	return render_template('home.html', tasks = tasks, Taskform = Taskform,DatePostsform = DatePostsform)
Ejemplo n.º 8
0
def add_task():
    task = TaskForm()
    # print(dir(task))
    # print ("csrf_token%s" % task.csrf_token)   ### csrf_token
    # print ("errors %s" % task.errors)      ###错误
    # print (task.validate())      ###  判断是否是一个合法的请求
    # print (task.validate_on_submit())     ### 判断是否是一个有效post、请求
    # print (task.data)    ### 请求的数据
    #
    error = {}
    if request.method == "POST":
        if task.validate_on_submit():    ## 校验
            ## 获取数据数据
            FormData = task.data
            ## 保存数据   数据库当中 建立模型
        else:
            ##
            error = task.errors
    return render_template("add_task.html",**locals())
Ejemplo n.º 9
0
def add_task():
    task = TaskForm()
    #     print(dir(task))
    # print("task.csrf_token%s"%task.csrf_token) ##csrf_token
    # print("task.errors%s"%task.errors)  ###错误
    # print("task.validate%s"%task.validate) ###判断是否是一个合法请求
    # print("task.validate_on_submit%s"%task.validate_on_submit) ##判断是否是一个有效的post 请求
    # print("task.data%s"%task.data)   ##请求的数据

    error = {}
    if request.method == "POST":
        if task.validate_on_submit():
            pass
            # 获取数据
            FromData = task.data
            #保存数据 数据库当中 建立模型
        else:
            error = task.errors
            print(error)
    print(error)
    return render_template('add_task.html', **locals())