예제 #1
0
파일: views.py 프로젝트: iamrizvan/contacts
def delete(request, pk):
    contact = Contact.objects.get(id=pk)
    context = {'contact': contact}
    if request.method == 'POST':
        contact.delete()
        return redirect('/')
    return render(request, 'delete.html', context)
예제 #2
0
def menu():
    FILENAME = 'test.txt'
    while True:
        display_menu()
        response = input('Choose from menu please\n> ')

        if response == '1':
            name = input('Name: ')
            phone = input('Phone: ')
            r = contact.create(FILENAME, name, phone)
            if r:
                print('succ')
            else:
                print('not succ')
        elif response == '2':
            display_contact(FILENAME)
        elif response == '3':
            name = input('Name to update: ')
            contacts = contact.read(FILENAME)
            found = contact.find(contacts, name)
            if found:
                print('Found')
                print('Enter new info to update')
                new_name = input('New Name: ')
                new_phone = input('New Phone: ')
                new_contact = '{}:{}\n'.format(new_name, new_phone)
                updated_contacts = contact.update(contacts, found, new_contact)
                if updated_contacts:
                    contact.write(FILENAME, updated_contacts)
                    print('succ')
                else:
                    print('not updated')
            else:
                print('not found')
        elif response == '4':
            name = input('Name to update: ')
            contacts = contact.read(FILENAME)
            result = contact.delete(contacts, name)
            if result:
                contact.write(FILENAME, result)
            else:
                print('not deleted')

        elif response == '5':
            name = input('Name to update: ')
            contacts = contact.read(FILENAME)
            found = contact.find(contacts, name)
            if found:
                print('Found', found)
            else:
                print('not found')

        elif response == '6':
            break
예제 #3
0
cursor = conn.cursor()
cursor.execute('create table if not exists contacts(name text,number integer )')
cursor.close()

i=-1
while i!=6:
    print("Choose : \n1.Add contact\n2.Update Contact\n3.Delete Contact\n4.print\n5.serch\n6.exit\n")
    i=int(input("Enter Your Choice:"))
    if i==1:
        name=input("Enter Name:")
        num=int(input("Enter Number:"))
        contact.insert(conn,name,num)
    elif i==2:
        name=input("Enter Name:")
        num=int(input("Enter Number:"))
        contact.update(conn, name, num)
    elif i==3:
        name=input("Enter Name:")
        contact.delete(conn, name)
    elif i==4:
        contact.serch(conn)
    elif i==5:
        ip=input("Enter value:")
        contact.userview(conn,ip)
    elif i==6:
        contact.close(conn)
    else:
        print('input should be between 1 to 6 only')


예제 #4
0
def delete_ui():
    name = input('Name to update: ')
    res = contact.delete(name)
    print(res)
예제 #5
0
import sqlite3
import contact

db = sqlite3.connect("contacts.db")
contact.create_table(db)
print("Select one:")
while True:
    print(
        "1.Add contact\n2.Update Contact\n3.Delete Contact\n4.print\n5.userview\n6.exit\n"
    )
    i = int(input("Enter Your Choice:"))
    if i == 1:
        name = input("Enter Name:")
        num = int(input("Enter Number:"))
        contact.insert(db, name, num)
    elif i == 2:
        name = input("Enter Name:")
        num = int(input("Enter Number:"))
        contact.update(db, name, num)
    elif i == 3:
        name = input("Enter Name:")
        contact.delete(db, name)
    elif i == 4:
        contact.view(db)
    elif i == 5:
        ip = input("Enter value:")
        contact.userview(db, ip)
    elif i == 6:
        exit()

db.close()