Commit dd5fd7c1 authored by Arhan Banerjee's avatar Arhan Banerjee
Browse files

Added further commands

parent 352dc4a8
import mysql.connector as mysql
from datetime import datetime
......@@ -20,13 +21,55 @@ tables = cursor.fetchall()
print(tables)
'''
# Get max Recipe ID
# if param is 0, then ask user for which recipe/review
def splitter(input_string, tag):
temp_list = input_string.split(",")
output_list = [item.strip(" ") for item in temp_list]
if(tag):
output_list = [sub.replace(' ', '-') for sub in output_list]
return output_list
def create_recipe():
print("creating recipe")
recipe_name = input("Enter recipe name: ")
# recipeID = recipeID + 1
minutes_taken = input("Enter minutes taken (as an integer): ")
contributor = 2 # Member role
date_submitted = datetime.today().strftime('%Y-%m-%d')
tag_input = input("Enter tags seperated by commas: ")
tag_list = splitter(tag_input, True)
calories = input("Enter calorie count: ")
print("\nFor the further nutritional information inputs below, please enter the Percent Daily Value of the nutrient.")
print("Ex. sugar: 20\n")
fat = input("Enter total fat: ")
sugar = input("Enter sugar: ")
sodium = input("Enter sodium: ")
protein = input("Enter protein: ")
saturated_fat = input("Enter saturated fat: ")
carbs = input("Enter carbohydrates: ")
steps_count = input("Enter number of steps in recipe: ")
steps = input("Enter recipe steps seperated by commas: ")
description = input("Enter recipe description: ")
ingredients_count = input("Enter number of ingredients: ")
ingredients = input("Enter ingredients seperated by commas: ")
ingredient_list = splitter(ingredients, False)
def create_review(recipe_id):
print("creating review")
# 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: ")
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")
......@@ -35,10 +78,22 @@ def edit_review(review_id):
print("editing review")
def delete_recipe(recipe_id):
print("deleting recipe")
def delete_review(review_id):
print("deleting review")
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
check = input("Are you sure you want to delete this review? (y/n): ")
if(check == "y"):
# SQL code
print("deleting")
def search():
search_command = ""
......@@ -47,7 +102,67 @@ def 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(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("\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 part or full recipe name to search by: ")
# SQL code
elif(search_command == "Minutes"):
search_attribute = input("Enter max number of minutes taken for a recipe: ")
# SQL code
elif(search_command == "Tags"):
search_attribute = input("Enter tags seperated by commas to search by: ")
tag_list = splitter(search_attribute, True)
print(tag_list)
# SQL code
elif(search_command == "Calories"):
search_attribute = input("Enter max calorie count to search by: ")
# SQL code
elif(search_command == "Fat"):
search_attribute = input("Enter max fat count to search by: ")
# SQL code
elif(search_command == "Sugar"):
search_attribute = input("Enter max sugar count to search by: ")
# SQL code
elif(search_command == "Sodium"):
search_attribute = input("Enter max sodium count to search by: ")
# SQL code
elif(search_command == "Protein"):
search_attribute = input("Enter max protein count to search by: ")
# SQL code
elif(search_command == "Saturated Fat"):
search_attribute = input("Enter max saturated fat to search by: ")
# SQL code
elif(search_command == "Carbs"):
search_attribute = input("Enter max carbohydrates count to search by: ")
# SQL code
elif(search_command == "Steps Count"):
search_attribute = input("Enter max number of steps to search by: ")
# SQL code
elif(search_command == "Ingredients"):
search_attribute = input("Enter ingredients seperated by commas to search by: ")
ingredient_list = splitter(search_attribute, False)
print(ingredient_list)
# SQL code
elif(search_command == "Ingredients Count"):
search_attribute = input("Enter max number of ingredients to search by: ")
# SQL code
elif(search_command == "Rating"):
search_attribute = input("Enter minimum rating to search by: ")
# SQL code
elif(search_command == "RecipeID"):
search_attribute = input("Enter a RecipeID to search by: ")
# SQL code
elif(search_command == "UserID"):
search_attribute = input("Enter an UserID to search by: ")
# SQL code
elif(search_command == "End search"):
continue
else:
print("\nError: attribute not found\n")
......@@ -104,9 +219,9 @@ 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("0")
elif(edit_command == 2):
edit_review(0)
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.")
......@@ -115,18 +230,22 @@ def main():
if(create_command == 1):
create_recipe()
elif(create_command == 2):
create_review(0)
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)
delete_recipe("0")
elif(delete_command == 2):
delete_review(0)
delete_review("0")
elif (command == "search"):
search()
elif (command == "quit"):
continue
else:
print("Error: Not a valid command")
......
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