Exemplo n.º 1
0
def create_task():
    description = request.form["description"]
    user_id = request.form["user_id"]
    duration = request.form["duration"]
    completed = request.form["completed"]
    user = user_repository.select(user_id)

    task = Task(description, user, duration, completed)

    task_repository.save(task)

    return redirect('/tasks')


# SHOW                                                  # for showing one thing in detail. {{task.description}} in the html can be placed inside an <a></a> tag
# GET '/tasks/<id>'

# EDIT                                                  # slightly harder code
# GET '/tasks/<id>/edit'

# UPDATE                                                # slightly harder code
# PUT '/tasks/<id>'

# DELETE
# DELETE '/tasks/<id>'
Exemplo n.º 2
0
def create():
    description = request.form['description']
    duration = request.form['duration']
    completed = request.form['completed']
    user_id = request.form['user_id']
    user = user_repository.select(user_id)
    new_task = Task(description, user, duration, completed)
    task_repository.save(new_task)
    return redirect("/tasks")
def create_task():
    # grab all the bits from the form and assign to variables
    description = request.form["description"]
    user_id = request.form["user"]
    duration = request.form["duration"]
    completed = request.form["completed"]
    # find the right user from the database on the user id from data
    user = user_repository.select(user_id)
    #  create a new Task object based on that form data
    task = Task(description, user, duration, completed)
    # save it to the data base - save function from task repository
    task_repository.save(task)
    # redirect back to all tasks view
    return redirect('/tasks')
Exemplo n.º 4
0
import pdb
from models.task import Task
import repositories.task_repository as task_repository

task_repository.delete_all()

task_1 = Task("Walk Dog", "Jack Jarvis", 60)

task_2 = Task("Feed Cat", "Victor McDade", 5)

print(task_1.__dict__)

task_repository.save(task_1)

res = task_repository.select_all()

for task in res:
    print(task.__dict__)

pdb.set_trace()
import pdb
from models.task import Task
from models.user import User
import repositories.task_repository as task_repository
import repositories.user_repository as user_repository

task_repository.delete_all()
user_repository.delete_all()

jack = User("Jack", "Jarvis")
user_repository.save(jack)

victor = User("Victor", "McDade")
user_repository.save(victor)

dishes = Task("Do the dishes", jack, 4)
task_repository.save(dishes)

feed_cat = Task("Feed the cat", jack, 3)
task_repository.save(feed_cat)

pdb.set_trace()