예제 #1
0
loop = True
while loop:
    print('''1. New todo
2. View ALL Todos
3. Mark a Todo COMPLETED
4. Delete a Todo
5. Exit''')
    cmd = input("Enter your command? ").upper()
    if cmd == "1":
        name = input("Name: ")
        description = input("Description: ")
        new_todo = Todo(name=name, description=description)
        new_todo.save()
    elif cmd == "2":
        print("= " * 20)
        if Todo.objects().count() == 0:
            print("EMPTY")
        else:
            todo_list = Todo.objects()
            todo_no = 1
            for todo in todo_list:
                print(todo_no, todo, sep=". ")
                todo_no += 1
                print()
        print("= " * 20)
    elif cmd == "3":
        i = int(input("Which one? ")) - 1
        todo_list = Todo.objects()
        todo_list[i].update(set__completed=True)
        print("Updated")
    elif cmd == "4":
예제 #2
0
string = '''
1. New todo
2. View All Todos
3. Mark a Todo Completed
4. Delete a todo
5. Exit
Enter your Command? 
'''
user = int(input(string))
if user == 1:
    n = input("Name: ")
    d = input("Description: ")
    t = Todo(name=n, description=d)
    t.save()
elif user == 2:
    todo_list = Todo.objects()
    if len(todo_list) != 0:
        for i in todo_list:
            print(i.name, i.description, sep='\n')
    else:
        print("Empty")
elif user == 3:
    index = int(input("Which one? "))
    print("Updated")
    records = Todo.objects()
    for r in records:
        if r == index:
            r.update(set__available=True)
elif user == 4:
    index = int(input("Which one? "))
    print("Deleted")