diff --git a/.gitignore b/.gitignore index 35d4cb8..029519e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,2 @@ __pycache__/ -*.py[cod] -.vs -.DS_Store -.DS_Store? -._* -.Spotlight-V100 -.Trashes -ehthumbs.db -Thumbs.db +*.py[cod] \ No newline at end of file diff --git a/Milestones/M2/All M2 docs and files go here, no code should be here b/Milestones/M2/All M2 docs and files go here, no code should be here new file mode 100644 index 0000000..e69de29 diff --git a/Milestones/M4/All M4 docs and files go here, no code should be here b/Milestones/M4/All M4 docs and files go here, no code should be here new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md index 407d03a..c5655f5 100644 --- a/README.md +++ b/README.md @@ -10,42 +10,21 @@ - Gangzhaorige Li - Git Master / Back End Developer ## Live Project Link -[http://fridgeapp9000.com/](http://fridgeapp9000.com/) +[http://ec2-34-224-23-175.compute-1.amazonaws.com](http://ec2-34-224-23-175.compute-1.amazonaws.com) ### Test Server Link [http://ec2-3-91-133-192.compute-1.amazonaws.com](http://ec2-3-91-133-192.compute-1.amazonaws.com) -## Branch Description -All branches other than Master, Dev_Main, and Documentation are dedicated to development of specific features of the application. Within those features are sub features that are also developed within the parent's feature's branch. - -1. Master - - Current deployment of application and full documentation. -2. Dev_Main - - Finished features are pushed here for testing with other features. -3. Auth - - Development of the main landing page, authorization features, and user handling. -4. Fridge - - Fridge Landing - - Tracked Item Editing - - "Hamburger" Sidebar Functionality -5. Grocery - - Grocery landing page - - Manual Item Addition - - Tracked Item display -6. Capture - - Functionality of receipt capture - - Display of receipt contents "receipt review" -7. Recipe - - View saved recipes - - Search recipes -8. Profile - - View friended and owned fridges - - Edit personal notes - - Logout of app -9. Documentation - - This branch used for updating documentation of the application: ReadMe, Milestones, Etc. - - No other commits will be done here except for documentation. - - Should always be a derivative of branch Master. +## Instructor's ReadMe +------------- +Please when ready add your teams application URL or IP to the repository description. This will help with grading. Teams are expected to keep this value up to date. +Please do the following steps before completing Milestone 0. +1. Change the name of the repository. All that needs to change is the NN to your respective team number. Team numbers whose value is less than 10, please pad with a 0. Ex team 1 is Team01 team 11 is Team11. Please make sure to also remove the username from the repository as well. Teams with incorrectly name repository will have points deducted from their milestone 0 grades. + - Please follow the naming convention assigned by your instructor. +1. PLEASE REMOVE THE USERNAME FROM THE REPOSITORY NAME!!! +2. Add ALL members of your team to this repository. For it to count, they must ACCEPT the invite. + +NO code needs to be stored in the root of your repository. You may rename the application folder if you like to your team's application name. But all source code related to your team's application should be stored inside the application folder. diff --git a/application/Django_refrigerator_project/Fridge_9000/settings.py b/application/Django_refrigerator_project/Fridge_9000/settings.py index a57938d..4c3fcf5 100644 --- a/application/Django_refrigerator_project/Fridge_9000/settings.py +++ b/application/Django_refrigerator_project/Fridge_9000/settings.py @@ -25,8 +25,6 @@ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -PROD = False - ALLOWED_HOSTS = ['*'] @@ -40,7 +38,7 @@ 'django.contrib.messages', 'django.contrib.staticfiles', 'refrigerator_app', - 'users', + 'users.apps.UsersConfig', ] MIDDLEWARE = [ @@ -78,28 +76,16 @@ # https://docs.djangoproject.com/en/2.2/ref/settings/#databases -if(PROD): - DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.mysql', - 'NAME': 'ref_updated_10_31', - 'USER': 'admin', - 'PASSWORD': 'password', - 'HOST': 'refrigerator-db.c4p7z07xl4sc.us-east-1.rds.amazonaws.com', - 'PORT': '3306', - } - } -else: - DATABASES = { - 'default': { +DATABASES = { + 'default': { 'ENGINE': 'django.db.backends.mysql', - 'NAME': 'ref_db', - 'USER': 'root', + 'NAME': 'ref_updated_10_31', + 'USER': 'admin', 'PASSWORD': 'password', - 'HOST': 'mysql-db', + 'HOST': 'refrigerator-db.c4p7z07xl4sc.us-east-1.rds.amazonaws.com', 'PORT': '3306', - } } +} # Password validation @@ -126,13 +112,13 @@ LANGUAGE_CODE = 'en-us' -TIME_ZONE = 'America/Los_Angeles' +TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True -USE_TZ = False +USE_TZ = True # Static files (CSS, JavaScript, Images) @@ -146,8 +132,6 @@ '/Django_refrigerator_project/static', ) -MEDIA_ROOT = os.path.join(BASE_DIR,'media') -MEDIA_URL = '/media/' -LOGIN_REDIRECT_URL = 'fridge_init' #need this to redirect to home from login +LOGIN_REDIRECT_URL = 'fridge' #need this to redirect to home from login LOGIN_URL = 'login' #need this for login diff --git a/application/Django_refrigerator_project/Fridge_9000/urls.py b/application/Django_refrigerator_project/Fridge_9000/urls.py index b61185c..dad6aac 100644 --- a/application/Django_refrigerator_project/Fridge_9000/urls.py +++ b/application/Django_refrigerator_project/Fridge_9000/urls.py @@ -18,26 +18,19 @@ from django.conf.urls import include from refrigerator_app import views from recipes import views as recipe_views -from django.contrib.auth import views as auth_views -from users import views as user_views -from refrigerator_app import fridge as fridge_manager - +from django.contrib.auth import views as auth_views #view from django, we will use for our login and logout +from users import views as user_views #view from our users apps urlpatterns = [ path('', views.home, name='home'), - path('fridge/check/', fridge_manager.initialCurrentFridge, name='fridge_init'), - path('fridge/', views.fridge, name='fridge'), - path('add/', views.add_button, name='add_button'), + path('fridge/', views.fridge, name='fridge'), path('groceries/', views.groceries, name='groceries'), - path('recipes/', recipe_views.recipe_landing, name='recipes'), - path('recipes/search/', recipe_views.recipe_search, name='recipe_search'), - path('recipes/search', recipe_views.recipe_search_results, - name='recipe_search_results'), - path('profile/', views.profile, name='profile'), - # path('upload/', views.receipt_upload, name='upload'), - path('auth/register/', user_views.register, name='register'), + path('recipes/', recipe_views.recipe_landing, name='recipes'), + path('recipes/search/', recipe_views.recipe_search, name='recipe_search'), + path('profile/', views.profile, name='profile'), + path('upload/', views.simple_upload, name='upload'), + path('auth/register/', user_views.register, name='register'), #the login and logout views are from Django, not in our views path('auth/login/', auth_views.LoginView.as_view(template_name='users/login.html'), name='login'), - path('auth/logout/', auth_views.LogoutView.as_view( - template_name='users/logout.html'), name='logout'), + path('auth/logout/', auth_views.LogoutView.as_view(template_name='users/logout.html'), name='logout'), path('admin/', admin.site.urls), - path('search/', views.search, name='search') + path('search/', views.search, name='search'), ] diff --git a/application/Django_refrigerator_project/docker-compose.yml b/application/Django_refrigerator_project/docker-compose.yml index ef176c6..6200b36 100644 --- a/application/Django_refrigerator_project/docker-compose.yml +++ b/application/Django_refrigerator_project/docker-compose.yml @@ -1,4 +1,4 @@ -version: '3' +version: '2' services: web: @@ -8,18 +8,3 @@ services: - .:/code ports: - "8000:8000" - depends_on: - - mysql-db - mysql-db: - container_name: mysql-db - image: mysql:5.7 - restart: always - environment: - MYSQL_DATABASE: 'ref_db' - MYSQL_USER: 'root' - MYSQL_PASSWORD: 'password' - MYSQL_ROOT_PASSWORD: 'password' - volumes: - - db_data:/var/lib/mysql -volumes: - db_data: diff --git a/application/Django_refrigerator_project/recipes/views.py b/application/Django_refrigerator_project/recipes/views.py index 6a8d569..223585c 100644 --- a/application/Django_refrigerator_project/recipes/views.py +++ b/application/Django_refrigerator_project/recipes/views.py @@ -1,175 +1,16 @@ -import json -import requests -import refrigerator_app.fridge as fridge_import - from django.shortcuts import render from django.http import HttpResponse from django.conf import settings -from django.contrib.auth.decorators import login_required -from refrigerator_app.models import Item, Fridge, FridgeContent, Recipe -from users.models import User -from django.db.models import Q -from refrigerator_app import views as fridge_views -from django.shortcuts import redirect - -from datetime import datetime -from datetime import timedelta +from django.contrib.auth.decorators import login_required #for using @login_required decorator on top of a function +from refrigerator_app.models import Items +# Create your views here. @login_required def recipe_landing(request): - # Variables - fridge_manager = fridge_import.fridge_manager(request) - context = None - - # Delete Saved Recipes - if request.method == 'POST' and request.POST.get('delete_recipe'): - try: - Recipe.objects.filter( - id=request.POST.get('delete_recipe')).delete() - return redirect('/recipes/') - except: - pass - - # Get Fridge data and saved recipe data - try: - current_fridge = fridge_manager.getCurrentFridge() - saved_recipes = Recipe.objects.filter(fridge_id=current_fridge.id) - context = {'current_fridge': current_fridge, - 'saved_recipes': saved_recipes} - except: - pass - return render(request, 'recipes/recipe_landing.html', context) - + return render(request, 'recipes/recipe_landing.html') @login_required def recipe_search(request): - # Variables - fridge_manager = fridge_import.fridge_manager(request) - current_fridge = fridge_manager.getCurrentFridge() - current_time = datetime.now() - - # Return all items if user has no fridge - try: - inventory_items = fridge_manager.getCurrentFridgeContent() - except: - inventory_items = fridge_manager.getAllItems() - - context = {'current_fridge': current_fridge, - 'inventory_items': inventory_items, - 'current_date': current_time} - return render(request, 'recipes/recipe_search.html', context) - - -@login_required -def recipe_search_results(request): - # Variables - fridge_manager = fridge_import.fridge_manager(request) - current_fridge = None - recipe_data = None - context = None - - # Get refrigerator data - try: - current_fridge = fridge_manager.getCurrentFridge() - context = {'current_fridge': current_fridge} - except: - print('RECIPE_RESULTS VIEW: No Fridge found.') - - # Get recipe results - if request.method == 'GET': - try: - list = request.GET.getlist('ingredient', default=None) - ingredients = "" - for i in list: - ingredients = i + "," + ingredients - #recipe_data = food2fork_call(ingredients) - recipe_data = recipe_puppy(ingredients) - # context = {'current_fridge': current_fridge, - # 'recipes': recipe_data['recipes']} - context = {'current_fridge': current_fridge, - 'recipes': recipe_data} - except: - print('RECIPE_RESULTS VIEW: Error getting food API data.') - - # Save recipes - if request.method == 'POST' and request.POST.get('saved_recipe'): - try: - title, href = request.POST.get( - "saved_recipe").split(",") - - recipe_save = Recipe( - eff_bgn_ts=datetime.now(), - eff_end_ts=datetime(9999, 12, 31), - user_id=request.session['current_user_id'], - fridge_id=request.session['current_fridge_id'], - title=title, - sourceurl=href, - imageurl="" - ) - recipe_save.save() - return redirect('/recipes/') - - except: - print('RECIPE_RESULTS VIEW: Error saving recipe.') - return render(request, 'recipes/recipe_search_results.html', context) - - -def recipe_puppy(list): - - url = "http://www.recipepuppy.com/api/" - - querystring = {"i":list,"p":"30","format":"json"} - - - response = requests.request("GET", url, params=querystring) - - x = response.text - x=json.loads(x) - - # x : data to be retunred - # to the calling function - - x = x["results"] - - #debugging purposes -- tbd ASAP - for item in x: - z = item["title"] - z = z.replace(' ', '') - z = z.replace('\n', '') - print(z,'\n',item["href"]) - - return(x) - - - -def food2fork_call(list): - # Key 1 Attempt - key = '6e81eadfd535b092815e395bcc38be11' - paramsPost = { - 'key': key, - 'q': list, - 'sort': 'r', - 'page': '0' - } - responsePost = requests.post( - 'https://www.food2fork.com/api/search', paramsPost) - - # Key 2 Attempt - if responsePost.text == '{"error": "limit"}': - key = '57604ca61ce33d68532bb9af7f0472f9' - paramsPost = { - 'key': key, - 'q': list, - 'sort': 'r', - 'page': '0' - } - responsePost = requests.post( - 'https://www.food2fork.com/api/search', paramsPost) - - if responsePost.status_code == 202: - print('FOOD2FORK: Data received.') - - # fakePost = '{"count": 30, "recipes": [{"publisher": "Simply Recipes", "f2f_url": "http://food2fork.com/view/36482", "title": "How to Make Fruit Leather", "source_url": "http://www.simplyrecipes.com/recipes/how_to_make_fruit_leather/", "recipe_id": "36482", "image_url": "http://static.food2fork.com/fruitleather300x2001f9f84c4.jpg", "social_rank": 99.99999999999989, "publisher_url": "http://simplyrecipes.com"}, {"publisher": "Simply Recipes", "f2f_url": "http://food2fork.com/view/37128", "title": "Waldorf Salad", "source_url": "http://www.simplyrecipes.com/recipes/waldorf_salad/", "recipe_id": "37128", "image_url": "http://static.food2fork.com/waldorfsalad300x20000f287fd.jpg", "social_rank": 99.9999667957302, "publisher_url": "http://simplyrecipes.com"}, {"publisher": "All Recipes", "f2f_url": "http://food2fork.com/view/15768", "title": "Groovy Green Smoothie", "source_url": "http://allrecipes.com/Recipe/Groovy-Green-Smoothie/Detail.aspx", "recipe_id": "15768", "image_url": "http://static.food2fork.com/4511209622.jpg", "social_rank": 99.97384730336904, "publisher_url": "http://allrecipes.com"}]}' - return json.loads(responsePost.text) - # return json.loads(fakePost) + inventory_items = Items.objects.all() + return render(request, 'recipes/recipe_search.html', context={'inventory_items':inventory_items}) diff --git a/application/Django_refrigerator_project/refrigerator_app/models.py b/application/Django_refrigerator_project/refrigerator_app/models.py index fc1da94..ef84605 100644 --- a/application/Django_refrigerator_project/refrigerator_app/models.py +++ b/application/Django_refrigerator_project/refrigerator_app/models.py @@ -6,58 +6,190 @@ # * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table # Feel free to rename the models, but don't rename db_table values or field names. from django.db import models -from users.models import User -from users.models import AuthUser -from django.db.models import IntegerField, Model, CharField -from django_mysql.models import ListTextField, ListCharField -class Fridge(models.Model): +class AuthGroup(models.Model): + name = models.CharField(unique=True, max_length=150) + + class Meta: + managed = False + db_table = 'auth_group' + + +class AuthGroupPermissions(models.Model): + group = models.ForeignKey(AuthGroup, models.DO_NOTHING) + permission = models.ForeignKey('AuthPermission', models.DO_NOTHING) + + class Meta: + managed = False + db_table = 'auth_group_permissions' + unique_together = (('group', 'permission'),) + + +class AuthPermission(models.Model): + name = models.CharField(max_length=255) + content_type = models.ForeignKey('DjangoContentType', models.DO_NOTHING) + codename = models.CharField(max_length=100) + + class Meta: + managed = False + db_table = 'auth_permission' + unique_together = (('content_type', 'codename'),) + + +class AuthUser(models.Model): + password = models.CharField(max_length=128) + last_login = models.DateTimeField(blank=True, null=True) + is_superuser = models.IntegerField() + username = models.CharField(unique=True, max_length=150) + first_name = models.CharField(max_length=30) + last_name = models.CharField(max_length=150) + email = models.CharField(max_length=254) + is_staff = models.IntegerField() + is_active = models.IntegerField() + date_joined = models.DateTimeField() + + class Meta: + managed = False + db_table = 'auth_user' + + +class AuthUserGroups(models.Model): + user = models.ForeignKey(AuthUser, models.DO_NOTHING) + group = models.ForeignKey(AuthGroup, models.DO_NOTHING) + + class Meta: + managed = False + db_table = 'auth_user_groups' + unique_together = (('user', 'group'),) + + +class AuthUserUserPermissions(models.Model): + user = models.ForeignKey(AuthUser, models.DO_NOTHING) + permission = models.ForeignKey(AuthPermission, models.DO_NOTHING) + + class Meta: + managed = False + db_table = 'auth_user_user_permissions' + unique_together = (('user', 'permission'),) + + +class DjangoAdminLog(models.Model): + action_time = models.DateTimeField() + object_id = models.TextField(blank=True, null=True) + object_repr = models.CharField(max_length=200) + action_flag = models.PositiveSmallIntegerField() + change_message = models.TextField() + content_type = models.ForeignKey('DjangoContentType', models.DO_NOTHING, blank=True, null=True) + user = models.ForeignKey(AuthUser, models.DO_NOTHING) + + class Meta: + managed = False + db_table = 'django_admin_log' + + +class DjangoContentType(models.Model): + app_label = models.CharField(max_length=100) + model = models.CharField(max_length=100) + + class Meta: + managed = False + db_table = 'django_content_type' + unique_together = (('app_label', 'model'),) + + +class DjangoMigrations(models.Model): + app = models.CharField(max_length=255) name = models.CharField(max_length=255) - owner = models.ForeignKey(User, models.DO_NOTHING, related_name='fridges') - friends = ListTextField(base_field=IntegerField(), default=[]) - auto_gen_grocery_list = ListTextField( - base_field=CharField(max_length=15), default=[]) - manually_added_list = ListTextField( - base_field=CharField(max_length=15), default=[]) + applied = models.DateTimeField() + + class Meta: + managed = False + db_table = 'django_migrations' + + +class DjangoSession(models.Model): + session_key = models.CharField(primary_key=True, max_length=40) + session_data = models.TextField() + expire_date = models.DateTimeField() + + class Meta: + managed = False + db_table = 'django_session' + + + +class Fridge(models.Model): + fridgeid = models.AutoField(db_column='FridgeID', primary_key=True) # Field name made lowercase. + fridgename = models.CharField(db_column='FridgeName', max_length=255) # Field name made lowercase. + owner = models.ForeignKey('Users', models.DO_NOTHING, db_column='Owner') # Field name made lowercase. + friends = models.TextField(db_column='Friends', null=True) # Field name made lowercase. + auto_gen_grocery_list = models.TextField(db_column='Auto_gen_grocery_list', blank=True, null=True) # Field name made lowercase. + manually_added_list = models.TextField(db_column='Manually_added_list', blank=True, null=True) # Field name made lowercase. creation_date = models.DateTimeField() modified_date = models.DateTimeField() eff_bgn_ts = models.DateTimeField() eff_end_ts = models.DateTimeField() + class Meta: + managed = False + db_table = 'Fridge' -class Item(models.Model): - name = models.CharField(max_length=255) - age = models.BigIntegerField(blank=True, null=True) - isperishable = models.IntegerField() - calories = models.IntegerField(blank=True, null=True) + +class FridgeContents(models.Model): + fridgeid = models.ForeignKey(Fridge, models.DO_NOTHING, db_column='FridgeID') # Field name made lowercase. + itemid = models.ForeignKey('Items', models.DO_NOTHING, db_column='ItemID') # Field name made lowercase. + addedby = models.ForeignKey('Users', models.DO_NOTHING, db_column='AddedBy') # Field name made lowercase. + expirationdate = models.DateTimeField(db_column='ExpirationDate') # Field name made lowercase. + size = models.IntegerField(db_column='Size', blank=True, null=True) # Field name made lowercase. creation_date = models.DateTimeField() modified_date = models.DateTimeField() eff_bgn_ts = models.DateTimeField() eff_end_ts = models.DateTimeField() + class Meta: + managed = False + db_table = 'Fridge_Contents' -class FridgeContent(models.Model): - fridge = models.ForeignKey( - Fridge, models.DO_NOTHING, related_name='fridge_contents') - item = models.ForeignKey(Item, models.DO_NOTHING, - related_name='fridge_content') - addedby = models.ForeignKey( - User, models.DO_NOTHING, related_name='fridge_contents') - expirationdate = models.DateTimeField() - size = models.IntegerField(blank=True, null=True) + +class Items(models.Model): + itemid = models.AutoField(db_column='ItemID', primary_key=True) # Field name made lowercase. + itemname = models.CharField(db_column='ItemName', max_length=255) # Field name made lowercase. + age = models.BigIntegerField(db_column='Age') # Field name made lowercase. + isperishable = models.IntegerField(db_column='isPerishable') # Field name made lowercase. + calories = models.IntegerField(db_column='Calories', blank=True, null=True) # Field name made lowercase. creation_date = models.DateTimeField() modified_date = models.DateTimeField() eff_bgn_ts = models.DateTimeField() eff_end_ts = models.DateTimeField() + class Meta: + managed = False + db_table = 'Items' + -class Recipe(models.Model): - fridge = models.ForeignKey( - Fridge, models.DO_NOTHING, related_name='recipes') - user = models.ForeignKey(User, models.DO_NOTHING, related_name='recipes') - title = models.TextField() - sourceurl = models.TextField(null=True) - imageurl = models.TextField(null=True) +class Recipes(models.Model): + fridgeid = models.ForeignKey(Fridge, models.DO_NOTHING, db_column='FridgeId') # Field name made lowercase. + userid = models.ForeignKey('Users', models.DO_NOTHING, db_column='UserId') # Field name made lowercase. + title = models.TextField(db_column='Title') # Field name made lowercase. + sourceurl = models.TextField(db_column='SourceUrl') # Field name made lowercase. eff_bgn_ts = models.DateTimeField() eff_end_ts = models.DateTimeField() + + class Meta: + managed = False + db_table = 'Recipes' + + +class Users(models.Model): + userid = models.ForeignKey('AuthUser', models.DO_NOTHING, db_column='UserID') # Field name made lowercase. + username = models.CharField(db_column='Username', unique=True, max_length=255) # Field name made lowercase. + ownedfridges = models.TextField(db_column='OwnedFridges', blank=True, null=True) # Field name made lowercase. + friendedfridges = models.TextField(db_column='FriendedFridges', blank=True, null=True) # Field name made lowercase. + personalnotes = models.TextField(db_column='PersonalNotes', blank=True, null=True) # Field name made lowercase. + eff_bgn_ts = models.DateTimeField() + eff_end_ts = models.DateTimeField() + + class Meta: + managed = False + db_table = 'Users' diff --git a/application/Django_refrigerator_project/refrigerator_app/views.py b/application/Django_refrigerator_project/refrigerator_app/views.py index a06fd8c..5245f42 100644 --- a/application/Django_refrigerator_project/refrigerator_app/views.py +++ b/application/Django_refrigerator_project/refrigerator_app/views.py @@ -1,435 +1,149 @@ +from django.shortcuts import render +from django.http import HttpResponse +from django.conf import settings +from django.core.files.storage import FileSystemStorage +from django.contrib.auth.decorators import login_required #for using @login_required decorator on top of a function +import boto3 import io +from io import BytesIO import sys import math -import datetime -import refrigerator_app.fridge as fridge_import - -from io import BytesIO - -from django.conf import settings -from django.core.files.storage import FileSystemStorage -from django.contrib.auth.decorators import login_required +from .models import Items +from .models import Users +from .models import AuthUser +from .models import Fridge from django.db.models import Q -from django.http import HttpResponse -from django.shortcuts import redirect -from django.shortcuts import render - -from .models import Fridge, Item, FridgeContent - -from users.models import AuthUser -from users.models import User - -from datetime import datetime -from datetime import timedelta +# Create your views here. def home(request): - return render(request, 'refrigerator_project/home.html') + inventory_items = Items.objects.all() + return render(request, 'refrigerator_project/home.html', context={'inventory_items': inventory_items}) +@login_required +def delete_item(request): + inventory_items = Items.objects.all() + return render(request, 'refrigerator_project/home.html', context={'inventory_items': inventory_items}) @login_required def groceries(request): - # Variables - fridge_manager = fridge_import.fridge_manager(request) - current_fridge = None - all_items = fridge_manager.getAllItems() - match = None - missing_items = None - manual_item_list = None - tracked_item_list = None - - # Get Current Fridge Name - try: - current_fridge = fridge_manager.getCurrentFridge() - except: - pass - - # Get list of manual items - try: - manual_item_list = fridge_manager.getCurrentFridge().manually_added_list - manual_item_list.reverse() - except: - # fridge_manager.initialCurrentFridge(request) - print('GROCERY VIEW: Error getting manual groceries.') - # return redirect('/groceries/') - - # Compute list of missing items - try: - tracked_item_list = fridge_manager.getCurrentFridge().auto_gen_grocery_list - inventory_items = fridge_manager.getCurrentFridgeContent() - - # Check for Tracked items missing from fridge - missing_items = [] - current_time = datetime.now() - for tItems in tracked_item_list: - inFridge = False - for iItems in inventory_items: - if (iItems.eff_end_ts > current_time): - if (tItems == iItems.item.name): - inFridge = True - if (inFridge == False): - missing_items.append(tItems) - except: - print('GROCERY VIEW: Error getting tracked groceries.') - - # Tracked item selection - if request.method == 'POST' and request.POST.get('tracked_selector_submit') == 'selection': - try: - # user_id = User.objects.filter(username=request.user.username).get().id - fridge = fridge_manager.getCurrentFridge() - list = request.POST.getlist('tracked_items', default=None) - fridge.auto_gen_grocery_list.clear() - for each in list: - fridge.auto_gen_grocery_list.append(each) - fridge.save() - return redirect('/groceries/') - except: - print('GROCERY VIEW: Error saving selected items to grocery list.') - - # Selected items added to manual list - if request.method == 'POST' and request.POST.get('grocery_selector_submit') == 'selection': - try: - fridge = fridge_manager.getCurrentFridge() - list = request.POST.getlist('grocery_items', default=None) - for each in list: - fridge.manually_added_list.append(each) - fridge.save() - return redirect('/groceries/') - except: - print('GROCERY VIEW: Error saving selected items to grocery list.') - - # Delete Item from manual list - if request.method == 'POST' and request.POST.get('delete_item'): - try: - fridge = fridge_manager.getCurrentFridge() - delete_this_item = request.POST.get('delete_item') - fridge.manually_added_list.remove(delete_this_item) - fridge.save() - return redirect('/groceries/') - except: - print('GROCERY VIEW: Error removing selected items to grocery list.') - - context = { - 'all_items': all_items, - 'sr': match, - 'missing_items': missing_items, - 'tracked_items': tracked_item_list, - 'manual_items': manual_item_list, - 'current_fridge': current_fridge} - - return render(request, 'refrigerator_project/groceries.html', context) - + fridge_data = Fridge + inventory_items = Items.objects.all() + if(request.method == 'POST'): + srch = request.POST['itemname'] + if srch: + match = Items.objects.filter(Q(itemname__icontains=srch) | Q( + itemid__icontains=srch) | Q(calories__icontains=srch)) + if match: + return render(request, 'refrigerator_project/groceries.html', {'sr': match}) + return render(request,'refrigerator_project/groceries.html', context={'inventory_items':inventory_items}) @login_required def profile(request): - # Send user to receipt upload page upon "+" button click - try: - if request.method == 'POST' and request.FILES['receipt_image']: - return receipt_upload(request) - except: - pass - try: - if request.method == 'POST' and request.POST.get('validate_items') == 'selection': - receipt_upload(request) - return redirect('/fridge/') - except: - pass - - fridge_manager = fridge_import.fridge_manager(request) - - # previous line printed all users - # current_user = request.user - user_info = User.objects.filter(username=request.user.username) - user_id = User.objects.filter(username=request.user.username).get().id - ownedfridgelist = Fridge.objects.filter(owner_id=user_id) - - # for friended fridges column I will assume that it will be a list of fridge ids - friendedfridgeidlist = User.objects.filter( - username=request.user.username).get().friendedfridges - - # this is a list of the actual fridge objects matching the friendedfridgeidlist; note the __in allows us to query by list - friendedfridgelist = Fridge.objects.filter(id__in=friendedfridgeidlist) - - # account for the deleted fridges - actualownedfridges = fridge_manager.make_verified_fridge_list( - ownedfridgelist) - actualfriendedfridges = fridge_manager.make_verified_fridge_list( - friendedfridgelist) - - # An object that holds the info from fridges in ownedfridgelist, except the there is a friends_name_list to hold names - ownedfridge_objectlist = [] - # parameters: name, creation_date, friends_name_list, id - for fridge in actualownedfridges: - f_obj = fridge_manager.fridge_Object( - fridge.name, fridge.creation_date, fridge_manager.get_name_list_from_id_list(fridge.friends), fridge.id) - ownedfridge_objectlist.append(f_obj) - - # An object that holds the info from fridges in friendedfridgelist, except the there is a friends_name_list to hold names - friendedfridge_objectlist = [] - # parameters: name, creation_date, friends_name_list, id - for fridge in actualfriendedfridges: - f_obj = fridge_manager.fridge_Object( - fridge.name, fridge.creation_date, fridge_manager.get_name_list_from_id_list(fridge.friends), fridge.id) - friendedfridge_objectlist.append(f_obj) - - actualownedfridges = fridge_manager.make_verified_fridge_list( - ownedfridgelist) - actualfriendedfridges = fridge_manager.make_verified_fridge_list( - friendedfridgelist) - - # Setting Personal Notes - if request.method == 'POST' and request.POST.get('add_personal_notes'): - try: - fridge_manager.set_personal_notes(request.POST.get( - 'personal_notes')) - except: - print('Error setting personal notes') - - personalnotes = User.objects.filter( - username=request.user.username).get().personalnotes - - if personalnotes is None: - personalnotes = '' - - context = { - 'user_info': user_info, - 'ownedfridge_objectlist': ownedfridge_objectlist, - 'friendedfridge_objectlist': friendedfridge_objectlist, - 'personalnotes': personalnotes - } - - return render(request, 'refrigerator_project/profile.html', context) + user_info = Users.objects.all() + return render(request,'refrigerator_project/profile.html', context={'user_info' : user_info }) +@login_required +def fridge(request): + inventory_items = Items.objects.all() + my_dict = {'insert_me':"Hello I am from views.py"} + return render(request,'refrigerator_project/fridge.html', context={'inventory_items':inventory_items}) @login_required -def add_button(request): - try: - if request.method == 'POST' and request.FILES['receipt_image']: - return receipt_upload(request) - except: - pass - try: - if request.method == 'POST' and request.POST.get('validate_items') == 'selection': - receipt_upload(request) - return redirect('/fridge/') - except: - print("No Selected items.") +def recipe(request): + my_dict = {'insert_me':"Hello I am from views.py"} + return render(request,'refrigerator_project/recipe.html', context=my_dict) - if request.method == 'GET': - fridge_manager = fridge_import.fridge_manager(request) - inventory_items = fridge_manager.getAllItems() - current_fridge = fridge_manager.getCurrentFridge() - return render(request, 'refrigerator_project/item_addition.html', {'all_items': inventory_items, 'current_fridge': current_fridge}) +@login_required +def simple_upload(request): + context = {} + if request.method == 'POST' and request.FILES['image']: + myfile = request.FILES['image'] + fs = FileSystemStorage() + filename = fs.save(myfile.name, myfile) + print(filename) + text = detect_text(filename) + context['text'] = text + return render(request, 'refrigerator_project/receipt_upload.html', context) - # Selected items added to current fridge - if request.method == 'POST' and request.POST.get('grocery_selector_submit') == 'selection': - try: - fridge_manager = fridge_import.fridge_manager(request) - list = request.POST.getlist('grocery_items', default=None) - for each in list: - fridge_manager.addItem(each) - return redirect('/fridge/') - except: - print('ADD ITEM VIEW: Error saving selected items to grocery list.') +# AWS TextTract +def DisplayBlockInformation(block): + if 'Text' in block: + return block['Text'] + return '' +# AWS TextTract +def process_text_analysis(filename): -@login_required -def fridge(request): - # Variables - fridge_manager = fridge_import.fridge_manager(request) - inventory_items = None - expired = None - expiring = None - fresh = None - current_fridge = None - primary_fridge_id = None - current_time = datetime.now() - week_time = current_time + timedelta(days=7) - all_fridges = None - current_fridge_friends = None - ownership = None - owner_name = None - current_user = User.objects.filter( - id=request.session['current_user_id']).get() - # Get current fridge data - current_fridge = fridge_manager.getCurrentFridge() - try: - all_fridges = fridge_manager.get_all_the_related_fridges() - inventory_items = fridge_manager.getCurrentFridgeContent() - inventory_items_sorted = fridge_manager.getCurrentFridgeContentByExpiration() - expired = inventory_items_sorted['expired'] - expiring = inventory_items_sorted['expiring'] - fresh = inventory_items_sorted['fresh'] - current_fridge_friends = fridge_manager.getCurrentFridgeFriendsUsername() - ownership = fridge_manager.is_owner() - except: - print('FRIDGE VIEW: Error getting fridge data.') - # Get Fridge owner - try: - owner_name = User.objects.filter( - id=current_fridge.owner_id).get().username - except: - pass - # Select a fridge to view - if request.method == 'POST' and request.POST.get('select_fridge_submit'): - try: - fridge_manager.changeCurrentFridge( - request.POST.get('select_fridge_selected')) - return redirect('/fridge/') - except: - print('FRIDGE VIEW: Error Selecting Fridge.') - # Setting Primary Fridge - if request.method == 'POST' and request.POST.get('primary_fridge_submit'): - try: - fridge_manager.setPrimaryFridge( - request.POST.get('primary_fridge_selected')) - except: - print('FRIDGE VIEW: Failed setting primary fridge.') - # Check if Primary Fridge - try: - primary_fridge_id = fridge_manager.getPrimaryFridge() - except: - print("FRIDGE VIEW: Error getting primary fridge.") - # Adding Fridge - if request.method == 'POST' and request.POST.get('add_fridge'): - try: - if request.POST.get('fridge_name') != '': - fridge_manager.createFridge(request.POST.get( - 'fridge_name')) - return redirect('/fridge/') - except: - print('FRIDGE VIEW: Error adding fridge') - # Deleting Fridge - if request.method == 'POST' and request.POST.get('delete_fridge'): - try: - fridge_manager.delete_current_fridge() - return redirect('/fridge/') - except: - print('FRIDGE VIEW: Error deleting fridge') - # Adding Friends - if request.method == 'POST' and request.POST.get('add_friend_by_email'): - try: - fridge_manager.addFriend(request.POST.get('friend_email')) - return redirect('/fridge/') - except: - print('FRIDGE VIEW: Error adding friend') - # Deleting items via trash icon - if request.method == 'POST' and request.POST.get('delete_item'): - try: - fridge_manager.deleteItem(request.POST.get('delete_item')) - return redirect('/fridge/') - except: - print('FRIDGE VIEW: Error deleting item from fridge.') - # Adding items via text field - if request.method == 'POST' and request.POST.get('add_item'): - try: - fridge_manager.addItem(request.POST.get('item_name').lower()) - return redirect('/fridge/') - except: - print('FRIDGE VIEW: Error adding item.') - # Rename current primary fridge name :: to be added checks on ownership. - if request.method == 'POST' and request.POST.get('rename_fridge'): - try: - request.POST.get('fridge_name') - fridge_manager.renameCurrentFridge( - request.POST.get('fridge_name')) - return redirect('/fridge/') - except: - print('FRIDGE VIEW: Error Renaming Fridge') - # Deleting Friends from fridge - if request.method == 'POST' and request.POST.get('friend_selected_submit'): - try: - list = request.POST.getlist('select_friend_delete', default=None) - for each in list: - fridge_manager.remove_friend(each) - return redirect('/fridge/') - except: - print('FRIDGE VIEW: Error deleting friend from fridge.') - context = {'inventory_items': inventory_items, 'current_fridge': current_fridge, 'primary_fridge_id': primary_fridge_id, - 'current_date': current_time, 'week_time': week_time, - 'all_fridges': all_fridges, 'current_fridge_friends': current_fridge_friends, - 'ownership': ownership, 'owner_name': owner_name, 'current_user': current_user, 'expiring': expiring, 'expired': expired, 'fresh': fresh} - return render(request, 'refrigerator_project/fridge.html', context) + bw_img = open(filename,'rb') + client = boto3.client('textract') -@login_required -def receipt_upload(request): - fridge_manager = fridge_import.fridge_manager(request) - context = {} - # Get Current Fridge Data - try: - current_fridge = fridge_manager.getCurrentFridge() - context['current_fridge'] = current_fridge - except: - pass - # Display found receipt content upon image receipt - if request.method == 'POST': - try: - if request.FILES['receipt_image']: - myfile = request.FILES['receipt_image'] - fs = FileSystemStorage() - filename = fs.save(myfile.name, myfile) - text = detect_text(filename)[1] - # text = {'coffee'} #used for testing - context['text'] = text - except: - print('RECEIPT VIEW: No items detected.') - # Get list of selected found items and save it to db - if request.method == 'POST' and request.POST.get('validate_items') == 'selection': - print("submitted") - try: - list = request.POST.getlist('selected_items', default=None) - print(list) - selected_items = {} - for i in list: - temp_ = Item.objects.filter(Q(name__icontains=i)) - for j in temp_: - if j.name.lower() == i.lower(): - selected_items[j.id] = j.age - break - # Save to fridgeContent Table - fridge_manager.save_to_db(selected_items) - return redirect('/fridge/') - except: - print('RECEIPT VIEW: Error saving selected items to fridge.') - return render(request, 'refrigerator_project/receipt_upload.html', context) + response = client.analyze_document(Document={'Bytes': bw_img.read()}, + FeatureTypes=["TABLES", "FORMS"]) + blocks=response['Blocks'] + result = [] + print('Calling From Amazon Textract') + for block in blocks: + text = DisplayBlockInformation(block) + result.append(text) + + return ' '.join(result) +# Google Vision def detect_text(filename): - # Google Vision - post_processing_results = [] - tmp_id_exp_age_store = {} - # Detects text in the file. + db =['apple', 'pineapple','strawberry', 'bread', 'juice', 'yogurt'] + + """matching against the database function""" + def is_it_in(a): + if a.casefold() in (name.casefold() for name in db): + return True; + + + """Detects text in the file.""" from google.cloud import vision import io client = vision.ImageAnnotatorClient() - filepath = 'media/' + filename - with io.open(filepath, 'rb') as image_file: + + with io.open(filename, 'rb') as image_file: content = image_file.read() + image = vision.types.Image(content=content) + response = client.text_detection(image=image) texts = response.text_annotations nina = next(iter(texts)) - output = nina.description.splitlines() + print(type(nina)) + print(type(nina.description)) + output = nina.description.splitlines( ) for x in output: splitted = x.split() for i in splitted: - temp = Item.objects.filter(Q(name__icontains=i)) - for each in temp: - if each.name.lower() == i.lower(): - post_processing_results.append(each.name) - tmp_id_exp_age_store[each.id] = each.age - break - return tmp_id_exp_age_store, post_processing_results + if is_it_in(i): + print(i) + break + + + # result = [] + # print('Calling From Google Vision') + # for text in texts: + # text = '\n"{}"'.format(text.description) + # result.append(text) + # print('\n"{}"'.format(text.description)) + + # vertices = (['({},{})'.format(vertex.x, vertex.y) + # for vertex in text.bounding_poly.vertices]) + # print('bounds: {}'.format(','.join(vertices))) + return 'nina' #' '.join(result) @login_required def search(request): if(request.method == 'POST'): srch = request.POST['itemname'] if srch: - match = Item.objects.filter(Q(name__icontains=srch) | Q( - id__icontains=srch) | Q(calories__icontains=srch)) + match = Items.objects.filter(Q(itemname__icontains = srch) | Q(itemid__icontains = srch) | Q(calories__icontains = srch)) if match: - return render(request, 'refrigerator_project/search.html', {'sr': match}) - return render(request, 'refrigerator_project/search.html') + return render(request,'refrigerator_project/search.html',{'sr':match}) + return render(request,'refrigerator_project/search.html') diff --git a/application/Django_refrigerator_project/requirements.txt b/application/Django_refrigerator_project/requirements.txt index b2abbca..6ecca40 100644 --- a/application/Django_refrigerator_project/requirements.txt +++ b/application/Django_refrigerator_project/requirements.txt @@ -1,6 +1,6 @@ Django>=2.2.0,<2.3.0 +psycopg2>=2.7,<3.0 mysqlclient>=1.4,<1.5 boto3>=1.5,<2.0 google-cloud>=0.1,<1.1 google-cloud-vision>=0.1,<1.1 -django-mysql>=3.0,<3.3 diff --git a/application/Django_refrigerator_project/static/Apple.jpg b/application/Django_refrigerator_project/static/Apple.jpg new file mode 100644 index 0000000..698364d Binary files /dev/null and b/application/Django_refrigerator_project/static/Apple.jpg differ diff --git a/application/Django_refrigerator_project/static/Banana.jpg b/application/Django_refrigerator_project/static/Banana.jpg new file mode 100644 index 0000000..f4bc609 Binary files /dev/null and b/application/Django_refrigerator_project/static/Banana.jpg differ diff --git a/application/Django_refrigerator_project/static/Cheese.jpg b/application/Django_refrigerator_project/static/Cheese.jpg new file mode 100644 index 0000000..cb4201e Binary files /dev/null and b/application/Django_refrigerator_project/static/Cheese.jpg differ diff --git a/application/Django_refrigerator_project/static/Orange.jpg b/application/Django_refrigerator_project/static/Orange.jpg new file mode 100644 index 0000000..af2f1e2 Binary files /dev/null and b/application/Django_refrigerator_project/static/Orange.jpg differ diff --git a/application/Django_refrigerator_project/static/Pineapple.jpg b/application/Django_refrigerator_project/static/Pineapple.jpg new file mode 100644 index 0000000..ee45d3f Binary files /dev/null and b/application/Django_refrigerator_project/static/Pineapple.jpg differ diff --git a/application/Django_refrigerator_project/static/Pork.jpg b/application/Django_refrigerator_project/static/Pork.jpg new file mode 100644 index 0000000..02e8eb8 Binary files /dev/null and b/application/Django_refrigerator_project/static/Pork.jpg differ diff --git a/application/Django_refrigerator_project/static/base.css b/application/Django_refrigerator_project/static/base.css new file mode 100644 index 0000000..f7641c5 --- /dev/null +++ b/application/Django_refrigerator_project/static/base.css @@ -0,0 +1,101 @@ +/* .navbar-nav class is to override bootstraps automatic stacking feature when on mobile screens */ + +.navbar-nav { + flex-direction: row; +} + +.navbar-toggler { + left: 5%; +} + +/*.icon is for spacing in between icons */ + +.icon { + margin-left: 45px; +} + +.navbar-brand { + position: absolute; + left: 50%; + transform: translateX(-50%); + margin-top: 1px; + display: block +} + +body { + font-family: "Lato", sans-serif; + padding-top: 50px; +} + +/* The side navigation menu */ + +.sidenav { + height: 100%; + /* 100% Full-height */ + width: 0; + /* 0 width - change this with JavaScript */ + position: fixed; + /* Stay in place */ + z-index: 1; + /* Stay on top */ + top: 0; + /* Stay at the top */ + left: 0; + background-color: #353a3f; + /* Dark Blue Gray*/ + overflow-x: hidden; + /* Disable horizontal scroll */ + padding-top: 90px; + /* Place content 60px from the top */ + transition: 0.5s; + /* 0.5 second transition effect to slide in the sidenav */ +} + +/* The navigation menu links */ + +.sidenav a { + padding-top: 8px; + padding-right: 8px; + padding-bottom: 8px; + padding-left: 20px; + text-decoration: none; + font-size: 25px; + color: #dbd7d7; + display: block; + transition: 0.3s; + white-space: nowrap; +} + +/* When you mouse over the navigation links, change their color */ + +.sidenav a:hover { + color: #f1f1f1; +} + +/* Position and style the close button (top right corner) */ + +.sidenav .closebtn { + position: absolute; + top: 40px; + right: 25px; + font-size: 36px; + margin-left: 50px; +} + +/* Style page content - use this if you want to push the page content to the right when you open the side navigation */ + +#main { + transition: margin-left .5s; + padding: 20px; +} + +/* On smaller screens, where height is less than 450px, change the style of the sidenav (less padding and a smaller font size) */ + +@media screen and (max-height: 450px) { + .sidenav { + padding-top: 15px; + } + .sidenav a { + font-size: 18px; + } +} \ No newline at end of file diff --git a/application/Django_refrigerator_project/static/fridge_black.png b/application/Django_refrigerator_project/static/fridge_black.png new file mode 100644 index 0000000..5c548cd Binary files /dev/null and b/application/Django_refrigerator_project/static/fridge_black.png differ diff --git a/application/Django_refrigerator_project/static/fridge_card.css b/application/Django_refrigerator_project/static/fridge_card.css new file mode 100644 index 0000000..22abcf5 --- /dev/null +++ b/application/Django_refrigerator_project/static/fridge_card.css @@ -0,0 +1,36 @@ + /*.card-header and .fa for drop down ability*/ + .card-header .fa { + transition: .3s transform ease-in-out; + } + /*ability for arrow to rotate*/ + .card-header .collapsed .fa { + transform: rotate(-90deg); + } + /*card resizing*/ + .card{ + margin-left: 15px; + margin-right: 15px; + margin-top: 10px; + } + /*.column and .row are for inside the dropdown card*/ + .column{ + float: left; + width: 50%; + } + .row:after { + content: ""; + display: table; + clear: both; + } + /*trash icon to be centered*/ + .trash-center{ + display: flex; + align-items: center; + justify-content: center + } + /*text box centered*/ + .textarea { + display: block; + margin-left: auto; + margin-right: auto; + } \ No newline at end of file diff --git a/application/Django_refrigerator_project/static/fridge_gray.png b/application/Django_refrigerator_project/static/fridge_gray.png new file mode 100644 index 0000000..1cce597 Binary files /dev/null and b/application/Django_refrigerator_project/static/fridge_gray.png differ diff --git a/application/Django_refrigerator_project/static/fridge_logo_black.svg b/application/Django_refrigerator_project/static/fridge_logo_black.svg new file mode 100644 index 0000000..9682bad --- /dev/null +++ b/application/Django_refrigerator_project/static/fridge_logo_black.svg @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/application/Django_refrigerator_project/static/fridge_logo_gray.png b/application/Django_refrigerator_project/static/fridge_logo_gray.png new file mode 100644 index 0000000..6331eef Binary files /dev/null and b/application/Django_refrigerator_project/static/fridge_logo_gray.png differ diff --git a/application/Django_refrigerator_project/static/login.css b/application/Django_refrigerator_project/static/login.css new file mode 100644 index 0000000..ab03c52 --- /dev/null +++ b/application/Django_refrigerator_project/static/login.css @@ -0,0 +1,77 @@ +* { + box-sizing: border-box; + margin: 0; + padding: 0; +} + +input { + display: block; + padding: 6px 10px; + border-radius: 3px; +} + +input[type=text], input[type=password], input[type=email] { + width: 100%; + margin-bottom: 0px; + border: 1px solid rgb(167, 167, 167); +} + +input[type=submit] { + width: 100%; + cursor: pointer; + color: white; + background-color: rgba(30, 130, 250, 1); + border: none; + padding: 12px 20px; +} + +input[type=submit]:hover { + background-color: rgb(23, 117, 199); +} + +label { + display: inline; +} + +form { + display: block; +} + +legend { + text-align: center; + padding-top: 20px; + padding-bottom: 20px; + font-size: 32px; +} + +.main { + width: 50%; + margin: 0 auto; + margin-top: 50px; + background-color: rgb(248, 248, 248); + padding: 20px 30px; + box-shadow: -2px -2px 2px rgb(139, 139, 139), 2px 2px 2px rgb(139, 139, 139); + border: 2px solid rgb(230, 230, 230); + border-radius: 5px; +} + +.helptext, ul, li { + color: rgb(102, 102, 102); + font-size: 12px; +} + +.errorlist li { + color: red; + font-size: 12px; +} + +.main input { + margin-bottom: 25px; +} + +@media only screen and (max-width: 600px) { + .main { + width: 100%; + } + } + \ No newline at end of file diff --git a/application/Django_refrigerator_project/static/logo_gray.png b/application/Django_refrigerator_project/static/logo_gray.png new file mode 100644 index 0000000..e39265a Binary files /dev/null and b/application/Django_refrigerator_project/static/logo_gray.png differ diff --git a/application/Django_refrigerator_project/templates/recipes/recipe_landing.html b/application/Django_refrigerator_project/templates/recipes/recipe_landing.html index 1c7dc60..3421289 100644 --- a/application/Django_refrigerator_project/templates/recipes/recipe_landing.html +++ b/application/Django_refrigerator_project/templates/recipes/recipe_landing.html @@ -1,54 +1,56 @@ -{% extends 'refrigerator_project/base.html' %} {% load static %} {% block content %} +{% extends 'refrigerator_project/base.html' %} +{% load static %} +{% block content %} -
-

Recipes

- {% if current_fridge %} -

{{current_fridge.name}}

- {% else %} -

No Refrigerators. Please Add One.

- {% endif %} -
-
-
+
+
+
+

Recipes

+
+
+
+ +
+ -
-
+
-
Saved Recipes:
+

Saved Recipes:

+
- {% if saved_recipes %} {% for each in saved_recipes %} + {% if saved_recipes %} + {% for each in saved_recipes %} -
- {% endfor %} {% else %} + {% endfor %} + {% else %}

none

{% endif %}
diff --git a/application/Django_refrigerator_project/templates/recipes/recipe_search.html b/application/Django_refrigerator_project/templates/recipes/recipe_search.html index c14531a..b927822 100644 --- a/application/Django_refrigerator_project/templates/recipes/recipe_search.html +++ b/application/Django_refrigerator_project/templates/recipes/recipe_search.html @@ -1,88 +1,94 @@ -{% extends 'refrigerator_project/base.html' %} {% load static %} {% block content %} +{% extends 'refrigerator_project/base.html' %} +{% load static %} +{% block content %} - - -
-

Recipe Search

- {% if current_fridge %} -

{{current_fridge.name}}

- {% else %} -

No Refrigerators. Please Add One.

- {% endif %} -
-
+
-

Select items you'd like to use:

+

Select the items you'd like to use

-
+
-
-
- -
- +
+ {% csrf_token %} +
+
+ Search by Name, ID, or Calories:
-
+
+
+ +
+
+ +
-
Current Fridge Contents:
+ + {% if sr %} +
Found Items:
+ {% endif %} + {% for each in sr %} + + {% endfor %} + +
+ + - -
-
    - {% for each in inventory_items %} -
  • -
    - -
    -
  • - {% endfor %} -
-
-
- - -
-
- +
+
+ {% for each in inventory_items %} + + {% endfor %} +
+
+
+
+
+ Next
diff --git a/application/Django_refrigerator_project/templates/refrigerator_project/base.html b/application/Django_refrigerator_project/templates/refrigerator_project/base.html index bfb7422..95150eb 100644 --- a/application/Django_refrigerator_project/templates/refrigerator_project/base.html +++ b/application/Django_refrigerator_project/templates/refrigerator_project/base.html @@ -1,6 +1,8 @@ {% load static %} + + @@ -8,7 +10,6 @@ Fridge App 9000 - @@ -22,12 +23,8 @@ integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"> - - - - + @@ -52,491 +44,161 @@ - -
- - -
- - {% if not "auth" in request.path and request.path != "/" %} - - {% else %} - -
- {% if messages %} {% for message in messages %} -
- - {{ message }} -
- {% endfor %} {% endif %} + + + - {% endif %} - +
- - - - - -