-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_menu.py
83 lines (58 loc) · 1.96 KB
/
start_menu.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import database
from admin_menu import admin_menu
from logged_menu import logged_menu
def start_menu():
print("Hello and welcome to NomNom Food Delivery!!")
print("If you want to order please register or login")
while True:
command = input("Enter command or 'help' to see all commands>")
if command == 'help':
help()
elif command == 'exit':
break
elif command == 'register':
register()
elif command == 'login':
login()
elif command == 'admin':
admin()
else:
print("You have entered an invalid command")
def help():
print("command 'login' - if you already have an account")
print("command 'register' - if you want to create new account")
print("command 'exit' - if you want to close the program")
print("command 'admin' - if you have admin rights")
def register():
username = input("Username: ")
password = input("Password: ")
address = input("Address(Don't worry, you could change it later):")
is_registered = database.register(username, password, address)
if is_registered:
print("Registration Successful")
else:
print("That username has already been taken")
def login():
username = input("Valid username: ")
password = input("Valid password: ")
valid_user = database.login(username, password)
if valid_user:
logged_menu(valid_user)
else:
print("Invalid username or password, please try again")
def admin():
print("You are trying to access admin account")
admin_password = input('Admin password:')
is_admin = database.admin(admin_password)
if is_admin:
admin_menu()
else:
print("Sorry, wrong admin password")
def main():
database.create_users_table()
database.create_restaurant_table()
database.create_orders_table()
database.create_taxes_table()
start_menu()
if __name__ == '__main__':
main()