diff --git a/customer/__pycache__/admin.cpython-37.pyc b/customer/__pycache__/admin.cpython-37.pyc
index 339eb8e..43ff55e 100644
Binary files a/customer/__pycache__/admin.cpython-37.pyc and b/customer/__pycache__/admin.cpython-37.pyc differ
diff --git a/customer/__pycache__/models.cpython-37.pyc b/customer/__pycache__/models.cpython-37.pyc
index 0826e17..d508d10 100644
Binary files a/customer/__pycache__/models.cpython-37.pyc and b/customer/__pycache__/models.cpython-37.pyc differ
diff --git a/customer/__pycache__/views.cpython-37.pyc b/customer/__pycache__/views.cpython-37.pyc
index 8ff6c1a..236dc61 100644
Binary files a/customer/__pycache__/views.cpython-37.pyc and b/customer/__pycache__/views.cpython-37.pyc differ
diff --git a/customer/admin.py b/customer/admin.py
index 8c38f3f..a0d271e 100644
--- a/customer/admin.py
+++ b/customer/admin.py
@@ -1,3 +1,6 @@
from django.contrib import admin
+from .models import MenuItem, Category, OrderModel
-# Register your models here.
+admin.site.register(MenuItem)
+admin.site.register(Category)
+admin.site.register(OrderModel)
diff --git a/customer/migrations/0001_initial.py b/customer/migrations/0001_initial.py
new file mode 100644
index 0000000..51cf82e
--- /dev/null
+++ b/customer/migrations/0001_initial.py
@@ -0,0 +1,41 @@
+# Generated by Django 2.1.4 on 2020-10-06 04:26
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = [
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='Category',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('name', models.CharField(max_length=100)),
+ ],
+ ),
+ migrations.CreateModel(
+ name='MenuItem',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('name', models.CharField(max_length=100)),
+ ('description', models.TextField()),
+ ('image', models.ImageField(upload_to='menu_images/')),
+ ('price', models.DecimalField(decimal_places=2, max_digits=5)),
+ ('category', models.ManyToManyField(related_name='item', to='customer.Category')),
+ ],
+ ),
+ migrations.CreateModel(
+ name='OrderModel',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('created_on', models.DateTimeField(auto_now_add=True)),
+ ('price', models.DecimalField(decimal_places=2, max_digits=7)),
+ ('items', models.ManyToManyField(blank=True, related_name='order', to='customer.MenuItem')),
+ ],
+ ),
+ ]
diff --git a/customer/migrations/__pycache__/0001_initial.cpython-37.pyc b/customer/migrations/__pycache__/0001_initial.cpython-37.pyc
new file mode 100644
index 0000000..3db9b51
Binary files /dev/null and b/customer/migrations/__pycache__/0001_initial.cpython-37.pyc differ
diff --git a/customer/models.py b/customer/models.py
index 71a8362..285827e 100644
--- a/customer/models.py
+++ b/customer/models.py
@@ -1,3 +1,29 @@
from django.db import models
-# Create your models here.
+
+class MenuItem(models.Model):
+ name = models.CharField(max_length=100)
+ description = models.TextField()
+ image = models.ImageField(upload_to='menu_images/')
+ price = models.DecimalField(max_digits=5, decimal_places=2)
+ category = models.ManyToManyField('Category', related_name='item')
+
+ def __str__(self):
+ return self.name
+
+
+class Category(models.Model):
+ name = models.CharField(max_length=100)
+
+ def __str__(self):
+ return self.name
+
+
+class OrderModel(models.Model):
+ created_on = models.DateTimeField(auto_now_add=True)
+ price = models.DecimalField(max_digits=7, decimal_places=2)
+ items = models.ManyToManyField(
+ 'MenuItem', related_name='order', blank=True)
+
+ def __str__(self):
+ return f'Order: {self.created_on.strftime("%b %d %I: %M %p")}'
diff --git a/customer/templates/customer/index.html b/customer/templates/customer/index.html
index 76cb69d..88de44d 100644
--- a/customer/templates/customer/index.html
+++ b/customer/templates/customer/index.html
@@ -10,7 +10,7 @@
Online Food Delivery Service
Place an Order!
-
+
Order Now!
diff --git a/customer/templates/customer/navigation.html b/customer/templates/customer/navigation.html
index b5cb381..55fa8b7 100644
--- a/customer/templates/customer/navigation.html
+++ b/customer/templates/customer/navigation.html
@@ -14,7 +14,7 @@
diff --git a/customer/templates/customer/order.html b/customer/templates/customer/order.html
new file mode 100644
index 0000000..4fd19b0
--- /dev/null
+++ b/customer/templates/customer/order.html
@@ -0,0 +1,98 @@
+{% extends 'customer/base.html' %}
+
+{% block content %}
+
+{% endblock content %}
diff --git a/customer/templates/customer/order_confirmation.html b/customer/templates/customer/order_confirmation.html
new file mode 100644
index 0000000..859fcc5
--- /dev/null
+++ b/customer/templates/customer/order_confirmation.html
@@ -0,0 +1,24 @@
+{% extends 'customer/base.html' %}
+
+{% block content %}
+
+
+
+
Order Submitted!
+
You should receive a confirmation email soon.
+
Go to the homepage
+
+
+
+
+
+
Order Summary:
+ {% for item in items %}
+
{{ item.name }} {{ item.price }}
+ {% endfor %}
+
+
Total: {{ price }}
+
+
+
+{% endblock content %}
diff --git a/customer/views.py b/customer/views.py
index 5bcea34..dc88174 100644
--- a/customer/views.py
+++ b/customer/views.py
@@ -1,10 +1,68 @@
from django.shortcuts import render
from django.views import View
+from .models import MenuItem, Category, OrderModel
+
class Index(View):
def get(self, request, *args, **kwargs):
return render(request, 'customer/index.html')
+
class About(View):
def get(self, request, *args, **kwargs):
return render(request, 'customer/about.html')
+
+
+class Order(View):
+ def get(self, request, *args, **kwargs):
+ # get every item from each category
+ appetizers = MenuItem.objects.filter(
+ category__name__contains='Appetizer')
+ entres = MenuItem.objects.filter(category__name__contains='Entre')
+ desserts = MenuItem.objects.filter(category__name__contains='Dessert')
+ drinks = MenuItem.objects.filter(category__name__contains='Drink')
+
+ # pass into context
+ context = {
+ 'appetizers': appetizers,
+ 'entres': entres,
+ 'desserts': desserts,
+ 'drinks': drinks,
+ }
+
+ # render the template
+ return render(request, 'customer/order.html', context)
+
+ def post(self, request, *args, **kwargs):
+ order_items = {
+ 'items': []
+ }
+
+ items = request.POST.getlist('items[]')
+
+ for item in items:
+ menu_item = MenuItem.objects.get(pk__contains=int(item))
+ item_data = {
+ 'id': menu_item.pk,
+ 'name': menu_item.name,
+ 'price': menu_item.price
+ }
+
+ order_items['items'].append(item_data)
+
+ price = 0
+ item_ids = []
+
+ for item in order_items['items']:
+ price += item['price']
+ item_ids.append(item['id'])
+
+ order = OrderModel.objects.create(price=price)
+ order.items.add(*item_ids)
+
+ context = {
+ 'items': order_items['items'],
+ 'price': price
+ }
+
+ return render(request, 'customer/order_confirmation.html', context)
diff --git a/db.sqlite3 b/db.sqlite3
index fa9e853..751230a 100644
Binary files a/db.sqlite3 and b/db.sqlite3 differ
diff --git a/deliver/__pycache__/settings.cpython-37.pyc b/deliver/__pycache__/settings.cpython-37.pyc
index e29bec5..889f49c 100644
Binary files a/deliver/__pycache__/settings.cpython-37.pyc and b/deliver/__pycache__/settings.cpython-37.pyc differ
diff --git a/deliver/__pycache__/urls.cpython-37.pyc b/deliver/__pycache__/urls.cpython-37.pyc
index fd56455..47dc2e3 100644
Binary files a/deliver/__pycache__/urls.cpython-37.pyc and b/deliver/__pycache__/urls.cpython-37.pyc differ
diff --git a/deliver/settings.py b/deliver/settings.py
index a463374..530be77 100644
--- a/deliver/settings.py
+++ b/deliver/settings.py
@@ -120,3 +120,6 @@
# https://docs.djangoproject.com/en/2.1/howto/static-files/
STATIC_URL = '/static/'
+
+MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
+MEDIA_URL = '/media/'
diff --git a/deliver/urls.py b/deliver/urls.py
index 632d15d..dfa9cf1 100644
--- a/deliver/urls.py
+++ b/deliver/urls.py
@@ -15,10 +15,13 @@
"""
from django.contrib import admin
from django.urls import path
-from customer.views import Index, About
+from django.conf import settings
+from django.conf.urls.static import static
+from customer.views import Index, About, Order
urlpatterns = [
path('admin/', admin.site.urls),
path('', Index.as_view(), name='index'),
path('about/', About.as_view(), name='about'),
-]
+ path('order/', Order.as_view(), name='order'),
+] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
diff --git a/media/menu_images/download.jpg b/media/menu_images/download.jpg
new file mode 100644
index 0000000..eacae97
Binary files /dev/null and b/media/menu_images/download.jpg differ
diff --git a/media/menu_images/download_1.jpg b/media/menu_images/download_1.jpg
new file mode 100644
index 0000000..f476a05
Binary files /dev/null and b/media/menu_images/download_1.jpg differ
diff --git a/media/menu_images/download_1_Jojlvcz.jpg b/media/menu_images/download_1_Jojlvcz.jpg
new file mode 100644
index 0000000..f476a05
Binary files /dev/null and b/media/menu_images/download_1_Jojlvcz.jpg differ
diff --git a/media/menu_images/download_2.jpg b/media/menu_images/download_2.jpg
new file mode 100644
index 0000000..2725469
Binary files /dev/null and b/media/menu_images/download_2.jpg differ
diff --git a/media/menu_images/download_2_NxsJe0r.jpg b/media/menu_images/download_2_NxsJe0r.jpg
new file mode 100644
index 0000000..2725469
Binary files /dev/null and b/media/menu_images/download_2_NxsJe0r.jpg differ
diff --git a/media/menu_images/download_3.jpg b/media/menu_images/download_3.jpg
new file mode 100644
index 0000000..52d0ff6
Binary files /dev/null and b/media/menu_images/download_3.jpg differ
diff --git a/media/menu_images/download_3_8f9KIn0.jpg b/media/menu_images/download_3_8f9KIn0.jpg
new file mode 100644
index 0000000..52d0ff6
Binary files /dev/null and b/media/menu_images/download_3_8f9KIn0.jpg differ
diff --git a/media/menu_images/download_ObXxHFz.jpg b/media/menu_images/download_ObXxHFz.jpg
new file mode 100644
index 0000000..eacae97
Binary files /dev/null and b/media/menu_images/download_ObXxHFz.jpg differ