Commit 98214a3b authored by Arhan Banerjee's avatar Arhan Banerjee
Browse files

Updated adding remaining commands

parent dd5fd7c1
......@@ -35,11 +35,11 @@ def splitter(input_string, tag):
return output_list
def create_recipe():
def create_recipe(user_id):
recipe_name = input("Enter recipe name: ")
# recipeID = recipeID + 1
minutes_taken = input("Enter minutes taken (as an integer): ")
contributor = 2 # Member role
contributor = user_id # Member role
date_submitted = datetime.today().strftime('%Y-%m-%d')
tag_input = input("Enter tags seperated by commas: ")
tag_list = splitter(tag_input, True)
......@@ -59,37 +59,118 @@ def create_recipe():
ingredients = input("Enter ingredients seperated by commas: ")
ingredient_list = splitter(ingredients, False)
def create_review(recipe_id):
def create_review(user_id):
# user can only leave one review per recipe?
contributor = 2
if (recipe_id == "0"):
recipe_id = input("Enter the Recipe ID of the recipe for this review: ")
contributor = user_id
recipe_id = input("Enter the Recipe ID of the recipe for this review: ")
date_submitted = datetime.today().strftime('%Y-%m-%d')
rating = input("Enter a rating for this review (An integer between 0 and 5): ")
review_text = input("Enter any comments about the recipe: ")
def edit_recipe(recipe_id):
print("editing recipe")
def edit_recipe(user_id):
def edit_review(review_id):
print("editing review")
search_command = ""
search_command = input("Enter the Recipe ID of the recipe to be edited: ")
# if recipe_id.user_id == user_id, allow editing, else they are not allowed to edit
while (search_command != "End edit"):
search_command = input("What attribute would you like to edit? (Press 'help' for list of edit commands or 'End edit' to exit): ")
if(search_command == "help"):
print("\nRecipeID\nUserID\nRecipe Name\nMinutes\nTags\nCalories\nFat\nSugar\nSodium\nProtein\nSaturated Fat\nCarbs\nSteps Count\nIngredients\nIngredients Count\nRating\n")
elif(search_command == "Recipe Name"):
search_attribute = input("Enter new recipe name: ")
# SQL code
elif(search_command == "Minutes"):
search_attribute = input("Enter updated number of minutes: ")
# SQL code
elif(search_command == "Tags"):
search_attribute = input("Enter the updated tags seperated by commas: ")
tag_list = splitter(search_attribute, True)
# SQL code
elif(search_command == "Calories"):
search_attribute = input("Enter updated calorie count: ")
# SQL code
elif(search_command == "Fat"):
search_attribute = input("Enter updated fat count: ")
# SQL code
elif(search_command == "Sugar"):
search_attribute = input("Enter updated sugar count: ")
# SQL code
elif(search_command == "Sodium"):
search_attribute = input("Enter updated sodium count: ")
# SQL code
elif(search_command == "Protein"):
search_attribute = input("Enter updated protein count: ")
# SQL code
elif(search_command == "Saturated Fat"):
search_attribute = input("Enter updated saturated fat count: ")
# SQL code
elif(search_command == "Carbs"):
search_attribute = input("Enter updated carbs count: ")
# SQL code
elif(search_command == "Steps Count"):
search_attribute = input("Enter updated steps count: ")
# SQL code
elif(search_command == "Ingredients"):
search_attribute = input("Enter updated ingredients seperated by commas: ")
ingredient_list = splitter(search_attribute, False)
print(ingredient_list)
# SQL code
elif(search_command == "Ingredients Count"):
search_attribute = input("Enter updated ingredients count: ")
# SQL code
elif(search_command == "End edit"):
continue
else:
print("\nError: attribute not found\n")
def edit_review(user_id):
search_command = ""
search_command = input("Enter the Recipe ID of the recipe from which the review is to be edited: ")
# if review_id.user_id == user_id, allow editing, else they are not allowed to edit
while (search_command != "End edit"):
search_command = input("What attribute would you like to edit? (Press 'help' for list of edit commands or 'End edit' to exit): ")
if(search_command == "help"):
print("\nRating\nReview\n")
elif(search_command == "Rating"):
rating = input("Enter an updated rating for this review (An integer between 0 and 5): ")
elif(search_command == "Review"):
review_text = input("Enter updated comments about the recipe: ")
elif(search_command == "End edit"):
continue
else:
print("\nError: attribute not found\n")
def delete_recipe(user_id):
recipe_id = input("Enter the Recipe ID of the recipe to be deleted: ")
# if recipe_id.user_id == user_id, allow deleting, else they are not allowed to edit
def delete_recipe(recipe_id):
if (recipe_id == "0"):
recipe_id = input("Enter the Recipe ID of the recipe to be deleted: ")
check = input("Are you sure you want to delete this recipe? (y/n): ")
if(check == "y"):
# SQL code
print("deleting")
def delete_review(recipe_id):
if (recipe_id == "0"):
recipe_id = input("Enter the Recipe ID of the recipe from which the review is to be deleted: ")
user_id = 2
def delete_review(user_id):
recipe_id = input("Enter the Recipe ID of the recipe from which the review is to be deleted: ")
# if review_id.user_id == user_id, allow deleting, else they are not allowed to delete
check = input("Are you sure you want to delete this review? (y/n): ")
if(check == "y"):
# SQL code
......@@ -193,6 +274,7 @@ def main():
break
elif (user_role == 2):
print("\nSigned in as Member")
user_id = input("Enter an User ID: ")
break
else:
print("\nError logging in. Please select a valid role.")
......@@ -219,27 +301,27 @@ def main():
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")
edit_recipe(user_id)
elif(edit_command == 2):
edit_review("0")
edit_review(user_id)
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()
create_recipe(user_id)
elif(create_command == 2):
create_review("0")
create_review(user_id)
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")
delete_recipe()
elif(delete_command == 2):
delete_review("0")
delete_review()
elif (command == "search"):
search()
elif (command == "quit"):
......
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