def setUp(self): db.create_all() sample1 = Tasks(description='This is a test task') sample2 = Tasks(description='This is a completed task', complete=True) db.session.add(sample1) db.session.commit() db.session.add(sample2) db.session.commit()
def add(): form = TaskForm() if form.validate_on_submit(): new_task = Tasks(task=form.task.data) db.session.add(new_task) db.session.commit() return redirect(url_for('home')) return render_template('add.html', form=form)
def create(): form = TaskForm() if request.method == "POST": if form.validate_on_submit(): new_task = Tasks(description=form.description.data) db.session.add(new_task) db.session.commit() return redirect(url_for("home")) return render_template("add.html", title="Create a Task", form=form)
def create(): form=TaskForm() if request.method == "POST": #(check to see if the method a post request.)post request: send the filled/complete info to the route if form.validate_on_submit():#check if the form validates new_task = Tasks(description = form.description.data) #check if new task has been added with the data db.session.add(new_task) # add the new task to the route db.session.commit() # commit to the data base itself return redirect(url_for("home")) #redirect back to the home page return render_template("add.html", title = "Create a Task", form=form)
def create(): form = TaskForm() if request.method == 'POST': if form.validate_on_submit(): new_task = Tasks(desc=form.desc.data) db.session.add(new_task) db.session.commit() return redirect(url_for('home')) return render_template("add.html", title='Create a task', form=form)
def add(): form = TaskForm() if request.method == "POST": if form.validate_on_submit(): new_task = Tasks(task=form.task.data, status=form.status.data) db.session.add(new_task) db.session.commit() return redirect(url_for("home")) return render_template("add.html", title="Add Task", form=form)
def setUp(self): """ Will be called before every test """ db.create_all() task1 = Tasks(description="My First Task") db.session.add(task1) db.session.commit()
def setUp(self): db.session.commit() db.drop_all() db.create_all() project = Projects(project_name="Testing", owner="Admin", due_date="2020-03-24", start_date="2020-02-17", end_date="2020-03-23", status="Done") task = Tasks(task_name="Phase 1", project_id=1, user="******", due_date="2020-03-24", start_date="2020-02-17", end_date="2020-03-23", status="Done") db.session.add(project) db.session.add(task) project = Projects(project_name="Coding", owner="Admin", due_date="2020-03-24", start_date="2020-02-17", end_date="2020-03-23", status="Done") task = Tasks(task_name="Phase 2", project_id=2, user="******", due_date="2020-03-24", start_date="2020-02-17", end_date="2020-03-23", status="Done") db.session.add(project) db.session.add(task) db.session.commit()
def add(): form = AddTask() if request.method == 'POST': task_name = form.task_name.data task_desc = form.task_desc.data task_stat = form.task_stat.data newtask = Tasks(name=task_name, desc=task_desc, status=task_stat) db.session.add(newtask) db.session.commit() return redirect(url_for('home')) return render_template('add.html', form=form)
def add_task_to_db(user_id, height, width, name_pic, identifier, pic_base64): task = Tasks(name_pic=name_pic[0], height=height[0], width=width[0], pic_base64=pic_base64[0], identifier=identifier, user_id=user_id) db.session.add(task) db.session.commit() return identifier
def setUp(self): """ Will be called before every test """ # Create table db.create_all() # Create test task sample1 = Tasks(name="Testtask", desc='A test task', status='incomplete') # save task to database db.session.add(sample1) db.session.commit()
def test_task(self): user_id = 4 name_pic = 'apple' height = 100 width = 100 done = False identifier = '123456' t1 = Tasks(user_id=user_id, name_pic=name_pic, height=height, width=width, done=done, identifier=identifier) db.session.add(t1) db.session.commit() task = Tasks.query.filter(Tasks.user_id == user_id).first() self.assertEqual(task.name_pic, name_pic) self.assertEqual(task.height, height) self.assertEqual(task.width, width) self.assertEqual(task.done, done) self.assertEqual(task.identifier, identifier)
def addtask(id): project=Projects.query.filter_by(id=id) projectData = project.first() form = TaskForm() form.project_id.data=projectData.project_name if form.validate_on_submit(): taskData = Tasks( task_name=form.task_name.data, user=form.user.data, project_id=id, due_date=form.due_date.data, start_date=form.start_date.data, end_date=form.end_date.data, status=form.status.data, ) db.session.add(taskData) db.session.commit() return redirect(url_for('tasks')) else: print(form.errors) return render_template('addtask.html', title='Add Task', form=form)
def setUp(self): # Set up the database schema(table). db.create_all() # Create table test_task = Tasks( description="Test the flask app") # create a new class >>same<< db.session.add(test_task) # save users to database db.session.commit()
from application.models import db, Tasks db.drop_all() db.create_all() test = Tasks(description="finally works kmt") db.session.add(test) db.session.commit()
def setUp(self): db.create_all() test_task = Tasks(description="Test the flask app") db.session.add(test_task) db.session.commit()
def add(newtask): new_task= Tasks(name=newtask) db.session.add(new_task) db.session.commit() return "New task added"
def setUp(self): db.create_all() sample1 = Tasks(desc="Eat cheese") db.session.add(sample1) db.session.commit()