Commit 352dc4a8 authored by Arhan Banerjee's avatar Arhan Banerjee
Browse files

Added commands

parent dbcce2f6
......@@ -2,6 +2,7 @@ import mysql.connector as mysql
db = mysql.connect(
host = "marmoset04.shoshin.uwaterloo.ca",
user = "",
......@@ -18,54 +19,118 @@ cursor.execute("show tables;")
tables = cursor.fetchall()
print(tables)
'''
command = ""
user_role = 0
# if param is 0, then ask user for which recipe/review
print('''
def create_recipe():
print("creating recipe")
***************************
_____
/\ / ____| /\
/ \ | | / \
/ /\ \| | / /\ \
/ ____ | |____ / ____ \
/_/ \_\_____/_/ \_\
def create_review(recipe_id):
print("creating review")
***************************
''')
def edit_recipe(recipe_id):
print("editing recipe")
print("Welcome to ACA, the number one stop for all your culinary needs! \nDiscover recipes, reviews, and how-tos from users all around the world right here!")
def edit_review(review_id):
print("editing review")
while(True):
user_role = int(input("\nHow do you want to access the application? (Press 1 for Guest, 2 for Member): "))
def delete_recipe(recipe_id):
print("deleting recipe")
if(user_role == 1):
print("\nSigned in as Guest")
break
elif (user_role == 2):
print("\nSigned in as Member")
break
else:
print("\nError logging in. Please select a valid role.")
def delete_review(review_id):
print("deleting review")
print("Type in 'help' to get list of commands and user role descriptions")
def search():
search_command = ""
while (command != "quit"):
command = input("\nEnter a command: ")
while(search_command != "End search"):
search_command = input("What attribute would you like to search by? (Press 'help' for list of search commands or 'End search' to exit): ")
if (command == "help"):
print("\nUser Roles: \n\nGuest: Only able to view/select items from database.")
print("Member: Able to view, add, delete, and edit items from database\n")
if(search_command == "help"):
print("\nRecipe Name\nMinutes Taken\nTags\nCalorie Count\nTotal Fat Count\nSugar\nSodium\nProtein\nSaturated Fat\nCarbs\nSteps Count\nIngredients\nIngredients Count\nRating")
print("Commands: \n")
print("quit: Terminates the application")
print("edit: Members can add and delete entries from database")
elif (command == "edit"):
if(user_role == 1):
print("\nError: Guest users do not have the permission to edit. Please quit and sign in as a Member to edit.")
def main():
print('''
***************************
_____
/\ / ____| /\
/ \ | | / \
/ /\ \| | / /\ \
/ ____ | |____ / ____ \
/_/ \_\_____/_/ \_\
***************************
''')
print("Welcome to ACA, the number one stop for all your culinary needs! \nDiscover recipes, reviews, and how-tos from users all around the world right here!")
command = ""
user_role = 0
while(True):
user_role = int(input("\nHow do you want to access the application? (Press 1 for Guest, 2 for Member): "))
if(user_role == 1):
print("\nSigned in as Guest")
break
elif (user_role == 2):
print("\nSigned in as Member")
break
else:
print("\nError logging in. Please select a valid role.")
print("Type in 'help' to get list of commands and user role descriptions")
while (command != "quit"):
command = input("\nEnter a command: ")
if (command == "help"):
print("\nUser Roles: \n\nGuest: Only able to view/select items from database.")
print("Member: Able to view, create, delete, and edit items from database\n")
print("Commands: \n")
print("quit: Terminates the application")
print("edit: Members can edit entries from database")
print("create: Members can create entries to input into database")
print("delete: Members can delete entries from database")
print("search: Guests and Members can search the database via specific attributes")
elif (command == "edit"):
if(user_role == 1):
print("\nError: Guest users do not have the permission to edit. Please quit and sign in as a Member to edit.")
elif(user_role == 2):
edit_command = int(input("\nWhat would you like to edit? (Press 1 to edit a recipe, 2 to edit a review): "))
if(edit_command == 1):
edit_recipe(0)
elif(edit_command == 2):
edit_review(0)
elif (command == "create"):
if(user_role == 1):
print("\nError: Guest users do not have the permission to create. Please quit and sign in as a Member to create.")
elif(user_role == 2):
create_command = int(input("\nWhat would you like to create? (Press 1 to create a recipe, 2 to create a review): "))
if(create_command == 1):
create_recipe()
elif(create_command == 2):
create_review(0)
elif (command == "delete"):
if(user_role == 1):
print("\nError: Guest users do not have the permission to delete. Please quit and sign in as a Member to delete.")
elif(user_role == 2):
delete_command = int(input("\nWhat would you like to delete? (Press 1 to delete a recipe, 2 to delete a review): "))
if(delete_command == 1):
delete_recipe(0)
elif(delete_command == 2):
delete_review(0)
elif (command == "search"):
search()
main()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment