Commit e7431d56 authored by Julia Santos's avatar Julia Santos

Merge branch 'master' into 'Setup2'

# Conflicts:
#   Breadcrumbs/urls.py
#   manage.py
parent df0720f8
from django.contrib import admin
from Breadcrumbs.models import User, Product_Type, Item, Recipe
admin.site.register(User)
admin.site.register(Product_Type)
admin.site.register(Item)
admin.site.register(Recipe)
from django.apps import AppConfig
class BreadcrumbsConfig(AppConfig):
name = 'Breadcrumbs'
# -*- coding: utf-8 -*-
# Generated by Django 1.11.17 on 2021-03-16 09:45
from __future__ import unicode_literals
import datetime
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Ingredient',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('Ingredient_Quantity', models.FloatField(default=1)),
('Quantity_Unit', models.CharField(default='grams', max_length=255)),
],
),
migrations.CreateModel(
name='Item',
fields=[
('Item_ID', models.AutoField(primary_key=True, serialize=False)),
('Item_Quantity', models.FloatField(default=1)),
('Quantity_Unit', models.CharField(default='grams', max_length=255)),
('Item_Description', models.CharField(blank=True, max_length=255)),
('Purchase_Date', models.DateField(default=datetime.date(2021, 3, 16))),
('Expiration_Date', models.DateField(default=datetime.date(2021, 3, 16))),
('Is_Expired', models.BooleanField(default=False)),
('Is_Consumed', models.BooleanField(default=False)),
],
),
migrations.CreateModel(
name='Product_Type',
fields=[
('Product_ID', models.AutoField(primary_key=True, serialize=False)),
('Product_Name', models.CharField(max_length=255)),
('Product_Category', models.CharField(max_length=255)),
('Product_Description', models.CharField(blank=True, max_length=255)),
('To_Buy', models.BooleanField(default=False)),
],
),
migrations.CreateModel(
name='Recipe',
fields=[
('Recipe_ID', models.AutoField(primary_key=True, serialize=False)),
('Recipe_Name', models.CharField(max_length=255)),
('Recipe_Description', models.CharField(blank=True, max_length=255)),
],
),
migrations.CreateModel(
name='User',
fields=[
('User_ID', models.AutoField(primary_key=True, serialize=False)),
('User_Username', models.CharField(max_length=255)),
('User_Password', models.CharField(max_length=255)),
('User_Email', models.EmailField(max_length=254)),
],
),
migrations.AddField(
model_name='recipe',
name='User_ID',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='Breadcrumbs.User'),
),
migrations.AddField(
model_name='product_type',
name='User_ID',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='Breadcrumbs.User'),
),
migrations.AddField(
model_name='item',
name='Product_ID',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='Breadcrumbs.Product_Type'),
),
migrations.AddField(
model_name='item',
name='User_ID',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='Breadcrumbs.User'),
),
migrations.AddField(
model_name='ingredient',
name='Product_ID',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='Breadcrumbs.Product_Type'),
),
migrations.AddField(
model_name='ingredient',
name='Recipe_ID',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='Breadcrumbs.Recipe'),
),
migrations.AlterUniqueTogether(
name='ingredient',
unique_together=set([('Recipe_ID', 'Product_ID')]),
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.17 on 2021-03-16 10:00
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('Breadcrumbs', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='product_type',
name='Icon',
field=models.ImageField(null=True, upload_to='upload/'),
),
]
from django.db import models
import datetime
#from compositekey import db #used in the Ingredients class
class User(models.Model):
User_ID = models.AutoField(primary_key = True)
User_Username = models.CharField(max_length = 255)
User_Password = models.CharField(max_length = 255)
User_Email = models.EmailField(max_length = 254)
def __str__(self):
return str(self.User_Email)
class Product_Type(models.Model):
Product_ID = models.AutoField(primary_key = True)
Product_Name = models.CharField(max_length = 255)
Product_Category = models.CharField(max_length = 255)
Product_Description = models.CharField(max_length = 255, blank = True)
To_Buy = models.BooleanField(default = False)
User_ID = models.ForeignKey(User, on_delete=models.PROTECT) #From User Product Relationship Table
Icon = models.ImageField(upload_to='upload/', null = True)
def __str__(self):
return str(self.Product_ID)
class Item(models.Model): #1 class = 1 table
Item_ID = models.AutoField(primary_key = True)
Item_Quantity = models.FloatField(default = 1)
Quantity_Unit = models.CharField(max_length = 255, default = 'grams')
Item_Description = models.CharField(max_length = 255, blank = True)
Purchase_Date = models.DateField(default = datetime.datetime.now().date())
Expiration_Date = models.DateField(default = datetime.datetime.now().date())
Is_Expired = models.BooleanField(default = False)
Is_Consumed = models.BooleanField(default = False)
Product_ID = models.ForeignKey(Product_Type, on_delete=models.PROTECT) #From the Product Relationship Table
User_ID = models.ForeignKey(User, on_delete=models.PROTECT) #From User Item Relationship Table
def __str__(self):
return str(self.Item_ID)
class Recipe(models.Model):
Recipe_ID = models.AutoField(primary_key = True)
Recipe_Name = models.CharField(max_length = 255)
Recipe_Description = models.CharField(max_length = 255, blank = True)
User_ID = models.ForeignKey(User, on_delete=models.PROTECT)
def __str__(self):
return str(self.Recipe_ID)
class Ingredient(models.Model):
Recipe_ID = models.ForeignKey(Recipe, on_delete=models.PROTECT)
Product_ID = models.ForeignKey(Product_Type, on_delete=models.PROTECT)
Ingredient_Quantity = models.FloatField(default = 1)
Quantity_Unit = models.CharField(max_length = 255, default = 'grams')
class Meta:
unique_together = (("Recipe_ID", "Product_ID"),)
def __str__(self):
return str(self.Ingredients_ID)
\ No newline at end of file
<html>
<title>Publishers</title>
{% block content %}
<style>
table, th, td {
border: 1px solid black;
}
</style>
<h2>Publishers</h2>
<table style="width:100%">
<tr><th>pub id</th><th>name</th><th>city</th><th>state</th><th>country</th><th>pr info</th></tr>
{% for user in object_list %}
<tr>
<th>{{user.user_id}}</th>
</tr>
{% endfor %}
</table>
{% endblock %}
</html>
<html>
<title>Publishers</title>
{% block content %}
<style>
table, th, td {
border: 1px solid black;
}
</style>
<h2>Publishers</h2>
<table style="width:100%">
<tr><th>pub id</th><th>name</th><th>city</th><th>state</th><th>country</th><th>pr info</th></tr>
{% for user in object_list %}
<tr>
<th>{{user.user_id}}</th>
</tr>
{% endfor %}
</table>
{% endblock %}
</html>
<html>
<title>Fridge</title>
{% block content %}
<style>
table, th, td {
border: 1px solid black;
}
</style>
<h2>Fridge</h2>
<table style="width:100%">
<tr><th></th><th>name</th><th>category</th><th>description</th><th>to buy?</th><th>user</th></tr>
{% for product in object_list %}
<tr>
<th>
<img src = "{{product.Icon.url}}" width = "100" height ="100">
</th>
<th>
{{product.Product_Name}}
</th>
<th>
{{product.Product_Category}}
</th>
<th>
{{product.Product_Description}}
</th>
<th>
{{product.To_Buy}}
</th>
<th>
{{product.User_ID.User_Username}}
</th>
</tr>
{% endfor %}
</table>
{% endblock %}
</html>
from django.test import TestCase
# Create your tests here.
"""Breadcrumbs URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url
from django.contrib import admin
from django.conf import settings
from django.conf.urls.static import static
from .views import UserListView, ProductListView
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^fridge/list/', ProductListView.as_view(), name='fridgeL'),
]
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
\ No newline at end of file
from django.views.generic import ListView
from .models import User, Product_Type, Item, Recipe
from django.db.models import Q
class UserListView(ListView):
model = User
template_name = 'placeholder-list.html'
def get_queryset(self):
return User.objects.all().order_by('User_ID')
class ProductListView(ListView):
model = Product_Type
template_name = 'placeholder-list.html'
context_object_name = 'product'
def get_queryset(self):
return Product_Type.objects.all().order_by('Product_Name')
\ No newline at end of file
"""
Django settings for HungerBuster project.
Generated by 'django-admin startproject' using Django 1.11.17.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'rj0(--ammwe)5(^e*898=(%k8^*^qwa%xdu9$l&#+wd26#*le7'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'Breadcrumbs',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'HungerBuster.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'HungerBuster.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'breadcrumbs',
'USER': 'postgres',
'PASSWORD': 'postgres',
'HOST': 'localhost',
'PORT': '',
}
}
# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
STATIC_URL = '/static/'
STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'), )
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
\ No newline at end of file
"""Breadcrumbs URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url, include
from django.contrib import admin
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'', include('Breadcrumbs.urls') ),
]
"""
WSGI config for HungerBuster project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "HungerBuster.settings")
application = get_wsgi_application()
......@@ -3,7 +3,7 @@ import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Breadcrumbs.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "HungerBuster.settings")
try:
from django.core.management import execute_from_command_line
except ImportError:
......
Markdown is supported
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