This is (potentially) a solution for the third problem from CS50 course conducted at Harvard University. The course is accessible through edX platform: https://www.edx.org/
The goal is to develop own version of following website: http://www.pinocchiospizza.net/menu.html with additional ability allowing users to place orders composed of dishes listed in menu.
The program requires Django installed to run. Type python3 manage.py runserver
and copy output link from terminal to go to the basic route.
The file extract data.ipynb
extracts data from orignal website to .csv files menu_tables.csv
and menu_toppings.csv
. Running import csv.py
file with command python3 manage.py import\ csv.py
inserts .csv
files' inner into the database.
The database file db.sqlite3
has already inserted menu data from the orignal site and also contains already created superuser (username: admin
, password: abc123
).
The database diagram is shown below. All menu data is stored in 4 tables, connected with foreignkeys. The arrowhead points to a table which posses foreignkey of a table at the arrow start. 3 parallel arrows mean 'many to many relation'.
-
ItemKind
table consists of all possible dish kinds. -
ItemName
table consists of all possible dish names with the same kind, and defines number of toppings in case of pizzas. -
ItemSize
table consists of all possible size variants for specified dish kind. -
MenuItem
table defines price of a dish for corresponding kind, name and size. -
Topping
table defines names of available toppings for pizza -
Dish
table concats kind, name, size, price info with selected toppings for pizza, which are a list ofTopping
objects. -
Order
represents singleUser
's order, which consists of list ofDish
elements. -
User
is a standard django table with normal and superusers info, used for logging and authentificating users.
02.02.2020:
- database structure in file
orders/models.py
is complete - program for data extracting from original website and inserting it into database is complete
- creating dishes and orders works properly and is possible so far only from admin site (route
/admin
):
- First you have to create a new empty
order
(at least one) - Then you can create various
dishes
and assign them to a choosedorder
. The order consists of dishes which the user is going to see in their cart. - Note: a
dish
differs from amenu item
is such way, that in case of creating a pizza kinddish
you can assign varioustoppings
to it, wheremenu item
pizza only defines number oftoppings
.
03.02.2020
- you can view price menu with links to corresponding pizza's info
07.02.2020
- exchanged the notebook that extracts data from web and inserts into database to a notebook that extracts data to .csv file
- extracted data can be inserted into the database using django's ORM outside of the app by running the file
import csv.py
08.02.2020
- added forms to properly (as tested so far) customize pizzas (add/delete toppings, change size, alter price) by users
9.02.2020
- added form to properly add/delete dishes to card and display overall price
13.02.2020
- login/register for users is available
login/logout for usersdonedone, all with/
route with menu items listedadd to cart
buttonsdone for pizzas/<item_id>
route allowing users to customise dishesand add them to cartdone/cart
route with all dishes created by logged user, with total amount of $ to billmostly done and with a textfield allowing the user to leave an additional message for restauration's owner- start making unit tests!