From 6ce6d588b2e6878be8773b63def6692b5c1c7f01 Mon Sep 17 00:00:00 2001 From: Brandon Tan <101177183+Aeromon@users.noreply.github.com> Date: Sun, 20 Mar 2022 20:48:57 +0800 Subject: [PATCH 001/147] Create TheMakanNetworkSchema --- sql/TheMakanNetworkSchema | 1 + 1 file changed, 1 insertion(+) create mode 100644 sql/TheMakanNetworkSchema diff --git a/sql/TheMakanNetworkSchema b/sql/TheMakanNetworkSchema new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/sql/TheMakanNetworkSchema @@ -0,0 +1 @@ + From 7be0e17c8581fa0b40cc08b775cc86c0da740df3 Mon Sep 17 00:00:00 2001 From: Brandon Tan <101177183+Aeromon@users.noreply.github.com> Date: Sun, 20 Mar 2022 22:18:26 +0800 Subject: [PATCH 002/147] Update TheMakanNetworkSchema --- sql/TheMakanNetworkSchema | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/TheMakanNetworkSchema b/sql/TheMakanNetworkSchema index 8b1378917..6b1bd7bed 100644 --- a/sql/TheMakanNetworkSchema +++ b/sql/TheMakanNetworkSchema @@ -1 +1 @@ - +CREATE table if exist From 30b4b74ce7f3495a095ea49de7ac3f7b2583a5d3 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Sun, 20 Mar 2022 22:35:37 +0800 Subject: [PATCH 003/147] Update TheMakanNetworkSchema --- sql/TheMakanNetworkSchema | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/TheMakanNetworkSchema b/sql/TheMakanNetworkSchema index 6b1bd7bed..ff41c324a 100644 --- a/sql/TheMakanNetworkSchema +++ b/sql/TheMakanNetworkSchema @@ -1 +1,2 @@ CREATE table if exist +CREATE TABLE IF NOT EXISTS buyer From 42b123f9e73a4c6f91e5d5f6b20d847c9dbc066b Mon Sep 17 00:00:00 2001 From: Brandon Tan <101177183+Aeromon@users.noreply.github.com> Date: Tue, 22 Mar 2022 22:32:28 +0800 Subject: [PATCH 004/147] Update .env --- .env | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.env b/.env index 6b111ae9d..a03f8c5bd 100644 --- a/.env +++ b/.env @@ -14,8 +14,8 @@ LOCAL_DB_USER='postgres' LOCAL_DB_PASSWORD='postgres' ##### Heroku database ###### -DB_HOST= -DB_NAME= -DB_USER= -DB_PORT= -DB_PASSWORD= +DB_HOST=ec2-3-225-213-67.compute-1.amazonaws.com +DB_NAME=dcafujsnfvh3vf +DB_USER=gxhdxwiypuoagw +DB_PORT=5432 +DB_PASSWORD=7ca86887b1a9c84830bc056af1655ef2d61c199484e0c7a5e6f227b126d74f1f From 9d54ec26efb6c4844518989cfab2a067519d53b4 Mon Sep 17 00:00:00 2001 From: Aeromon Date: Wed, 23 Mar 2022 00:50:36 +0800 Subject: [PATCH 005/147] Change names of HTML files --- app/templates/app/Login.html | 10 ++++++++++ app/templates/app/{edit.html => edit_admin.html} | 0 .../app/{index.html => index_user_admin.html} | 0 app/templates/app/{add.html => new_user.html} | 2 +- app/templates/app/{view.html => view_admin.html} | 0 app/views.py | 8 ++++---- 6 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 app/templates/app/Login.html rename app/templates/app/{edit.html => edit_admin.html} (100%) rename app/templates/app/{index.html => index_user_admin.html} (100%) rename app/templates/app/{add.html => new_user.html} (98%) rename app/templates/app/{view.html => view_admin.html} (100%) diff --git a/app/templates/app/Login.html b/app/templates/app/Login.html new file mode 100644 index 000000000..566549bdf --- /dev/null +++ b/app/templates/app/Login.html @@ -0,0 +1,10 @@ + + + + + Title + + + + + \ No newline at end of file diff --git a/app/templates/app/edit.html b/app/templates/app/edit_admin.html similarity index 100% rename from app/templates/app/edit.html rename to app/templates/app/edit_admin.html diff --git a/app/templates/app/index.html b/app/templates/app/index_user_admin.html similarity index 100% rename from app/templates/app/index.html rename to app/templates/app/index_user_admin.html diff --git a/app/templates/app/add.html b/app/templates/app/new_user.html similarity index 98% rename from app/templates/app/add.html rename to app/templates/app/new_user.html index 6000dfbf2..cae4d25bf 100644 --- a/app/templates/app/add.html +++ b/app/templates/app/new_user.html @@ -1,6 +1,6 @@ -

Add New Customer

+

New User

Back to home

{{ status|safe }}

diff --git a/app/templates/app/view.html b/app/templates/app/view_admin.html similarity index 100% rename from app/templates/app/view.html rename to app/templates/app/view_admin.html diff --git a/app/views.py b/app/views.py index fba8722bc..64701fb71 100644 --- a/app/views.py +++ b/app/views.py @@ -18,7 +18,7 @@ def index(request): result_dict = {'records': customers} - return render(request,'app/index.html',result_dict) + return render(request, 'app/index_user_admin.html', result_dict) # Create your views here. def view(request, id): @@ -30,7 +30,7 @@ def view(request, id): customer = cursor.fetchone() result_dict = {'cust': customer} - return render(request,'app/view.html',result_dict) + return render(request, 'app/view_admin.html', result_dict) # Create your views here. def add(request): @@ -57,7 +57,7 @@ def add(request): context['status'] = status - return render(request, "app/add.html", context) + return render(request, "app/new_user.html", context) # Create your views here. def edit(request, id): @@ -89,4 +89,4 @@ def edit(request, id): context["obj"] = obj context["status"] = status - return render(request, "app/edit.html", context) \ No newline at end of file + return render(request, "app/edit_admin.html", context) \ No newline at end of file From 4a6b770edbcd707f3f9dc795928a55b9448e9db5 Mon Sep 17 00:00:00 2001 From: Aeromon Date: Wed, 23 Mar 2022 06:12:33 +0800 Subject: [PATCH 006/147] Updated HTML and views --- AppStore/urls.py | 1 + app/templates/app/Login.html | 10 ---------- app/templates/app/index_user_admin.html | 2 +- app/templates/app/login.html | 24 +++++++++++++++++++++++ app/templates/app/new_user.html | 8 ++++---- app/views.py | 26 ++++++++++++++++++++++++- 6 files changed, 55 insertions(+), 16 deletions(-) delete mode 100644 app/templates/app/Login.html create mode 100644 app/templates/app/login.html diff --git a/AppStore/urls.py b/AppStore/urls.py index 5355daa5c..4c8181f26 100644 --- a/AppStore/urls.py +++ b/AppStore/urls.py @@ -25,4 +25,5 @@ path('add', app.views.add, name='add'), path('view/', app.views.view, name='view'), path('edit/', app.views.edit, name='edit'), + path('login/',app.views.login, name='login'), ] diff --git a/app/templates/app/Login.html b/app/templates/app/Login.html deleted file mode 100644 index 566549bdf..000000000 --- a/app/templates/app/Login.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - Title - - - - - \ No newline at end of file diff --git a/app/templates/app/index_user_admin.html b/app/templates/app/index_user_admin.html index e32368db1..5130fde8a 100644 --- a/app/templates/app/index_user_admin.html +++ b/app/templates/app/index_user_admin.html @@ -3,7 +3,7 @@

Customers in the App Store

NUS logo
- New customer + New User

diff --git a/app/templates/app/login.html b/app/templates/app/login.html new file mode 100644 index 000000000..d5d93fa1c --- /dev/null +++ b/app/templates/app/login.html @@ -0,0 +1,24 @@ + + + + App Logo
+

Login

+ Back to home + Register + +

{{ status|safe }}

+ + + + {% csrf_token %} + +
+ + +
+ + + + \ No newline at end of file diff --git a/app/templates/app/new_user.html b/app/templates/app/new_user.html index cae4d25bf..8839eda1b 100644 --- a/app/templates/app/new_user.html +++ b/app/templates/app/new_user.html @@ -9,10 +9,10 @@

New User

{% csrf_token %} -
+ + + + + + + {% for product in product %} + + + + + + + + {% endfor %} +
IDProduct NamePriceDescription
{{ product.5 }} {{ product.0 }} {{ product.1 }} {{ product.2 }} + +
+ + \ No newline at end of file diff --git a/app/templates/app/login.html b/app/templates/app/login.html index d5d93fa1c..4976bc2e8 100644 --- a/app/templates/app/login.html +++ b/app/templates/app/login.html @@ -1,9 +1,13 @@ - +{% load static %} + + + Login + App Logo

Login

- Back to home + Back to home Register

{{ status|safe }}

@@ -15,8 +19,6 @@

Login

- -
diff --git a/app/templates/app/purchase.html b/app/templates/app/purchase.html new file mode 100644 index 000000000..58094faa9 --- /dev/null +++ b/app/templates/app/purchase.html @@ -0,0 +1,42 @@ + + + + Purchase + + + + + + + + + + + + + {% for product in product %} + + + + + + + + + + +
IDProduct NameAllergen NoticePriceDescriptionCategoryMin Orders
{{ product.5 }} {{ product.0 }} {{ product.1 }} {{ product.2 }} {{ product.3 }} {{ product.4 }} {{ product.6 }} +

{{ status|safe }}

+ +
+ + {% csrf_token %} + +
+
+
+
+ + + \ No newline at end of file diff --git a/app/views.py b/app/views.py index a3acbd31a..8e7d64f68 100644 --- a/app/views.py +++ b/app/views.py @@ -113,4 +113,18 @@ def login(request): else: status = 'Your User Id and Password is incorrect' % (request.POST['customerid']) - return render(request, 'app/login.html', context) \ No newline at end of file + return render(request, 'app/login.html', context) + + +# Create your views here. +def index_products(request): + """Shows the product listing page""" + + ## Use raw query to get all objects + with connection.cursor() as cursor: + cursor.execute("SELECT * FROM product_listings ORDER BY productid") + customers = cursor.fetchall() + + result_dict = {'records': product_listings} + + return render(request, 'app/index_products.html', result_dict) \ No newline at end of file From 04a1873ca0e47892cd6c0c8ef8b24c65bab19982 Mon Sep 17 00:00:00 2001 From: Aeromon Date: Wed, 23 Mar 2022 21:21:45 +0800 Subject: [PATCH 009/147] testing purchase.html, urls and views Updated login.html, urls.py,views.py --- AppStore/urls.py | 5 +++-- app/templates/app/purchase.html | 16 ++++++++-------- app/views.py | 14 +++++++++++++- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/AppStore/urls.py b/AppStore/urls.py index 9ae2386de..fb09cc718 100644 --- a/AppStore/urls.py +++ b/AppStore/urls.py @@ -21,10 +21,11 @@ urlpatterns = [ path('admin/', admin.site.urls), - path('', app.views.index, name='index'), + ##path('', app.views.index, name='index'), path('add', app.views.add, name='add'), path('view/', app.views.view, name='view'), path('edit/', app.views.edit, name='edit'), path('login/', app.views.login, name='login'), - path('index_products/', app.views.index_products, name='products') + path('index_products/', app.views.index_products, name='products'), + path('', app.views.purchase, name='purchase'), ] diff --git a/app/templates/app/purchase.html b/app/templates/app/purchase.html index 58094faa9..118c14923 100644 --- a/app/templates/app/purchase.html +++ b/app/templates/app/purchase.html @@ -14,15 +14,15 @@ Category Min Orders - {% for product in product %} + {% for cust in records %} - {{ product.5 }} - {{ product.0 }} - {{ product.1 }} - {{ product.2 }} - {{ product.3 }} - {{ product.4 }} - {{ product.6 }} + {{ cust.5 }} + {{ cust.0 }} + {{ cust.1 }} + {{ cust.2 }} + {{ cust.3 }} + {{ cust.4 }} + {{ cust.6 }}

{{ status|safe }}

diff --git a/app/views.py b/app/views.py index 8e7d64f68..38d80bfb8 100644 --- a/app/views.py +++ b/app/views.py @@ -127,4 +127,16 @@ def index_products(request): result_dict = {'records': product_listings} - return render(request, 'app/index_products.html', result_dict) \ No newline at end of file + return render(request, 'app/index_products.html', result_dict) + +def purchase(request): + """Shows the main page""" + + ## Use raw query to get all objects + with connection.cursor() as cursor: + cursor.execute("SELECT * FROM customers ORDER BY customerid") + customers = cursor.fetchall() + + result_dict = {'records': customers} + + return render(request, 'app/purchase.html', result_dict) \ No newline at end of file From c67e4bc61951ce2a5fbe66e2b92d17fbd38ac588 Mon Sep 17 00:00:00 2001 From: Aeromon Date: Wed, 23 Mar 2022 21:50:22 +0800 Subject: [PATCH 010/147] testing purchase.html, urls and views Updated login.html, urls.py,views.py --- app/templates/app/index_products.html | 2 +- app/templates/app/purchase.html | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/templates/app/index_products.html b/app/templates/app/index_products.html index 239980f34..14576330a 100644 --- a/app/templates/app/index_products.html +++ b/app/templates/app/index_products.html @@ -18,7 +18,7 @@

The Makan Network

Price Description - {% for product in product %} + {% for cust in records %} {{ product.5 }} {{ product.0 }} diff --git a/app/templates/app/purchase.html b/app/templates/app/purchase.html index 118c14923..24fc213c4 100644 --- a/app/templates/app/purchase.html +++ b/app/templates/app/purchase.html @@ -35,6 +35,7 @@ + {% endfor %}
From 5d48e25d0e2906f51d30495f18bf37e6a2f99c68 Mon Sep 17 00:00:00 2001 From: Aeromon Date: Wed, 23 Mar 2022 21:58:30 +0800 Subject: [PATCH 011/147] testing purchase.html, urls and views Updated login.html, urls.py,views.py --- AppStore/urls.py | 4 ++-- app/templates/app/index_products.html | 10 +++++----- app/views.py | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/AppStore/urls.py b/AppStore/urls.py index fb09cc718..1aa8dbb26 100644 --- a/AppStore/urls.py +++ b/AppStore/urls.py @@ -26,6 +26,6 @@ path('view/', app.views.view, name='view'), path('edit/', app.views.edit, name='edit'), path('login/', app.views.login, name='login'), - path('index_products/', app.views.index_products, name='products'), - path('', app.views.purchase, name='purchase'), + path('', app.views.index_products, name='products'), + path('purchase/', app.views.purchase, name='purchase'), ] diff --git a/app/templates/app/index_products.html b/app/templates/app/index_products.html index 14576330a..81e486609 100644 --- a/app/templates/app/index_products.html +++ b/app/templates/app/index_products.html @@ -20,12 +20,12 @@

The Makan Network

{% for cust in records %} - {{ product.5 }} - {{ product.0 }} - {{ product.1 }} - {{ product.2 }} + {{ cust.5 }} + {{ cust.0 }} + {{ cust.1 }} + {{ cust.2 }} - + {% endfor %} diff --git a/app/views.py b/app/views.py index 38d80bfb8..4bce38282 100644 --- a/app/views.py +++ b/app/views.py @@ -122,10 +122,10 @@ def index_products(request): ## Use raw query to get all objects with connection.cursor() as cursor: - cursor.execute("SELECT * FROM product_listings ORDER BY productid") + cursor.execute("SELECT * FROM customers ORDER BY customerid") customers = cursor.fetchall() - result_dict = {'records': product_listings} + result_dict = {'records': customers} return render(request, 'app/index_products.html', result_dict) From ae046043aea3dcba48b2661d16c367b654b3a42e Mon Sep 17 00:00:00 2001 From: Aeromon Date: Wed, 23 Mar 2022 22:23:44 +0800 Subject: [PATCH 012/147] testing purchase.html, urls and views Updated login.html, urls.py,views.py --- AppStore/urls.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AppStore/urls.py b/AppStore/urls.py index 1aa8dbb26..27d1a569e 100644 --- a/AppStore/urls.py +++ b/AppStore/urls.py @@ -25,7 +25,7 @@ path('add', app.views.add, name='add'), path('view/', app.views.view, name='view'), path('edit/', app.views.edit, name='edit'), - path('login/', app.views.login, name='login'), + path('login', app.views.login, name='login'), path('', app.views.index_products, name='products'), - path('purchase/', app.views.purchase, name='purchase'), + path('purchase', app.views.purchase, name='purchase'), ] From f7499022d50c9430af273c19ff7544866a3e2b7f Mon Sep 17 00:00:00 2001 From: Aeromon Date: Wed, 23 Mar 2022 22:44:43 +0800 Subject: [PATCH 013/147] testing purchase.html, urls and views Updated login.html, urls.py,views.py --- AppStore/urls.py | 1 + app/views.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/AppStore/urls.py b/AppStore/urls.py index 27d1a569e..349db7c79 100644 --- a/AppStore/urls.py +++ b/AppStore/urls.py @@ -23,6 +23,7 @@ path('admin/', admin.site.urls), ##path('', app.views.index, name='index'), path('add', app.views.add, name='add'), + path('buy', app.views.buy, name='buy') path('view/', app.views.view, name='view'), path('edit/', app.views.edit, name='edit'), path('login', app.views.login, name='login'), diff --git a/app/views.py b/app/views.py index 4bce38282..73440f6d2 100644 --- a/app/views.py +++ b/app/views.py @@ -139,4 +139,9 @@ def purchase(request): result_dict = {'records': customers} - return render(request, 'app/purchase.html', result_dict) \ No newline at end of file + return render(request, 'app/purchase.html', result_dict) + +def buy(request): + """This function enables the buy button on the purchase page""" + context = {} + status = '' From b925f9c878d5e48862d27c0a79aa1bbb6a199757 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Thu, 24 Mar 2022 16:16:51 +0800 Subject: [PATCH 014/147] Update TheMakanNetworkSchema --- sql/TheMakanNetworkSchema | 118 +++++++++++++++++++++++++++++++++++++- 1 file changed, 116 insertions(+), 2 deletions(-) diff --git a/sql/TheMakanNetworkSchema b/sql/TheMakanNetworkSchema index ff41c324a..6a0a23971 100644 --- a/sql/TheMakanNetworkSchema +++ b/sql/TheMakanNetworkSchema @@ -1,2 +1,116 @@ -CREATE table if exist -CREATE TABLE IF NOT EXISTS buyer +CREATE TABLE IF NOT EXISTS allusers ( + userid VARCHAR(32) NOT NULL UNIQUE, + phoneno BIGINT PRIMARY KEY, + password VARCHAR(32) NOT NULL +); + +CREATE TABLE IF NOT EXISTS products ( + productid int generated by default as identity + (start with 1 increment by 1) primary key, + sellerid varchar(32) not null, + name varchar(64) not null, + description varchar(256) not null, + price money not null, + category varchar(32) constraint category CHECK(category = 'dessert' OR category='ready meals' OR category = 'pastries' OR category = 'drinks'), + allergen varchar(32) not null, + minorder int not null check(minorder>=0), + foreign key(sellerid) references allusers(userid) +); + +CREATE TABLE IF NOT EXISTS transactions ( + orderid int generated by default as identity + (start with 1 increment by 1), + b_id varchar(32) not null, + s_id varchar(32) not null, + primary key(orderid, b_id, s_id), + p_id int references products(productid) generated by default as identity + (start with 1 increment by 1) unique, + qty int not null check(qty>0), + delivery varchar(12) not null check(delivery='self pickup' OR delivery='delivery'), + status varchar(10) not null check(status='pending' OR status='approved'), + foreign key(b_id) references allusers(userid), + foreign key(s_id) references allusers(userid), + check(not b_id = s_id) +); + +CREATE TABLE IF NOT EXISTS buyers ( + b_id varchar(32) primary key +); + +CREATE OR REPLACE FUNCTION new_buyer() +RETURNS trigger AS $$ +BEGIN + INSERT INTO buyers(b_id) + VALUES(NEW.b_id) ON CONFLICT DO NOTHING; + + RETURN NEW; +END; +$$ +LANGUAGE 'plpgsql'; + +CREATE TRIGGER update_buyers +AFTER INSERT +ON transactions +FOR EACH ROW +EXECUTE PROCEDURE new_buyer(); + +CREATE TABLE IF NOT EXISTS sellers ( + s_id varchar(32) primary key +); + +CREATE OR REPLACE FUNCTION new_seller() +RETURNS trigger AS $$ +BEGIN + INSERT INTO sellers(s_id) + VALUES(NEW.sellerid) ON CONFLICT DO NOTHING; + + RETURN NEW; +END; +$$ +LANGUAGE 'plpgsql'; + +CREATE TRIGGER update_sellers +AFTER INSERT +ON products +FOR EACH ROW +EXECUTE PROCEDURE new_seller(); + +CREATE OR REPLACE FUNCTION status_check() +RETURNS trigger AS $$ + +DECLARE + total_amount INT; + minorder INT; + +BEGIN + SELECT SUM(qty) FROM transactions WHERE p_id = NEW.p_id INTO total_amount; + SELECT minorder + FROM products + WHERE productid = NEW.p_id; + IF total_amount >= minorder THEN + UPDATE transactions SET status = 'approved' WHERE p_id = NEW.p_id; + RETURN NEW; + END IF; + RETURN NULL; +END; +$$ +LANGUAGE 'plpgsql'; + +CREATE TRIGGER check_status +AFTER INSERT +ON transactions +FOR EACH ROW +EXECUTE PROCEDURE status_check(); + +/* +CREATE TABLE IF NOT EXISTS reviews ( + userid VARCHAR(32) REFERENCES transactions(b_id) NOT NULL UNIQUE, + rated_p_id INT REFERENCES transactions(p_id) GENERATED BY DEFAULT AS IDENTITY + (START WITH 1 INCREMENT BY 1), + status VARCHAR(10) CONSTRAINT status CHECK (status = 'approved'), + userrating INT CONSTRAINT userrating CHECK (userrating BETWEEN 0 AND 5), + userreview VARCHAR(256), + ratingdate DATE +); +*/ + From ed276b21ca55a1335911ce5a645a03b98796b9e8 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Thu, 24 Mar 2022 17:04:03 +0800 Subject: [PATCH 015/147] Update new_user.html --- app/templates/app/new_user.html | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/app/templates/app/new_user.html b/app/templates/app/new_user.html index 8839eda1b..284126d0c 100644 --- a/app/templates/app/new_user.html +++ b/app/templates/app/new_user.html @@ -24,3 +24,32 @@

New User

+ + + +
+
+

Register

+

You're on your way to join our makan network family!

+
+ + + + + + + + + + + + +
+ + +
+ + +
From d4daae90c47d7098d51799b73e294945e35a2af1 Mon Sep 17 00:00:00 2001 From: Aeromon Date: Thu, 24 Mar 2022 19:13:46 +0800 Subject: [PATCH 016/147] testing purchase.html, urls and views Updated login.html, urls.py,views.py --- AppStore/urls.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/AppStore/urls.py b/AppStore/urls.py index 349db7c79..a647a0900 100644 --- a/AppStore/urls.py +++ b/AppStore/urls.py @@ -21,12 +21,12 @@ urlpatterns = [ path('admin/', admin.site.urls), + path('', app.views.index_products, name='products'), ##path('', app.views.index, name='index'), - path('add', app.views.add, name='add'), - path('buy', app.views.buy, name='buy') + path('add/', app.views.add, name='add'), + path('buy/', app.views.buy, name='buy') path('view/', app.views.view, name='view'), path('edit/', app.views.edit, name='edit'), - path('login', app.views.login, name='login'), - path('', app.views.index_products, name='products'), - path('purchase', app.views.purchase, name='purchase'), + path('login/', app.views.login, name='login'), + path('purchase/', app.views.purchase, name='purchase'), ] From 758b9e374a4c77cb42b129e6a98369957877f159 Mon Sep 17 00:00:00 2001 From: Brandon Tan <101177183+Aeromon@users.noreply.github.com> Date: Thu, 24 Mar 2022 19:16:14 +0800 Subject: [PATCH 017/147] Update urls.py --- AppStore/urls.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/AppStore/urls.py b/AppStore/urls.py index 349db7c79..a647a0900 100644 --- a/AppStore/urls.py +++ b/AppStore/urls.py @@ -21,12 +21,12 @@ urlpatterns = [ path('admin/', admin.site.urls), + path('', app.views.index_products, name='products'), ##path('', app.views.index, name='index'), - path('add', app.views.add, name='add'), - path('buy', app.views.buy, name='buy') + path('add/', app.views.add, name='add'), + path('buy/', app.views.buy, name='buy') path('view/', app.views.view, name='view'), path('edit/', app.views.edit, name='edit'), - path('login', app.views.login, name='login'), - path('', app.views.index_products, name='products'), - path('purchase', app.views.purchase, name='purchase'), + path('login/', app.views.login, name='login'), + path('purchase/', app.views.purchase, name='purchase'), ] From 0c0588d4c5aa06bfd800a857bad3b70acb925aad Mon Sep 17 00:00:00 2001 From: Aeromon Date: Thu, 24 Mar 2022 20:20:06 +0800 Subject: [PATCH 018/147] testing purchase.html, urls and views Updated login.html, urls.py,views.py --- app/models.py | 16 ++++++++++++++++ app/views.py | 4 +--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/models.py b/app/models.py index e69de29bb..3de114693 100644 --- a/app/models.py +++ b/app/models.py @@ -0,0 +1,16 @@ +from django.db import models +# Create your models here. +class User(models.Model): + username = models.CharField(max_length=45) + password = models.CharField(max_length=45) + email = models.EmailField() + balance = models.DecimalField(max_digits=6, decimal_places=2) + firstname = models.CharField(max_length=56) + lastname = models.CharField(max_length=45) + cellphone = models.CharField(max_length=14) + address = models.CharField(max_length=255) + town = models.CharField(max_length=45) + post_code = models.CharField(max_length=45) + country = models.CharField(max_length=45) + +class Product(models.Model): \ No newline at end of file diff --git a/app/views.py b/app/views.py index 73440f6d2..f4a4638f3 100644 --- a/app/views.py +++ b/app/views.py @@ -105,10 +105,8 @@ def login(request): customer = cursor.fetchone() ## No customer with same id if customer == None: - ##TODO: date validation cursor.execute("INSERT INTO customers VALUES (%s, %s, %s, %s, %s, %s, %s)" - , [request.POST['first_name'], request.POST['last_name'], request.POST['email'], - request.POST['dob'] , request.POST['since'], request.POST['customerid'], request.POST['country'] ]) + , [request.POST['first_name'], request.POST['last_name']]) return redirect('index') else: status = 'Your User Id and Password is incorrect' % (request.POST['customerid']) From 40f3979e1a79fcd8ae14d73abbd80e9cfb3ab241 Mon Sep 17 00:00:00 2001 From: Aeromon Date: Thu, 24 Mar 2022 20:22:04 +0800 Subject: [PATCH 019/147] testing purchase.html, urls and views Updated login.html, urls.py,views.py --- app/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views.py b/app/views.py index f4a4638f3..c8b761f8b 100644 --- a/app/views.py +++ b/app/views.py @@ -105,7 +105,7 @@ def login(request): customer = cursor.fetchone() ## No customer with same id if customer == None: - cursor.execute("INSERT INTO customers VALUES (%s, %s, %s, %s, %s, %s, %s)" + cursor.execute("INSERT INTO customers VALUES (%s, %s)" , [request.POST['first_name'], request.POST['last_name']]) return redirect('index') else: From e8379a506c79f598e5c233e512ca20ba4a6d5466 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Thu, 24 Mar 2022 22:42:54 +0800 Subject: [PATCH 020/147] Add files via upload --- sql/allusersdata.sql | 60 ++++++++++++++++++++++++++++++++++++++++++++ sql/productsdata.sql | 40 +++++++++++++++++++++++++++++ sql/transdata.sql | 20 +++++++++++++++ 3 files changed, 120 insertions(+) create mode 100644 sql/allusersdata.sql create mode 100644 sql/productsdata.sql create mode 100644 sql/transdata.sql diff --git a/sql/allusersdata.sql b/sql/allusersdata.sql new file mode 100644 index 000000000..b3b6d7b2a --- /dev/null +++ b/sql/allusersdata.sql @@ -0,0 +1,60 @@ +INSERT INTO allusers(userid,phoneno,password) VALUES ('tcollabine0',6285832565,'PCQxrGeU'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('lgaddas1',2253804958,'Xz0rOUUUEl'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('bkaubisch2',7712801575,'nsPynTV6k'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('ckulas3',1558928939,'NCjmH6QIgRmG'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('dlawey4',6169476060,'5pM6LrExm96'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('slurcock5',6694624405,'FKUHAZRHav'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('rparmeter6',5878515972,'3I8xvw'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('mstollard7',7861262615,'Lz5WcLv3Z66'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('dantunes8',8844753986,'ZTJGPy'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('dwallbridge9',9938377362,'naFqQn2RXOG'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('tbrewetta',8082904722,'NYpqORmP5Ra2'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('aodornanb',6316821408,'9x0eZtJ8u'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('mwhysallc',6224005791,'eecBV9rwSbc'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('mriseboroughd',5359337509,'GXoGXgrHhmL'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('rarrowsmithe',1156113166,'WunNnpKaykL'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('boscanlanf',7247137333,'9ZsbPBCzYVr'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('lfontenotg',4334733116,'OB2MB3IJB'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('nskalah',8489550491,'zyYDSRxLtEcI'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('gollarenshawi',2246828669,'TsOpVSMHB'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('nzannollij',1436732744,'hJMlJqoh'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('romullallyk',8411556652,'z9sDzWE71hhA'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('dledgerl',1503069846,'BseL6r'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('vcarneckm',9976903369,'DkKEA3'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('rdysartn',9428985599,'mY1jG9RPnL'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('wratchfordo',6677843909,'8bLy10CfpSw'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('cfiginp',9792286533,'XhYUGXxVO'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('mjozsikaq',6292040762,'YbCOWQD'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('ejulyanr',4752728626,'c3YSgVo3'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('wgallys',1572961053,'TzOKYdE'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('jmatisset',1508592599,'UrJpGKMjJfqf'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('lmiddletonu',1524260059,'q2nKqf'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('sgallardv',3447670274,'acH36NpsnK'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('dgodfrayw',4743171560,'ZOKZje'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('aphysicx',2927408787,'vLop8lxWC8'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('mlomaxy',9657782784,'NfopKuQu'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('klinforthz',9977904481,'U8QGtHoE3K'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('nhourstan10',3121040783,'lxAdU3kcb'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('kpatridge11',3745570419,'ax8QzkC5'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('rguice12',3773826039,'cvzH6t'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('dmein13',2604513172,'mdE0zrzxCxj'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('rcamilleri14',1828651155,'qullFOp08V'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('lshreve15',7799267681,'IZdaR7xBBKzJ'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('msodeau16',5247008815,'hrVk9IDoUY'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('eskamal17',4431469231,'eesz9ckLt'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('kdaout18',1555993974,'Y2ykGP2d'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('mpollock19',7343163085,'PJDAnA'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('pmacgilfoyle1a',8845658668,'wX4aT76yT'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('rhillan1b',1345477519,'FjX3BXfo3y'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('mchampain1c',6452774714,'9cnhv9Da'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('cwaliszek1d',4709908272,'7oA7OeYSi52'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('kpemberton1e',8917122663,'aIaM24sNyFy'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('dbodycombe1f',8395936976,'BbO7SumXB'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('achellingworth1g',4579015248,'nxbKQIyGxx'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('apavlishchev1h',2271307656,'xdm2qii'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('gsherel1i',9486712033,'LFMoVKM4WTL'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('mlawrey1j',2072575793,'uG0Bbx87V'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('obrosh1k',9422440139,'JkRxgMRhc65'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('nshreeves1l',1811466717,'LUo1MtKl'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('rdigginson1m',9087635100,'OLEWn7FEF'); +INSERT INTO allusers(userid,phoneno,password) VALUES ('krannie1n',5709108692,'kmGl9Ov0u'); diff --git a/sql/productsdata.sql b/sql/productsdata.sql new file mode 100644 index 000000000..feda1bb0b --- /dev/null +++ b/sql/productsdata.sql @@ -0,0 +1,40 @@ +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('mchampain1c', 'Basque Cheesecake', 'Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vivamus vestibulum sagittis sapien.', 5.1, 'dessert', 'dairy-free', 4); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('rdysartn', 'Indonesian Keropok', 'Curabitur gravida nisi at nibh.', 59.0, 'dessert', 'nut-free', 22); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('nzannollij', 'Basque Cheesecake', 'Nullam porttitor lacus at turpis.', 43.4, 'ready meals', 'gluten-free', 30); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('kpemberton1e', 'Salted Egg Cookies', 'Donec odio justo, sollicitudin ut, suscipit a, feugiat et, eros.', 50.2, 'pastries', 'egg-free', 20); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('dbodycombe1f', 'Curry filled bun', 'Maecenas ut massa quis augue luctus tincidunt.', 57.8, 'dessert', 'dairy-free', 32); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('aphysicx', 'Pasta', 'Etiam vel augue. Vestibulum rutrum rutrum neque.', 6.4, 'drinks', 'nut-free', 29); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('nzannollij', 'Tulang', 'In blandit ultrices enim. Lorem ipsum dolor sit amet, consectetuer adipiscing elit.', 10.8, 'dessert', 'dairy-free', 5); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('nzannollij', 'Crème Brulee Macaron', 'Morbi non quam nec dui luctus rutrum.', 47.4, 'pastries', 'egg-free', 1); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('nhourstan10', 'Salted Egg Cookies', 'Maecenas tristique, est et tempus semper, est quam pharetra magna, ac consequat metus sapien ut nunc. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Mauris viverra diam vitae quam.', 29.1, 'pastries', 'dairy-free', 21); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('mlawrey1j', 'Baklava Rings', 'Donec ut dolor. Morbi vel lectus in quam fringilla rhoncus. Mauris enim leo, rhoncus sed, vestibulum sit amet, cursus id, turpis.', 19.6, 'drinks', 'nut-free', 8); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('kpatridge11', 'Tulang', 'Duis bibendum, felis sed interdum venenatis, turpis enim blandit mi, in porttitor pede justo eu massa.', 9.7, 'pastries', 'egg-free', 12); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('nzannollij', 'Banana Pudding', 'Vivamus vel nulla eget eros elementum pellentesque.', 9.8, 'dessert', 'egg-free', 45); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('wratchfordo', 'Laska', 'Aenean auctor gravida sem. Praesent id massa id nisl venenatis lacinia.', 38.6, 'pastries', 'egg-free', 37); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('dbodycombe1f', 'Indonesian Keropok', 'Sed ante.', 19.1, 'drinks', 'nut-free', 22); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('wratchfordo', 'Nutella Butter Cookies', 'In hac habitasse platea dictumst.', 10.3, 'drinks', 'gluten-free', 46); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('aphysicx', 'Duo Flavour Cinnamon Roll', 'Vivamus vel nulla eget eros elementum pellentesque.', 54.6, 'dessert', 'nut-free', 11); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('eskamal17', 'Curry filled bun', 'Proin eu mi. Nulla ac enim. In tempor, turpis nec euismod scelerisque, quam turpis adipiscing lorem, vitae mattis nibh ligula nec sem.', 16.7, 'drinks', 'dairy-free', 8); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('romullallyk', 'Durian Chocolate Cakes', 'Nullam varius.', 46.9, 'ready meals', 'nut-free', 13); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('pmacgilfoyle1a', 'Chili Manis', 'Nulla ut erat id mauris vulputate elementum. Nullam varius. Nulla facilisi.', 21.3, 'dessert', 'gluten-free', 39); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('mpollock19', 'Pasta', 'Fusce congue, diam id ornare imperdiet, sapien urna pretium nisl, ut volutpat sapien arcu sed augue.', 59.6, 'dessert', 'egg-free', 40); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('jmatisset', 'Curry filled bun', 'In blandit ultrices enim.', 22.5, 'pastries', 'dairy-free', 12); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('lshreve15', 'Baklava Rings', 'Quisque id justo sit amet sapien dignissim vestibulum. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nulla dapibus dolor vel est. Donec odio justo, sollicitudin ut, suscipit a, feugiat et, eros.', 32.1, 'ready meals', 'nut-free', 16); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('wratchfordo', 'Tulang', 'Donec posuere metus vitae ipsum. Aliquam non mauris. Morbi non lectus.', 20.1, 'dessert', 'gluten-free', 0); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('dmein13', 'Ang Ku Kueh', 'Integer a nibh. In quis justo.', 42.7, 'dessert', 'egg-free', 36); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('mjozsikaq', 'Chili Manis', 'Integer ac leo.', 41.6, 'pastries', 'dairy-free', 17); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('slurcock5', 'Matcha Speculoos', 'Nam congue, risus semper porta volutpat, quam pede lobortis ligula, sit amet eleifend pede libero quis orci. Nullam molestie nibh in lectus. Pellentesque at nulla.', 58.8, 'ready meals', 'gluten-free', 32); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('gsherel1i', 'Biscoff-filled cookies', 'Morbi non lectus.', 31.5, 'drinks', 'gluten-free', 32); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('cwaliszek1d', 'Curry filled bun', 'Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec pharetra, magna vestibulum aliquet ultrices, erat tortor sollicitudin mi, sit amet lobortis sapien sapien non mi. Integer ac neque. Duis bibendum.', 16.5, 'ready meals', 'egg-free', 40); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('rcamilleri14', 'Durian Chocolate Cakes', 'Mauris lacinia sapien quis libero. Nullam sit amet turpis elementum ligula vehicula consequat. Morbi a ipsum.', 10.2, 'drinks', 'dairy-free', 29); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('msodeau16', 'Hakka Yong Tau Foo', 'Nunc purus. Phasellus in felis.', 17.8, 'drinks', 'nut-free', 2); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('dledgerl', 'Durian Chocolate Cakes', 'Integer ac neque. Duis bibendum.', 31.8, 'pastries', 'gluten-free', 22); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('eskamal17', 'Biscoff-filled cookies', 'Morbi vestibulum, velit id pretium iaculis, diam erat fermentum justo, nec condimentum neque sapien placerat ante. Nulla justo. Aliquam quis turpis eget elit sodales scelerisque.', 3.7, 'dessert', 'egg-free', 18); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('ejulyanr', 'Basque Cheesecake', 'Duis bibendum, felis sed interdum venenatis, turpis enim blandit mi, in porttitor pede justo eu massa.', 24.2, 'ready meals', 'dairy-free', 18); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('boscanlanf', 'Duo Flavour Cinnamon Roll', 'Phasellus in felis. Donec semper sapien a libero. Nam dui.', 42.9, 'drinks', 'nut-free', 7); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('dmein13', 'Caramelised Onions Sourdough Loaf', 'Aenean lectus. Pellentesque eget nunc. Donec quis orci eget orci vehicula condimentum.', 43.8, 'pastries', 'gluten-free', 7); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('lfontenotg', 'Durian Chocolate Cakes', 'Duis bibendum, felis sed interdum venenatis, turpis enim blandit mi, in porttitor pede justo eu massa.', 45.6, 'ready meals', 'egg-free', 50); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('lmiddletonu', 'Laska', 'Integer aliquet, massa id lobortis convallis, tortor risus dapibus augue, vel accumsan tellus nisi eu orci. Mauris lacinia sapien quis libero. Nullam sit amet turpis elementum ligula vehicula consequat.', 26.9, 'dessert', 'dairy-free', 41); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('kdaout18', 'Baklava Rings', 'Integer pede justo, lacinia eget, tincidunt eget, tempus vel, pede.', 6.9, 'pastries', 'nut-free', 6); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('aphysicx', 'Laska', 'Morbi porttitor lorem id ligula. Suspendisse ornare consequat lectus. In est risus, auctor sed, tristique in, tempus sit amet, sem.', 18.8, 'pastries', 'gluten-free', 14); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('dwallbridge9', 'Biscoff-filled cookies', 'Donec quis orci eget orci vehicula condimentum.', 5.5, 'dessert', 'egg-free', 3); \ No newline at end of file diff --git a/sql/transdata.sql b/sql/transdata.sql new file mode 100644 index 000000000..ce5f63b16 --- /dev/null +++ b/sql/transdata.sql @@ -0,0 +1,20 @@ +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('pmacgilfoyle1a','kdaout18',48,87,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('eskamal17','dmein13',45,7,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('dwallbridge9','wratchfordo',33,70,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('mlawrey1j','nzannollij',17,60,'self pickup','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('wgallys','msodeau16',40,50,'self pickup','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('nshreeves1l','nhourstan10',19,70,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('rparmeter6','dbodycombe1f',15,99,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('lmiddletonu','dbodycombe1f',24,79,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('eskamal17','dmein13',34,72,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('wgallys','rdysartn',12,17,'self pickup','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('lfontenotg','lmiddletonu',47,95,'self pickup','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('lgaddas1','kpatridge11',21,12,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('lshreve15','dwallbridge9',50,95,'self pickup','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('lfontenotg','mlawrey1j',20,34,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('cfiginp','ejulyanr',43,44,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('mlomaxy','nhourstan10',19,59,'self pickup','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('eskamal17','wratchfordo',25,21,'self pickup','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('jmatisset','rdysartn',12,60,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('mchampain1c','dledgerl',41,34,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('ejulyanr','dbodycombe1f',24,13,'delivery','pending'); From ce9c2e88ffae0bc8dcfd330959a7372638bb2011 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Thu, 24 Mar 2022 22:48:59 +0800 Subject: [PATCH 021/147] Update add_sql.sh --- add_sql.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/add_sql.sh b/add_sql.sh index 2304183ff..a4cde8f05 100755 --- a/add_sql.sh +++ b/add_sql.sh @@ -28,8 +28,8 @@ done < ".env" URI="postgres://$DB_USER:$DB_PASSWORD@$DB_HOST:$DB_PORT/$DB_NAME" # Run the scripts to insert data. -psql ${URI} -f sql/AppStoreClean.sql -psql ${URI} -f sql/AppStoreSchema.sql -psql ${URI} -f sql/AppStoreCustomers.sql -psql ${URI} -f sql/AppStoreGames.sql -psql ${URI} -f sql/AppStoreDownloads.sql +psql ${URI} -f sql/allusersdata.sql +psql ${URI} -f sql/TheMakanNetworkSchema.sql +psql ${URI} -f sql/productsdata.sql +psql ${URI} -f sql/transdata.sql + From a735b637213e91849df6a398539d8a770a474a52 Mon Sep 17 00:00:00 2001 From: Brandon Tan <101177183+Aeromon@users.noreply.github.com> Date: Thu, 24 Mar 2022 22:50:39 +0800 Subject: [PATCH 022/147] Update models.py --- app/models.py | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/app/models.py b/app/models.py index 3de114693..8b1378917 100644 --- a/app/models.py +++ b/app/models.py @@ -1,16 +1 @@ -from django.db import models -# Create your models here. -class User(models.Model): - username = models.CharField(max_length=45) - password = models.CharField(max_length=45) - email = models.EmailField() - balance = models.DecimalField(max_digits=6, decimal_places=2) - firstname = models.CharField(max_length=56) - lastname = models.CharField(max_length=45) - cellphone = models.CharField(max_length=14) - address = models.CharField(max_length=255) - town = models.CharField(max_length=45) - post_code = models.CharField(max_length=45) - country = models.CharField(max_length=45) -class Product(models.Model): \ No newline at end of file From 2ccd57870b3533b3715a3dec0cbcf435a77e0ee3 Mon Sep 17 00:00:00 2001 From: Aeromon Date: Thu, 24 Mar 2022 22:57:56 +0800 Subject: [PATCH 023/147] testing purchase.html, urls and views Updated login.html, urls.py,views.py --- app/templates/app/index_products.html | 10 +++++----- app/views.py | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/templates/app/index_products.html b/app/templates/app/index_products.html index 81e486609..352bcc609 100644 --- a/app/templates/app/index_products.html +++ b/app/templates/app/index_products.html @@ -18,12 +18,12 @@

The Makan Network

Price Description - {% for cust in records %} + {% for product in products %} - {{ cust.5 }} - {{ cust.0 }} - {{ cust.1 }} - {{ cust.2 }} + {{ product.0 }} + {{ product.2 }} + {{ product.4 }} + {{ product.3 }} diff --git a/app/views.py b/app/views.py index c8b761f8b..136caddd9 100644 --- a/app/views.py +++ b/app/views.py @@ -120,10 +120,10 @@ def index_products(request): ## Use raw query to get all objects with connection.cursor() as cursor: - cursor.execute("SELECT * FROM customers ORDER BY customerid") + cursor.execute("SELECT * FROM products ORDER BY productid") customers = cursor.fetchall() - result_dict = {'records': customers} + result_dict = {'records': products} return render(request, 'app/index_products.html', result_dict) @@ -143,3 +143,4 @@ def buy(request): """This function enables the buy button on the purchase page""" context = {} status = '' + cursor.execute("INSERT INTO transaction VALUES (%s)" \ No newline at end of file From 7dfc2903e7bab12b521a6d796586a5f948da09cc Mon Sep 17 00:00:00 2001 From: Aeromon Date: Thu, 24 Mar 2022 23:03:47 +0800 Subject: [PATCH 024/147] testing purchase.html, urls and views Updated login.html, urls.py,views.py --- AppStore/urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AppStore/urls.py b/AppStore/urls.py index a647a0900..fb107c7f6 100644 --- a/AppStore/urls.py +++ b/AppStore/urls.py @@ -24,7 +24,7 @@ path('', app.views.index_products, name='products'), ##path('', app.views.index, name='index'), path('add/', app.views.add, name='add'), - path('buy/', app.views.buy, name='buy') + path('buy/', app.views.buy, name='buy'), path('view/', app.views.view, name='view'), path('edit/', app.views.edit, name='edit'), path('login/', app.views.login, name='login'), From e082022ce433d05ed55ba0c2560d7ab07e095de0 Mon Sep 17 00:00:00 2001 From: Aeromon Date: Thu, 24 Mar 2022 23:14:00 +0800 Subject: [PATCH 025/147] testing purchase.html, urls and views Updated login.html, urls.py,views.py --- app/views.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/views.py b/app/views.py index 136caddd9..236e3a67f 100644 --- a/app/views.py +++ b/app/views.py @@ -139,8 +139,3 @@ def purchase(request): return render(request, 'app/purchase.html', result_dict) -def buy(request): - """This function enables the buy button on the purchase page""" - context = {} - status = '' - cursor.execute("INSERT INTO transaction VALUES (%s)" \ No newline at end of file From 62422d79439fa7b8921ef83b4c0d822751393015 Mon Sep 17 00:00:00 2001 From: Aeromon Date: Thu, 24 Mar 2022 23:16:52 +0800 Subject: [PATCH 026/147] testing purchase.html, urls and views Updated login.html, urls.py,views.py --- AppStore/urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AppStore/urls.py b/AppStore/urls.py index fb107c7f6..7223a317d 100644 --- a/AppStore/urls.py +++ b/AppStore/urls.py @@ -24,7 +24,7 @@ path('', app.views.index_products, name='products'), ##path('', app.views.index, name='index'), path('add/', app.views.add, name='add'), - path('buy/', app.views.buy, name='buy'), + ##path('buy/', app.views.buy, name='buy'), path('view/', app.views.view, name='view'), path('edit/', app.views.edit, name='edit'), path('login/', app.views.login, name='login'), From f9cce2a5bcdda509c65faf89177a89163573d3da Mon Sep 17 00:00:00 2001 From: Aeromon Date: Thu, 24 Mar 2022 23:24:05 +0800 Subject: [PATCH 027/147] testing purchase.html, urls and views Updated login.html, urls.py,views.py --- app/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views.py b/app/views.py index 236e3a67f..4287353bf 100644 --- a/app/views.py +++ b/app/views.py @@ -121,9 +121,9 @@ def index_products(request): ## Use raw query to get all objects with connection.cursor() as cursor: cursor.execute("SELECT * FROM products ORDER BY productid") - customers = cursor.fetchall() + products = cursor.fetchall() - result_dict = {'records': products} + result_dict = {'products': products} return render(request, 'app/index_products.html', result_dict) From 3ee1359544f5d7bc51cbba46c7e26f59c2efec8f Mon Sep 17 00:00:00 2001 From: Brandon Tan <101177183+Aeromon@users.noreply.github.com> Date: Thu, 24 Mar 2022 23:39:48 +0800 Subject: [PATCH 028/147] Rename TheMakanNetworkSchema to TheMakanNetworkSchema.sql --- sql/{TheMakanNetworkSchema => TheMakanNetworkSchema.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sql/{TheMakanNetworkSchema => TheMakanNetworkSchema.sql} (100%) diff --git a/sql/TheMakanNetworkSchema b/sql/TheMakanNetworkSchema.sql similarity index 100% rename from sql/TheMakanNetworkSchema rename to sql/TheMakanNetworkSchema.sql From fd169ec7c0383f8c1d4de1e399ba0ba35aec57e4 Mon Sep 17 00:00:00 2001 From: Brandon Tan <101177183+Aeromon@users.noreply.github.com> Date: Thu, 24 Mar 2022 23:42:46 +0800 Subject: [PATCH 029/147] Update add_sql.sh --- add_sql.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/add_sql.sh b/add_sql.sh index a4cde8f05..805d5bdd3 100755 --- a/add_sql.sh +++ b/add_sql.sh @@ -28,8 +28,8 @@ done < ".env" URI="postgres://$DB_USER:$DB_PASSWORD@$DB_HOST:$DB_PORT/$DB_NAME" # Run the scripts to insert data. -psql ${URI} -f sql/allusersdata.sql psql ${URI} -f sql/TheMakanNetworkSchema.sql +psql ${URI} -f sql/allusersdata.sql psql ${URI} -f sql/productsdata.sql psql ${URI} -f sql/transdata.sql From af36264105f490b560fd460a3afe5da7df3dc533 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Thu, 24 Mar 2022 23:45:24 +0800 Subject: [PATCH 030/147] Add files via upload --- sql/clean.sql | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 sql/clean.sql diff --git a/sql/clean.sql b/sql/clean.sql new file mode 100644 index 000000000..88fa494fc --- /dev/null +++ b/sql/clean.sql @@ -0,0 +1,17 @@ + +DROP TABLE IF EXISTS allusers CASCADE; +DROP TABLE IF EXISTS products CASCADE; +DROP TABLE IF EXISTS transactions CASCADE; +DROP TABLE IF EXISTS sellers CASCADE; +DROP TABLE IF EXISTS buyers CASCADE; +DROP TABLE IF EXISTS reviews CASCADE; +DROP TRIGGER IF EXISTS update_sellers on products; +DROP TRIGGER IF EXISTS check_status on transactions; + + +/* +SELECT * FROM allusers; +SELECT * FROM products; +SELECT * FROM transactions; +SELECT * FROM reviews; +*/ \ No newline at end of file From dcbb4f4c521c1eda670925403a11ae31a3439a1a Mon Sep 17 00:00:00 2001 From: Brandon Tan <101177183+Aeromon@users.noreply.github.com> Date: Thu, 24 Mar 2022 23:46:49 +0800 Subject: [PATCH 031/147] Update add_sql.sh --- add_sql.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/add_sql.sh b/add_sql.sh index 805d5bdd3..7c903b352 100755 --- a/add_sql.sh +++ b/add_sql.sh @@ -28,6 +28,7 @@ done < ".env" URI="postgres://$DB_USER:$DB_PASSWORD@$DB_HOST:$DB_PORT/$DB_NAME" # Run the scripts to insert data. +psql ${URI} -f sql/clean.sql psql ${URI} -f sql/TheMakanNetworkSchema.sql psql ${URI} -f sql/allusersdata.sql psql ${URI} -f sql/productsdata.sql From 09a9c836fc1bb01031369616ef52fe77821ce738 Mon Sep 17 00:00:00 2001 From: wanfeijong <37286614+wanfeijong@users.noreply.github.com> Date: Thu, 24 Mar 2022 23:49:35 +0800 Subject: [PATCH 032/147] Add files via upload --- sql/appschema.sql | 183 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100644 sql/appschema.sql diff --git a/sql/appschema.sql b/sql/appschema.sql new file mode 100644 index 000000000..9911cd476 --- /dev/null +++ b/sql/appschema.sql @@ -0,0 +1,183 @@ +--table of all the users on the app +--userid is username +CREATE TABLE IF NOT EXISTS allusers ( +userid varchar(16) not null unique, +phoneno bigint primary key, +password varchar(12) not null +); + +--table of all the products ever listed +-- change price to decimal +CREATE TABLE IF NOT EXISTS products ( +productid INT GENERATED BY DEFAULT AS IDENTITY + (START WITH 1 INCREMENT BY 1) primary key, +sellerid varchar(16) not null, +name varchar(64) not null, +description varchar(256) not null, +price decimal not null check(price>0), +category varchar(32) constraint category CHECK(category = 'dessert' OR category='ready meals' OR category='pastries' OR category='drinks'), +allergen varchar(32) not null, +minorder int not null check(minorder>=0), +foreign key(sellerid) references allusers(userid), +unique(productid, sellerid) +); + +--table of all the order details/transaction details +CREATE TABLE IF NOT EXISTS transactions ( +orderid INT GENERATED BY DEFAULT AS IDENTITY + (START WITH 1 INCREMENT BY 1) primary key, +b_id varchar(16) not null, +s_id varchar(16) not null, +p_id int references products(productid), +qty int not null check(qty>0), +delivery varchar(12) not null check(delivery='self pickup' OR delivery='delivery'), +status varchar(10) not null check(status='pending' OR status='confirmed'), +foreign key(b_id) references allusers(userid), +foreign key(s_id, p_id) references products(sellerid, productid), +check(not b_id = s_id) +); + +--table to store all the ratings for products +--primary key: b_id + p_id +CREATE TABLE IF NOT EXISTS product_ratings ( +b_id references transaction +) + + +--table to track which users bought products before +--user inserted when user inserts into transaction table -> trigger +--product id is integer i.e. 01245 +CREATE TABLE IF NOT EXISTS buyers ( +b_id varchar(16) primary key +); + +--TRIGGER TO ADD USER INTO BUYER TABLE + +CREATE OR REPLACE FUNCTION new_buyer() + RETURNS trigger AS +$$ +BEGIN + INSERT INTO buyers(b_id) + VALUES(NEW.b_id) on conflict do nothing; + + RETURN NEW; +END; +$$ +LANGUAGE 'plpgsql'; + +CREATE TRIGGER update_buyers + AFTER INSERT + ON transactions + FOR EACH ROW + EXECUTE PROCEDURE new_buyer(); + + +--table of all users who have ever sold a product +-- users inserted into this table when a product is inserted into the products table -> trigger +CREATE TABLE IF NOT EXISTS sellers ( +s_id varchar(16) primary key +); + +--TRIGGER TO ADD USER INTO SELLER TABLE +CREATE OR REPLACE FUNCTION new_seller() + RETURNS trigger AS +$$ +BEGIN + INSERT INTO sellers(s_id) + VALUES(NEW.sellerid) on conflict do nothing; + + RETURN NEW; +END; +$$ +LANGUAGE 'plpgsql'; + +CREATE TRIGGER update_sellers + AFTER INSERT + ON products + FOR EACH ROW + EXECUTE PROCEDURE new_seller(); + + +--if we delete the product then user still a seller + +--TRIGGER TO CHANGE STATUS +CREATE OR REPLACE FUNCTION updatestatus() +RETURNS trigger AS +$$ +declare + total INT; + minord INT; + +BEGIN + select sum(qty) from transactions where p_id=new.p_id into total; + select minorder from products where productid=new.p_id into minord; + if total >= minord then + UPDATE transactions SET status = 'confirmed' WHERE p_id = new.p_id; + RETURN new; + end if; + RETURN new; +END; +$$ + LANGUAGE 'plpgsql'; + +CREATE TRIGGER statusupdate +AFTER INSERT +ON transactions +FOR EACH ROW +EXECUTE PROCEDURE updatestatus(); + + + +--DROPPING ignore +DELETE FROM allusers; +DELETE FROM transactions; + +drop trigger if exists statusupdate on transactions; + +DROP TRIGGER update_buyers on transactions; + +DROP TABLE IF EXISTS allusers; +DROP TABLE IF EXISTS products; +DROP TABLE IF EXISTS transactions; +DROP TABLE IF EXISTS sellers; +DROP TABLE IF EXISTS buyers; + +DROP TRIGGER IF EXISTS update_sellers on products; + + +--INSERTING TRIAL (ignore) +INSERT INTO transactions(b_id, s_id, p_id, qty, delivery, status) VALUES('sehun','baekhyun', 1, 2,'delivery', 'pending'); +INSERT INTO transactions(b_id, s_id, p_id, qty, delivery, status) VALUES('onew','kyungsoo', 4, 2,'delivery', 'pending'); +INSERT INTO transactions(b_id, s_id, p_id, qty, delivery, status) VALUES('onew','kyungsoo', 4, 2,'delivery', 'pending'); + +INSERT INTO transactions(b_id, s_id, p_id, qty, delivery, status) VALUES('onew','sehun',5,10,'delivery', 'pending'); + +INSERT INTO transactions(b_id, s_id, p_id, qty, delivery, status) VALUES('sehun', 'onew', 2, 20, 'self pickup', 'pending'); + + +INSERT INTO products(sellerid, name, description, category, allergen, price, minorder) VALUES('baekhyun', 'cookies', 'chocolate', 'dessert', 'nut-free',3, 0); +INSERT INTO products(sellerid, name, description, category, allergen, price, minorder) VALUES('kyungsoo', 'cookies', 'chocolate', 'dessert', 'nut-free',2, 0); +INSERT INTO products(sellerid, name, description, category, allergen,price, minorder) VALUES('sehun', 'pie', 'apple', 'dessert', 'nut-free',1, 5); +INSERT INTO products(sellerid, name, description, category, allergen,price, minorder) VALUES('onew', 'brownie', 'mochi brownies', 'dessert', 'none', 4, 30); + +INSERT INTO allusers VALUES('baekhyun', 90897162, 'password'); +INSERT INTO allusers VALUES('kyungsoo', 12345678, 'exodo'); +INSERT INTO allusers VALUES('sehun', 87654321, 'exosehun'); +INSERT INTO allusers VALUES('onew', 12141989, 'shinee'); + + +-- TESTING +SELECT * FROM public.products; +SELECT * FROM public.allusers; +SELECT * FROM public.sellers; +SELECT * FROM public.buyers; +SELECT * FROM public.transactions; + +SELECT COUNT(DISTINCT b_id) +from transactions + + +select sum(qty) +from transactions +where p_id=5; + From 16388013ce6fddc7fa205dc0b6627006d03799f1 Mon Sep 17 00:00:00 2001 From: wanfeijong <37286614+wanfeijong@users.noreply.github.com> Date: Thu, 24 Mar 2022 23:50:28 +0800 Subject: [PATCH 033/147] Update appschema.sql --- sql/appschema.sql | 74 ++--------------------------------------------- 1 file changed, 2 insertions(+), 72 deletions(-) diff --git a/sql/appschema.sql b/sql/appschema.sql index 9911cd476..951c6028b 100644 --- a/sql/appschema.sql +++ b/sql/appschema.sql @@ -1,13 +1,11 @@ ---table of all the users on the app ---userid is username + CREATE TABLE IF NOT EXISTS allusers ( userid varchar(16) not null unique, phoneno bigint primary key, password varchar(12) not null ); ---table of all the products ever listed --- change price to decimal + CREATE TABLE IF NOT EXISTS products ( productid INT GENERATED BY DEFAULT AS IDENTITY (START WITH 1 INCREMENT BY 1) primary key, @@ -22,7 +20,6 @@ foreign key(sellerid) references allusers(userid), unique(productid, sellerid) ); ---table of all the order details/transaction details CREATE TABLE IF NOT EXISTS transactions ( orderid INT GENERATED BY DEFAULT AS IDENTITY (START WITH 1 INCREMENT BY 1) primary key, @@ -37,21 +34,15 @@ foreign key(s_id, p_id) references products(sellerid, productid), check(not b_id = s_id) ); ---table to store all the ratings for products ---primary key: b_id + p_id CREATE TABLE IF NOT EXISTS product_ratings ( b_id references transaction ) ---table to track which users bought products before ---user inserted when user inserts into transaction table -> trigger ---product id is integer i.e. 01245 CREATE TABLE IF NOT EXISTS buyers ( b_id varchar(16) primary key ); ---TRIGGER TO ADD USER INTO BUYER TABLE CREATE OR REPLACE FUNCTION new_buyer() RETURNS trigger AS @@ -72,13 +63,10 @@ CREATE TRIGGER update_buyers EXECUTE PROCEDURE new_buyer(); ---table of all users who have ever sold a product --- users inserted into this table when a product is inserted into the products table -> trigger CREATE TABLE IF NOT EXISTS sellers ( s_id varchar(16) primary key ); ---TRIGGER TO ADD USER INTO SELLER TABLE CREATE OR REPLACE FUNCTION new_seller() RETURNS trigger AS $$ @@ -98,8 +86,6 @@ CREATE TRIGGER update_sellers EXECUTE PROCEDURE new_seller(); ---if we delete the product then user still a seller - --TRIGGER TO CHANGE STATUS CREATE OR REPLACE FUNCTION updatestatus() RETURNS trigger AS @@ -125,59 +111,3 @@ AFTER INSERT ON transactions FOR EACH ROW EXECUTE PROCEDURE updatestatus(); - - - ---DROPPING ignore -DELETE FROM allusers; -DELETE FROM transactions; - -drop trigger if exists statusupdate on transactions; - -DROP TRIGGER update_buyers on transactions; - -DROP TABLE IF EXISTS allusers; -DROP TABLE IF EXISTS products; -DROP TABLE IF EXISTS transactions; -DROP TABLE IF EXISTS sellers; -DROP TABLE IF EXISTS buyers; - -DROP TRIGGER IF EXISTS update_sellers on products; - - ---INSERTING TRIAL (ignore) -INSERT INTO transactions(b_id, s_id, p_id, qty, delivery, status) VALUES('sehun','baekhyun', 1, 2,'delivery', 'pending'); -INSERT INTO transactions(b_id, s_id, p_id, qty, delivery, status) VALUES('onew','kyungsoo', 4, 2,'delivery', 'pending'); -INSERT INTO transactions(b_id, s_id, p_id, qty, delivery, status) VALUES('onew','kyungsoo', 4, 2,'delivery', 'pending'); - -INSERT INTO transactions(b_id, s_id, p_id, qty, delivery, status) VALUES('onew','sehun',5,10,'delivery', 'pending'); - -INSERT INTO transactions(b_id, s_id, p_id, qty, delivery, status) VALUES('sehun', 'onew', 2, 20, 'self pickup', 'pending'); - - -INSERT INTO products(sellerid, name, description, category, allergen, price, minorder) VALUES('baekhyun', 'cookies', 'chocolate', 'dessert', 'nut-free',3, 0); -INSERT INTO products(sellerid, name, description, category, allergen, price, minorder) VALUES('kyungsoo', 'cookies', 'chocolate', 'dessert', 'nut-free',2, 0); -INSERT INTO products(sellerid, name, description, category, allergen,price, minorder) VALUES('sehun', 'pie', 'apple', 'dessert', 'nut-free',1, 5); -INSERT INTO products(sellerid, name, description, category, allergen,price, minorder) VALUES('onew', 'brownie', 'mochi brownies', 'dessert', 'none', 4, 30); - -INSERT INTO allusers VALUES('baekhyun', 90897162, 'password'); -INSERT INTO allusers VALUES('kyungsoo', 12345678, 'exodo'); -INSERT INTO allusers VALUES('sehun', 87654321, 'exosehun'); -INSERT INTO allusers VALUES('onew', 12141989, 'shinee'); - - --- TESTING -SELECT * FROM public.products; -SELECT * FROM public.allusers; -SELECT * FROM public.sellers; -SELECT * FROM public.buyers; -SELECT * FROM public.transactions; - -SELECT COUNT(DISTINCT b_id) -from transactions - - -select sum(qty) -from transactions -where p_id=5; - From 0d96cf83515db8aa4b2aa94256e7b4a248acbb92 Mon Sep 17 00:00:00 2001 From: wanfeijong <37286614+wanfeijong@users.noreply.github.com> Date: Thu, 24 Mar 2022 23:50:56 +0800 Subject: [PATCH 034/147] Update add_sql.sh --- add_sql.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/add_sql.sh b/add_sql.sh index 7c903b352..841fabcdc 100755 --- a/add_sql.sh +++ b/add_sql.sh @@ -29,7 +29,7 @@ URI="postgres://$DB_USER:$DB_PASSWORD@$DB_HOST:$DB_PORT/$DB_NAME" # Run the scripts to insert data. psql ${URI} -f sql/clean.sql -psql ${URI} -f sql/TheMakanNetworkSchema.sql +psql ${URI} -f sql/appschema.sql psql ${URI} -f sql/allusersdata.sql psql ${URI} -f sql/productsdata.sql psql ${URI} -f sql/transdata.sql From 0066616d11890af62f1b00f47dfa4cbf742032df Mon Sep 17 00:00:00 2001 From: wanfeijong <37286614+wanfeijong@users.noreply.github.com> Date: Fri, 25 Mar 2022 00:01:03 +0800 Subject: [PATCH 035/147] Delete transdata.sql --- sql/transdata.sql | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 sql/transdata.sql diff --git a/sql/transdata.sql b/sql/transdata.sql deleted file mode 100644 index ce5f63b16..000000000 --- a/sql/transdata.sql +++ /dev/null @@ -1,20 +0,0 @@ -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('pmacgilfoyle1a','kdaout18',48,87,'delivery','pending'); -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('eskamal17','dmein13',45,7,'delivery','pending'); -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('dwallbridge9','wratchfordo',33,70,'delivery','pending'); -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('mlawrey1j','nzannollij',17,60,'self pickup','pending'); -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('wgallys','msodeau16',40,50,'self pickup','pending'); -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('nshreeves1l','nhourstan10',19,70,'delivery','pending'); -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('rparmeter6','dbodycombe1f',15,99,'delivery','pending'); -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('lmiddletonu','dbodycombe1f',24,79,'delivery','pending'); -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('eskamal17','dmein13',34,72,'delivery','pending'); -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('wgallys','rdysartn',12,17,'self pickup','pending'); -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('lfontenotg','lmiddletonu',47,95,'self pickup','pending'); -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('lgaddas1','kpatridge11',21,12,'delivery','pending'); -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('lshreve15','dwallbridge9',50,95,'self pickup','pending'); -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('lfontenotg','mlawrey1j',20,34,'delivery','pending'); -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('cfiginp','ejulyanr',43,44,'delivery','pending'); -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('mlomaxy','nhourstan10',19,59,'self pickup','pending'); -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('eskamal17','wratchfordo',25,21,'self pickup','pending'); -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('jmatisset','rdysartn',12,60,'delivery','pending'); -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('mchampain1c','dledgerl',41,34,'delivery','pending'); -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('ejulyanr','dbodycombe1f',24,13,'delivery','pending'); From f2b2ab3ca17877068cbe14eda658097d6de28550 Mon Sep 17 00:00:00 2001 From: wanfeijong <37286614+wanfeijong@users.noreply.github.com> Date: Fri, 25 Mar 2022 00:01:23 +0800 Subject: [PATCH 036/147] Add files via upload --- sql/transdata.sql | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 sql/transdata.sql diff --git a/sql/transdata.sql b/sql/transdata.sql new file mode 100644 index 000000000..863df2e9e --- /dev/null +++ b/sql/transdata.sql @@ -0,0 +1,20 @@ +--INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('pmacgilfoyle1a','kdaout18',48,87,'delivery','pending'); +--INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('eskamal17','dmein13',45,7,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('dwallbridge9','wratchfordo',33,70,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('mlawrey1j','nzannollij',17,60,'self pickup','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('wgallys','msodeau16',40,50,'self pickup','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('nshreeves1l','nhourstan10',19,70,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('rparmeter6','dbodycombe1f',15,99,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('lmiddletonu','dbodycombe1f',24,79,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('eskamal17','dmein13',34,72,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('wgallys','rdysartn',12,17,'self pickup','pending'); +--INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('lfontenotg','lmiddletonu',47,95,'self pickup','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('lgaddas1','kpatridge11',21,12,'delivery','pending'); +--INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('lshreve15','dwallbridge9',50,95,'self pickup','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('lfontenotg','mlawrey1j',20,34,'delivery','pending'); +--INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('cfiginp','ejulyanr',43,44,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('mlomaxy','nhourstan10',19,59,'self pickup','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('eskamal17','wratchfordo',25,21,'self pickup','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('jmatisset','rdysartn',12,60,'delivery','pending'); +--INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('mchampain1c','dledgerl',41,34,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('ejulyanr','dbodycombe1f',24,13,'delivery','pending'); From 17475b6e048736662072186050737c8bca646e02 Mon Sep 17 00:00:00 2001 From: wanfeijong <37286614+wanfeijong@users.noreply.github.com> Date: Fri, 25 Mar 2022 00:15:04 +0800 Subject: [PATCH 037/147] Delete transdata.sql --- sql/transdata.sql | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 sql/transdata.sql diff --git a/sql/transdata.sql b/sql/transdata.sql deleted file mode 100644 index 863df2e9e..000000000 --- a/sql/transdata.sql +++ /dev/null @@ -1,20 +0,0 @@ ---INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('pmacgilfoyle1a','kdaout18',48,87,'delivery','pending'); ---INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('eskamal17','dmein13',45,7,'delivery','pending'); -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('dwallbridge9','wratchfordo',33,70,'delivery','pending'); -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('mlawrey1j','nzannollij',17,60,'self pickup','pending'); -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('wgallys','msodeau16',40,50,'self pickup','pending'); -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('nshreeves1l','nhourstan10',19,70,'delivery','pending'); -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('rparmeter6','dbodycombe1f',15,99,'delivery','pending'); -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('lmiddletonu','dbodycombe1f',24,79,'delivery','pending'); -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('eskamal17','dmein13',34,72,'delivery','pending'); -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('wgallys','rdysartn',12,17,'self pickup','pending'); ---INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('lfontenotg','lmiddletonu',47,95,'self pickup','pending'); -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('lgaddas1','kpatridge11',21,12,'delivery','pending'); ---INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('lshreve15','dwallbridge9',50,95,'self pickup','pending'); -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('lfontenotg','mlawrey1j',20,34,'delivery','pending'); ---INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('cfiginp','ejulyanr',43,44,'delivery','pending'); -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('mlomaxy','nhourstan10',19,59,'self pickup','pending'); -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('eskamal17','wratchfordo',25,21,'self pickup','pending'); -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('jmatisset','rdysartn',12,60,'delivery','pending'); ---INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('mchampain1c','dledgerl',41,34,'delivery','pending'); -INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('ejulyanr','dbodycombe1f',24,13,'delivery','pending'); From e5eac1d71181dcf8ffea9f946caf5881b3ff7295 Mon Sep 17 00:00:00 2001 From: wanfeijong <37286614+wanfeijong@users.noreply.github.com> Date: Fri, 25 Mar 2022 00:15:35 +0800 Subject: [PATCH 038/147] Add files via upload --- sql/transdata.sql | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 sql/transdata.sql diff --git a/sql/transdata.sql b/sql/transdata.sql new file mode 100644 index 000000000..6b4caae1a --- /dev/null +++ b/sql/transdata.sql @@ -0,0 +1,20 @@ +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('mstollard7','aphysicx',16,37,'self pickup','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('lfontenotg','dmein13',24,89,'self pickup','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('krannie1n','wratchfordo',23,87,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('lfontenotg','lshreve15',22,27,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('rarrowsmithe','aphysicx',39,24,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('nzannollij','pmacgilfoyle1a',19,80,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('slurcock5','nhourstan10',9,44,'self pickup','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('kdaout18','lshreve15',22,43,'self pickup','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('lgaddas1','eskamal17',32,47,'self pickup','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('dantunes8','dledgerl',31,47,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('rhillan1b','boscanlanf',34,48,'self pickup','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('dgodfrayw','jmatisset',21,98,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('mlawrey1j','aphysicx',6,7,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('achellingworth1g','eskamal17',17,38,'self pickup','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('mpollock19','ejulyanr',33,57,'self pickup','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('mstollard7','nhourstan10',9,55,'self pickup','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('msodeau16','mpollock19',20,48,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('kdaout18','nhourstan10',9,79,'self pickup','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('bkaubisch2','lmiddletonu',37,82,'delivery','pending'); +INSERT INTO transactions(b_id,s_id,p_id,qty,delivery,status) VALUES ('pmacgilfoyle1a','mlawrey1j',10,28,'delivery','pending'); From 6a134f1a3ff7eb5a00de1cc5c63c06cb8233c67b Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Fri, 25 Mar 2022 01:24:43 +0800 Subject: [PATCH 039/147] Update index_products.html --- app/templates/app/index_products.html | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/templates/app/index_products.html b/app/templates/app/index_products.html index 352bcc609..5789fc531 100644 --- a/app/templates/app/index_products.html +++ b/app/templates/app/index_products.html @@ -14,16 +14,24 @@

The Makan Network

+ - + + + + {% for product in products %} + - + + + + @@ -31,4 +39,4 @@

The Makan Network

{% endfor %}
IDSeller Product NamePrice DescriptionPriceCategoryAllergensMinimum Order Required
{{ product.0 }} {{ product.1 }} {{ product.2 }} {{ product.4 }} {{ product.3 }} {{ product.4 }} {{ product.5 }} {{ product.6 }} {{ product.7 }}
- \ No newline at end of file + From e72c8307b89542bfc9d33912596b803cb4d7ef24 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Fri, 25 Mar 2022 01:27:20 +0800 Subject: [PATCH 040/147] Update index_products.html --- app/templates/app/index_products.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/app/index_products.html b/app/templates/app/index_products.html index 5789fc531..362758845 100644 --- a/app/templates/app/index_products.html +++ b/app/templates/app/index_products.html @@ -33,7 +33,7 @@

The Makan Network

{{ product.6 }} {{ product.7 }} - + {% endfor %} From 2e2fa9a4f4f17e989cf028efed571c658810063b Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Fri, 25 Mar 2022 01:34:09 +0800 Subject: [PATCH 041/147] Update index_products.html --- app/templates/app/index_products.html | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/app/templates/app/index_products.html b/app/templates/app/index_products.html index 362758845..b15426b8d 100644 --- a/app/templates/app/index_products.html +++ b/app/templates/app/index_products.html @@ -14,13 +14,9 @@

The Makan Network

- - - - {% for product in products %} @@ -28,10 +24,7 @@

The Makan Network

- - - - + From a81e26b5fd8a66bd6592cca28ae0fd81dae7484a Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Fri, 25 Mar 2022 01:38:59 +0800 Subject: [PATCH 042/147] Update index_products.html --- app/templates/app/index_products.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/templates/app/index_products.html b/app/templates/app/index_products.html index b15426b8d..17bfaa7f0 100644 --- a/app/templates/app/index_products.html +++ b/app/templates/app/index_products.html @@ -17,13 +17,15 @@

The Makan Network

+ {% for product in products %} - + +
IDSeller Product Name Description PriceCategoryAllergensMinimum Order Required
{{ product.1 }} {{ product.2 }} {{ product.3 }} {{ product.4 }} {{ product.5 }} {{ product.6 }} {{ product.7 }} Product Name Description PriceCategory
{{ product.0 }} {{ product.1 }} {{ product.2 }} {{ product.3 }} {{ product.4 }} {{ product.5 }} From cfdc5cf3a352170944b78558ba3daba5dc749141 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Fri, 25 Mar 2022 01:41:41 +0800 Subject: [PATCH 043/147] Update purchase.html --- app/templates/app/purchase.html | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/app/templates/app/purchase.html b/app/templates/app/purchase.html index 24fc213c4..277ddd1f1 100644 --- a/app/templates/app/purchase.html +++ b/app/templates/app/purchase.html @@ -7,22 +7,24 @@ + - - + - + + - {% for cust in records %} + {% for product in products %} - - - - - - - + + + + + + + + {% endfor %} From e894654099a56e801f856089291a5dd20efb14c3 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Fri, 25 Mar 2022 14:31:10 +0800 Subject: [PATCH 045/147] Update views.py --- app/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views.py b/app/views.py index 4287353bf..d7710e4b3 100644 --- a/app/views.py +++ b/app/views.py @@ -133,9 +133,9 @@ def purchase(request): ## Use raw query to get all objects with connection.cursor() as cursor: cursor.execute("SELECT * FROM customers ORDER BY customerid") - customers = cursor.fetchall() + products = cursor.fetchall() - result_dict = {'records': customers} + result_dict = {'products': products} return render(request, 'app/purchase.html', result_dict) From 51fd4d1b3c6548fd6f4cd62e1a26f6354c5ed197 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Fri, 25 Mar 2022 14:36:15 +0800 Subject: [PATCH 046/147] Update views.py --- app/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views.py b/app/views.py index d7710e4b3..d89d06f93 100644 --- a/app/views.py +++ b/app/views.py @@ -132,7 +132,7 @@ def purchase(request): ## Use raw query to get all objects with connection.cursor() as cursor: - cursor.execute("SELECT * FROM customers ORDER BY customerid") + cursor.execute("SELECT * FROM products ORDER BY productid") products = cursor.fetchall() result_dict = {'products': products} From 89954179bb6873fdf37af8509dff71d56e6699d0 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Fri, 25 Mar 2022 15:21:56 +0800 Subject: [PATCH 047/147] Update views.py --- app/views.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views.py b/app/views.py index d89d06f93..4394a39a6 100644 --- a/app/views.py +++ b/app/views.py @@ -132,8 +132,9 @@ def purchase(request): ## Use raw query to get all objects with connection.cursor() as cursor: - cursor.execute("SELECT * FROM products ORDER BY productid") - products = cursor.fetchall() + cursor.execute("SELECT * FROM products p + WHERE p.productid = %s ",[productid]) + products = cursor.fetchone() result_dict = {'products': products} From 487a68dbf60975561be983bcd615aa8c2d13bc9d Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Fri, 25 Mar 2022 15:24:55 +0800 Subject: [PATCH 048/147] Update views.py --- app/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views.py b/app/views.py index 4394a39a6..4ed82e8dd 100644 --- a/app/views.py +++ b/app/views.py @@ -132,8 +132,8 @@ def purchase(request): ## Use raw query to get all objects with connection.cursor() as cursor: - cursor.execute("SELECT * FROM products p - WHERE p.productid = %s ",[productid]) + cursor.execute("SELECT * FROM products + WHERE productid = %s ",[productid]) products = cursor.fetchone() result_dict = {'products': products} From 1d6eb333a29dfea606625ec5af315cd5c95c470f Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Fri, 25 Mar 2022 15:30:35 +0800 Subject: [PATCH 049/147] Update views.py --- app/views.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/views.py b/app/views.py index 4ed82e8dd..5f18bdab3 100644 --- a/app/views.py +++ b/app/views.py @@ -127,13 +127,12 @@ def index_products(request): return render(request, 'app/index_products.html', result_dict) -def purchase(request): +def purchase(request, productid): """Shows the main page""" ## Use raw query to get all objects with connection.cursor() as cursor: - cursor.execute("SELECT * FROM products - WHERE productid = %s ",[productid]) + cursor.execute("SELECT * FROM product WHERE productid = %s",[productid]) products = cursor.fetchone() result_dict = {'products': products} From d052df5416200d819b4ebb912f979abad26991f2 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Fri, 25 Mar 2022 15:47:04 +0800 Subject: [PATCH 050/147] Update new_user.html --- app/templates/app/new_user.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/templates/app/new_user.html b/app/templates/app/new_user.html index 284126d0c..4c8e4becb 100644 --- a/app/templates/app/new_user.html +++ b/app/templates/app/new_user.html @@ -1,6 +1,9 @@ + + New User + + -

New User

Back to home

{{ status|safe }}

From 66f560da16ac1be6d4236d4082d41e4ff3b6a1b1 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Fri, 25 Mar 2022 15:50:55 +0800 Subject: [PATCH 051/147] Update new_user.html --- app/templates/app/new_user.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/templates/app/new_user.html b/app/templates/app/new_user.html index 4c8e4becb..8ef6ec29f 100644 --- a/app/templates/app/new_user.html +++ b/app/templates/app/new_user.html @@ -1,9 +1,10 @@ - New User + Register +

New User

Back to home

{{ status|safe }}

From ac8723ec30e05b912c8480dd656a497582936a27 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Fri, 25 Mar 2022 15:52:35 +0800 Subject: [PATCH 052/147] Update new_user.html --- app/templates/app/new_user.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/app/new_user.html b/app/templates/app/new_user.html index 8ef6ec29f..0d354db6e 100644 --- a/app/templates/app/new_user.html +++ b/app/templates/app/new_user.html @@ -1,7 +1,7 @@ Register - +

New User

From 78d33022fd41ffd87f1d3a05d18b60ff47aea2e8 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Fri, 25 Mar 2022 15:53:44 +0800 Subject: [PATCH 053/147] Create styleforregister.css --- app/templates/app/styleforregister.css | 59 ++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 app/templates/app/styleforregister.css diff --git a/app/templates/app/styleforregister.css b/app/templates/app/styleforregister.css new file mode 100644 index 000000000..fdcc687bc --- /dev/null +++ b/app/templates/app/styleforregister.css @@ -0,0 +1,59 @@ +body +{ + margin: 0; + padding: 0; + background-color:#6abadeba; + font-family: 'Arial'; +} +.login{ + width: 382px; + overflow: hidden; + margin: auto; + margin: 20 0 0 450px; + padding: 80px; + background: #23463f; + border-radius: 15px ; + +} +h2{ + text-align: center; + color: #277582; + padding: 20px; +} +label{ + color: #08ffd1; + font-size: 17px; +} +#Uname{ + width: 300px; + height: 30px; + border: none; + border-radius: 3px; + padding-left: 8px; +} +#Pass{ + width: 300px; + height: 30px; + border: none; + border-radius: 3px; + padding-left: 8px; + +} +#log{ + width: 300px; + height: 30px; + border: none; + border-radius: 17px; + padding-left: 7px; + color: blue; + + +} +span{ + color: white; + font-size: 17px; +} +a{ + float: right; + background-color: grey; +} From 0905f19ea2dd7c32edaba9d40e7948f2e34a387d Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Fri, 25 Mar 2022 15:56:47 +0800 Subject: [PATCH 054/147] Update new_user.html --- app/templates/app/new_user.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/app/new_user.html b/app/templates/app/new_user.html index 0d354db6e..eef2f116f 100644 --- a/app/templates/app/new_user.html +++ b/app/templates/app/new_user.html @@ -1,7 +1,7 @@ Register - +

New User

From 20b256b0e368d0d3bb554c6dbc7a51db8300f185 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Fri, 25 Mar 2022 16:05:24 +0800 Subject: [PATCH 055/147] Update styleforregister.css --- app/templates/app/styleforregister.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/app/styleforregister.css b/app/templates/app/styleforregister.css index fdcc687bc..7e293fc75 100644 --- a/app/templates/app/styleforregister.css +++ b/app/templates/app/styleforregister.css @@ -20,7 +20,7 @@ h2{ color: #277582; padding: 20px; } -label{ +.label{ color: #08ffd1; font-size: 17px; } From e93188094e2e37392f3835a77d76f1a46f649036 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Fri, 25 Mar 2022 16:05:29 +0800 Subject: [PATCH 056/147] Update new_user.html --- app/templates/app/new_user.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/templates/app/new_user.html b/app/templates/app/new_user.html index eef2f116f..eded53f88 100644 --- a/app/templates/app/new_user.html +++ b/app/templates/app/new_user.html @@ -9,7 +9,7 @@

New User

{{ status|safe }}

- + {% csrf_token %} @@ -31,7 +31,7 @@

New User

- +

Register

You're on your way to join our makan network family!

From 65138accd05f7562fb2797606267eb5339d1a24a Mon Sep 17 00:00:00 2001 From: wanfeijong <37286614+wanfeijong@users.noreply.github.com> Date: Fri, 25 Mar 2022 16:25:35 +0800 Subject: [PATCH 057/147] Add files via upload --- sql/products.sql | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 sql/products.sql diff --git a/sql/products.sql b/sql/products.sql new file mode 100644 index 000000000..bd2d2a4b9 --- /dev/null +++ b/sql/products.sql @@ -0,0 +1,40 @@ +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('mchampain1c', 'Basque Cheesecake', 'The Basque cheesecake is and must be charred, with rough and irregular edges and a soft and melting heart.', 5.1, 'dessert', 'dairy-free', 4); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('rdysartn', 'Indonesian Keropok', 'Keropok are crunchy savoury snacks mostly made from starch and often flavoured with fish, seafood (prawns, squid), onion, chilli', 59.0, 'ready meals', 'nut-free', 22); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('nzannollij', 'Basque Cheesecake', 'The Basque cheesecake is and must be charred, with rough and irregular edges and a soft and melting heart.', 43.4, 'dessert', 'gluten-free', 30); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('kpemberton1e', 'Salted Egg Cookies', 'Soft buttery cookies are infused with the salty umami salted egg yolks to give you sweet, salty, and crumbly cookies.', 50.2, 'dessert', 'egg-free', 20); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('dbodycombe1f', 'Curry filled bun', 'The unspoken Singaporean favourite of curry meets bread made convenient', 57.8, 'ready meals', 'dairy-free', 32); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('aphysicx', 'Pasta', 'Angel hair tomato based spaghetti', 6.4, 'ready meals', 'nut-free', 29); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('nzannollij', 'Tulang', 'In blandit ultrices enim. Lorem ipsum dolor sit amet, consectetuer adipiscing elit.', 10.8, 'ready meals', 'dairy-free', 5); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('nzannollij', 'Crème Brulee Macaron', 'Caramelised bite-size wonders', 47.4, 'dessert', 'egg-free', 1); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('nhourstan10', 'Salted Egg Cookies', 'Soft buttery cookies are infused with the salty umami salted egg yolks to give you sweet, salty, and crumbly cookies.', 29.1, 'dessert', 'dairy-free', 21); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('mlawrey1j', 'Baklava Rings', 'Delicately crisp phyllo rings with a creamy chocolate center, a sprinkling of sea salt and crunchy pistachios! ', 19.6, 'pastries', 'nut-free', 8); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('kpatridge11', 'Tulang', 'Delicious Soup Tulang with meaty bones and hot gravy.', 9.7, 'ready meals', 'egg-free', 12); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('nzannollij', 'Banana Pudding', 'Bringing you the most delicious and authentic South American dessert!', 9.8, 'dessert', 'egg-free', 45); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('wratchfordo', 'Laska', 'Best Singapore Laksa', 38.6, 'ready meals', 'egg-free', 37); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('dbodycombe1f', 'Indonesian Keropok', 'Keropok are crunchy savoury snacks mostly made from starch and often flavoured with fish, seafood (prawns, squid), onion, chilli', 19.1, 'pastries', 'nut-free', 22); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('wratchfordo', 'Nutella Butter Cookies', 'Nutella butter cookies with delicious Nutella filled in the centre', 10.3, 'ready meals', 'gluten-free', 46); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('aphysicx', 'Duo Flavour Cinnamon Roll', 'Get the taste of both world with our vanilla and chocolate cinnamon roll.', 54.6, 'dessert', 'nut-free', 11); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('eskamal17', 'Curry filled bun', 'The unspoken Singaporean favourite of curry meets bread made convenient', 16.7, 'ready meals', 'dairy-free', 8); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('romullallyk', 'Durian Chocolate Cakes', 'Taste of 2 Heavens: Mao Shan Wang and Chocolate', 46.9, 'dessert', 'nut-free', 13); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('pmacgilfoyle1a', 'Chili Manis', 'Delicious sweet chili sauce for you to dip anything and everything in', 21.3, 'ready meals', 'gluten-free', 39); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('mpollock19', 'Pasta', 'Turkey bacon carbonara', 59.6, 'ready meals', 'egg-free', 40); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('jmatisset', 'Curry filled bun', 'The unspoken Singaporean favourite of curry meets bread made convenient', 22.5, 'pastries', 'dairy-free', 12); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('lshreve15', 'Baklava Rings', 'Delicately crisp phyllo rings with a creamy chocolate center, a sprinkling of sea salt and crunchy pistachios! ', 32.1, 'pastries', 'nut-free', 16); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('wratchfordo', 'Tulang', 'Bowl of wonderful meaty mutton bones with red sauce', 20.1, 'ready meals', 'gluten-free', 0); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('dmein13', 'Ang Ku Kueh', 'Ang Ku Kueh that taste just like your grandma’s handmade ones', 42.7, 'dessert', 'egg-free', 36); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('mjozsikaq', 'Chili Manis', 'Sweet Chili sauce to pair with everything', 41.6, 'ready meals', 'dairy-free', 17); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('slurcock5', 'Matcha Speculoos', 'Green tea gelato with speculoos filling.', 58.8, 'dessert', 'gluten-free', 32); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('gsherel1i', 'Biscoff-filled cookies', 'With a dough made from Biscoff cookie crumbs and stuffed with a scoop of creamy Biscoff spread …the cookies are exploding with cookie butter flavor!', 31.5, 'dessert', 'gluten-free', 32); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('cwaliszek1d', 'Curry filled bun', 'The unspoken Singaporean favourite of curry meets bread made convenient', 16.5, 'ready meals', 'egg-free', 40); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('rcamilleri14', 'Durian Chocolate Cakes', 'Chocolate cake filled with durian wonder', 10.2, 'dessert', 'dairy-free', 29); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('msodeau16', 'Hakka Yong Tau Foo', 'Good ol traditional Yong Tau Foo.', 17.8, 'ready meals', 'nut-free', 2); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('dledgerl', 'Durian Chocolate Cakes', 'Mao Shan Wang combined with Chocolate.', 31.8, 'dessert', 'gluten-free', 22); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('eskamal17', 'Biscoff-filled cookies', 'With a dough made from Biscoff cookie crumbs and stuffed with a scoop of creamy Biscoff spread …the cookies are exploding with cookie butter flavor!', 31.5, 'dessert', 'gluten-free', 18); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('ejulyanr', 'Basque Cheesecake', 'The Basque cheesecake is and must be charred, with rough and irregular edges and a soft and melting heart.', 24.2, 'dessert', 'dairy-free', 18); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('boscanlanf', 'Duo Flavour Cinnamon Roll', 'Matcha and Chocolate Cinnamon Roll together in one', 42.9, 'dessert', 'nut-free', 7); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('dmein13', 'Caramelised Onions Sourdough Loaf', 'Perfect bread for a wonderful breakfast.', 43.8, 'pastries', 'gluten-free', 7); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('lfontenotg', 'Durian Chocolate Cakes', 'A little wonderful secret inside the Chocolate Cake.', 45.6, 'dessert', 'egg-free', 50); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('lmiddletonu', 'Laska', 'Penang Laksa straight from Malaysia', 26.9, 'ready meals', 'dairy-free', 41); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('kdaout18', 'Baklava Rings', 'Delicately crisp phyllo rings with a creamy chocolate center, a sprinkling of sea salt and crunchy pistachios! ', 6.9, 'pastries', 'nut-free', 6); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('aphysicx', 'Laska', 'The original Katong Laksa', 18.8, 'pastries', 'gluten-free', 14); +insert into products (sellerid, name, description, price, category, allergen, minorder) values ('dwallbridge9', 'Biscoff-filled cookies', 'With a dough made from Biscoff cookie crumbs and stuffed with a scoop of creamy Biscoff spread …the cookies are exploding with cookie butter flavor!', 31.5, 'dessert', 'egg-free', 3); From 035d607b08643a0f6592bb36ca0b98e411200f6e Mon Sep 17 00:00:00 2001 From: wanfeijong <37286614+wanfeijong@users.noreply.github.com> Date: Fri, 25 Mar 2022 16:25:53 +0800 Subject: [PATCH 058/147] Update add_sql.sh --- add_sql.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/add_sql.sh b/add_sql.sh index 841fabcdc..4022f7ca9 100755 --- a/add_sql.sh +++ b/add_sql.sh @@ -31,6 +31,6 @@ URI="postgres://$DB_USER:$DB_PASSWORD@$DB_HOST:$DB_PORT/$DB_NAME" psql ${URI} -f sql/clean.sql psql ${URI} -f sql/appschema.sql psql ${URI} -f sql/allusersdata.sql -psql ${URI} -f sql/productsdata.sql +psql ${URI} -f sql/products.sql psql ${URI} -f sql/transdata.sql From 000a72d30c3c51b712f4a16da93757410087207d Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Fri, 25 Mar 2022 16:41:59 +0800 Subject: [PATCH 059/147] Update appschema.sql --- sql/appschema.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/appschema.sql b/sql/appschema.sql index 951c6028b..d02d55663 100644 --- a/sql/appschema.sql +++ b/sql/appschema.sql @@ -35,7 +35,7 @@ check(not b_id = s_id) ); CREATE TABLE IF NOT EXISTS product_ratings ( -b_id references transaction +b_id references transactions ) From 936b43fc90893ac972fc7b3c085beaf4653206c1 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Fri, 25 Mar 2022 16:45:19 +0800 Subject: [PATCH 060/147] Update appschema.sql --- sql/appschema.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/appschema.sql b/sql/appschema.sql index d02d55663..a2df2613d 100644 --- a/sql/appschema.sql +++ b/sql/appschema.sql @@ -36,7 +36,7 @@ check(not b_id = s_id) CREATE TABLE IF NOT EXISTS product_ratings ( b_id references transactions -) +); CREATE TABLE IF NOT EXISTS buyers ( From d115a286699ccfc53013acb3150f42467b4b7d8c Mon Sep 17 00:00:00 2001 From: wanfeijong <37286614+wanfeijong@users.noreply.github.com> Date: Fri, 25 Mar 2022 16:47:12 +0800 Subject: [PATCH 061/147] testing purchase pathing --- AppStore/urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AppStore/urls.py b/AppStore/urls.py index 7223a317d..fd5cd2d25 100644 --- a/AppStore/urls.py +++ b/AppStore/urls.py @@ -28,5 +28,5 @@ path('view/', app.views.view, name='view'), path('edit/', app.views.edit, name='edit'), path('login/', app.views.login, name='login'), - path('purchase/', app.views.purchase, name='purchase'), + path('purchase/', app.views.purchase, name='purchase'), ] From 272e02df90d501bc348ed30335183d6e475790c5 Mon Sep 17 00:00:00 2001 From: wanfeijong <37286614+wanfeijong@users.noreply.github.com> Date: Fri, 25 Mar 2022 17:07:46 +0800 Subject: [PATCH 062/147] testing purchase path --- AppStore/urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AppStore/urls.py b/AppStore/urls.py index fd5cd2d25..89cd62e2d 100644 --- a/AppStore/urls.py +++ b/AppStore/urls.py @@ -28,5 +28,5 @@ path('view/', app.views.view, name='view'), path('edit/', app.views.edit, name='edit'), path('login/', app.views.login, name='login'), - path('purchase/', app.views.purchase, name='purchase'), + path('purchase/', app.views.purchase, name='purchase'), ] From e180c2da838d2c19e9fde96d7b9877e827eb5c96 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Fri, 25 Mar 2022 17:09:31 +0800 Subject: [PATCH 063/147] Update styleforregister.css --- app/templates/app/styleforregister.css | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/templates/app/styleforregister.css b/app/templates/app/styleforregister.css index 7e293fc75..37aec6da4 100644 --- a/app/templates/app/styleforregister.css +++ b/app/templates/app/styleforregister.css @@ -2,10 +2,15 @@ body { margin: 0; padding: 0; - background-color:#6abadeba; + background-color: lightblue; font-family: 'Arial'; -} -.login{ +} + +h1{ + color : blue; +} + +.controls{ width: 382px; overflow: hidden; margin: auto; From 13b17293f083fa7a682432dddf3e56013f149d7d Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Fri, 25 Mar 2022 17:09:41 +0800 Subject: [PATCH 064/147] Update new_user.html --- app/templates/app/new_user.html | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/app/templates/app/new_user.html b/app/templates/app/new_user.html index eded53f88..0ba0598a5 100644 --- a/app/templates/app/new_user.html +++ b/app/templates/app/new_user.html @@ -29,31 +29,3 @@

New User

- - - -
-

Register

-

You're on your way to join our makan network family!

-
- - - - - - - - - - - - -
- - -
- - - From 2558b5479a1b7b4570a8951fcf441be35d4e5354 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Fri, 25 Mar 2022 17:17:21 +0800 Subject: [PATCH 065/147] Update new_user.html --- app/templates/app/new_user.html | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/app/templates/app/new_user.html b/app/templates/app/new_user.html index 0ba0598a5..a5a028877 100644 --- a/app/templates/app/new_user.html +++ b/app/templates/app/new_user.html @@ -1,3 +1,4 @@ + + + + + Login Form + + + +

Login Page


+ + + From 4fb46d35b35ff1781404cde7b5c16a78140b91b7 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Fri, 25 Mar 2022 17:18:04 +0800 Subject: [PATCH 066/147] Update new_user.html --- app/templates/app/new_user.html | 1 + 1 file changed, 1 insertion(+) diff --git a/app/templates/app/new_user.html b/app/templates/app/new_user.html index a5a028877..d52fc7cac 100644 --- a/app/templates/app/new_user.html +++ b/app/templates/app/new_user.html @@ -12,6 +12,7 @@

New User

+

Login

Back to home Register + + +
@@ -39,3 +43,4 @@

Login

+--> From 1820d7f3d370d14a2250e7dd433e547b8351b4ca Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Fri, 25 Mar 2022 21:10:41 +0800 Subject: [PATCH 084/147] Update login.html --- app/templates/app/login.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/templates/app/login.html b/app/templates/app/login.html index fd54d234d..988013bd6 100644 --- a/app/templates/app/login.html +++ b/app/templates/app/login.html @@ -30,11 +30,11 @@

Login

+ + + App Logo
+ - +

Login

From 38a9027375590b6e5833050d92eb17483f12f763 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Fri, 25 Mar 2022 22:12:16 +0800 Subject: [PATCH 091/147] Update login.html --- app/templates/app/login.html | 96 ++++++++++++++++++++++++++++++++++-- 1 file changed, 93 insertions(+), 3 deletions(-) diff --git a/app/templates/app/login.html b/app/templates/app/login.html index 9c0104f59..2bf71b24a 100644 --- a/app/templates/app/login.html +++ b/app/templates/app/login.html @@ -9,7 +9,7 @@ - +
-

Login

+

Login

Incorrect username/password combination.
@@ -64,3 +64,93 @@

Login

--> + + + + + + Not So ActiveSG + + + + +

Not So ActiveSG

+

From thick to thicc.

+ +

Are you a Member, Trainer or a Gym?

+ + + + + +

+
+ {% csrf_token %} + + +
+ +
+ + + + +

If you do not have an account, register here for a new account.

+ + +--> From 726cca93437f92bccf2adfffb2109cb6e0b13572 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Fri, 25 Mar 2022 22:15:33 +0800 Subject: [PATCH 092/147] Update login.html --- app/templates/app/login.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/app/login.html b/app/templates/app/login.html index 2bf71b24a..72b5ef88c 100644 --- a/app/templates/app/login.html +++ b/app/templates/app/login.html @@ -72,7 +72,7 @@

Login

- <--!!--> + <--!! From 42aa8741a5516082679760ffd3f8c6735c0dea14 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Fri, 25 Mar 2022 22:32:10 +0800 Subject: [PATCH 094/147] Update login.html --- app/templates/app/login.html | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/app/templates/app/login.html b/app/templates/app/login.html index 9d915c231..466202f76 100644 --- a/app/templates/app/login.html +++ b/app/templates/app/login.html @@ -10,20 +10,18 @@ From c5067af190ff13b3db417f200f038c1e36585293 Mon Sep 17 00:00:00 2001 From: wanfeijong <37286614+wanfeijong@users.noreply.github.com> Date: Sat, 26 Mar 2022 02:23:55 +0800 Subject: [PATCH 095/147] Update login.html --- app/templates/app/login.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/app/login.html b/app/templates/app/login.html index 466202f76..537e82b8d 100644 --- a/app/templates/app/login.html +++ b/app/templates/app/login.html @@ -41,7 +41,7 @@

Login

- Back to home + Back to home Register From 696d0c9b4193718caa0334bd355558eda42a3e5e Mon Sep 17 00:00:00 2001 From: Aeromon Date: Mon, 28 Mar 2022 20:38:58 +0800 Subject: [PATCH 096/147] testing purchase.html, urls and views Updated login.html, urls.py,views.py --- AppStore/settings.py | 3 +++ AppStore/urls.py | 15 +++++++++------ app/templates/app/Profile.html | 10 ++++++++++ app/templates/app/index_products.html | 2 ++ app/views.py | 1 + 5 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 app/templates/app/Profile.html diff --git a/AppStore/settings.py b/AppStore/settings.py index e7500a271..a26dfa619 100644 --- a/AppStore/settings.py +++ b/AppStore/settings.py @@ -150,3 +150,6 @@ STATIC_URL = '/static/' django_heroku.settings(locals()) +import app.views +LOGIN_REDIRECT_URL = ('profile/', app.views.profile, name='profile'), +LOGOUT_REDIRECT_URL = "/" \ No newline at end of file diff --git a/AppStore/urls.py b/AppStore/urls.py index 7223a317d..01e0b1eb6 100644 --- a/AppStore/urls.py +++ b/AppStore/urls.py @@ -17,16 +17,19 @@ from django.urls import path import app.views - +from django.contrib.auth import views as auth_views urlpatterns = [ path('admin/', admin.site.urls), - path('', app.views.index_products, name='products'), - ##path('', app.views.index, name='index'), - path('add/', app.views.add, name='add'), - ##path('buy/', app.views.buy, name='buy'), + path('accounts/', include("django.contrib.auth.urls")), + path('', app.views.index_products, name='products'), """Home page of the app""" + path('accounts/login/', auth_views.auth_login, name='login'), + path('accounts/logout/', auth_views.auth_logout, name='logout'), path('view/', app.views.view, name='view'), path('edit/', app.views.edit, name='edit'), + path('add/', app.views.add, name='add'), + """path('Admin', app.views.index, name='index'), + path('buy/', app.views.buy, name='buy'), path('login/', app.views.login, name='login'), - path('purchase/', app.views.purchase, name='purchase'), + path('purchase/', app.views.purchase, name='purchase'),""" ] diff --git a/app/templates/app/Profile.html b/app/templates/app/Profile.html new file mode 100644 index 000000000..cb3e23438 --- /dev/null +++ b/app/templates/app/Profile.html @@ -0,0 +1,10 @@ + + + + + Profile + + + + + \ No newline at end of file diff --git a/app/templates/app/index_products.html b/app/templates/app/index_products.html index 352bcc609..eaec1aac7 100644 --- a/app/templates/app/index_products.html +++ b/app/templates/app/index_products.html @@ -10,6 +10,8 @@

The Makan Network

Register
Login +
+ logout

IDSeller Product NameAllergen NoticePrice DescriptionPrice CategoryMin OrdersAllergen NoticeMinimum Order Required
{{ cust.5 }} {{ cust.0 }} {{ cust.1 }} {{ cust.2 }} {{ cust.3 }} {{ cust.4 }} {{ cust.6 }} {{ product.0 }} {{ product.1 }} {{ product.2 }} {{ product.3 }} {{ product.4 }} {{ product.5 }} {{ product.6 }} {{ product.7 }}

{{ status|safe }}

@@ -40,4 +42,4 @@
- \ No newline at end of file + From f996ad322817faef01674a0d6dc239d7f4a622aa Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Fri, 25 Mar 2022 01:45:18 +0800 Subject: [PATCH 044/147] Update index_products.html --- app/templates/app/index_products.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/app/index_products.html b/app/templates/app/index_products.html index 17bfaa7f0..3cd5ab4c8 100644 --- a/app/templates/app/index_products.html +++ b/app/templates/app/index_products.html @@ -28,7 +28,7 @@

The Makan Network

{{ product.5 }} - +
diff --git a/app/views.py b/app/views.py index 4287353bf..01a4f7cd0 100644 --- a/app/views.py +++ b/app/views.py @@ -139,3 +139,4 @@ def purchase(request): return render(request, 'app/purchase.html', result_dict) +def profile(request): From 15f90d025adfbd424bf829bd169ee701f35a65da Mon Sep 17 00:00:00 2001 From: Aeromon Date: Mon, 28 Mar 2022 20:40:33 +0800 Subject: [PATCH 097/147] testing purchase.html, urls and views Updated login.html, urls.py,views.py --- app/templates/app/index_products.html | 2 +- app/templates/app/login.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/templates/app/index_products.html b/app/templates/app/index_products.html index eaec1aac7..969533ac8 100644 --- a/app/templates/app/index_products.html +++ b/app/templates/app/index_products.html @@ -5,7 +5,7 @@ Products Listing - App Logo
+ App Logo

The Makan Network

Register
diff --git a/app/templates/app/login.html b/app/templates/app/login.html index 4976bc2e8..768e2f191 100644 --- a/app/templates/app/login.html +++ b/app/templates/app/login.html @@ -5,7 +5,7 @@ Login - App Logo
+ App Logo

Login

Back to home Register From 5f3e93852bf32a812a3e2add129bd8d54a676ee8 Mon Sep 17 00:00:00 2001 From: Aeromon Date: Mon, 28 Mar 2022 20:42:33 +0800 Subject: [PATCH 098/147] testing purchase.html, urls and views Updated login.html, urls.py,views.py --- app/templates/app/index_products.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/app/index_products.html b/app/templates/app/index_products.html index f6353a203..2ddc78904 100644 --- a/app/templates/app/index_products.html +++ b/app/templates/app/index_products.html @@ -5,7 +5,7 @@ Products Listing - App Logo
+ App Logo

The Makan Network

Register
From 87533c290d757de6b1096c59f49affac3a5e61ea Mon Sep 17 00:00:00 2001 From: Aeromon Date: Mon, 28 Mar 2022 20:47:50 +0800 Subject: [PATCH 099/147] testing purchase.html, urls and views Updated login.html, urls.py,views.py --- AppStore/settings.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AppStore/settings.py b/AppStore/settings.py index a26dfa619..df4def991 100644 --- a/AppStore/settings.py +++ b/AppStore/settings.py @@ -151,5 +151,5 @@ django_heroku.settings(locals()) import app.views -LOGIN_REDIRECT_URL = ('profile/', app.views.profile, name='profile'), -LOGOUT_REDIRECT_URL = "/" \ No newline at end of file +LOGIN_REDIRECT_URL = ('profile/', app.views.profile), +LOGOUT_REDIRECT_URL = ("products/"), \ No newline at end of file From 98f60d58bde7cb5aaa97d3519d6a43026dd677db Mon Sep 17 00:00:00 2001 From: Brandon Tan <101177183+Aeromon@users.noreply.github.com> Date: Mon, 28 Mar 2022 21:03:59 +0800 Subject: [PATCH 100/147] Update views.py --- app/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views.py b/app/views.py index 97c061194..b908baa47 100644 --- a/app/views.py +++ b/app/views.py @@ -139,4 +139,4 @@ def purchase(request, productid): return render(request, 'app/purchase.html', result_dict) -def profile(request): +"""def profile(request): From 76df5fbe236449c870a2c8e5d7c441ff327b1cd1 Mon Sep 17 00:00:00 2001 From: Brandon Tan <101177183+Aeromon@users.noreply.github.com> Date: Mon, 28 Mar 2022 21:04:55 +0800 Subject: [PATCH 101/147] Update views.py --- app/views.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/views.py b/app/views.py index b908baa47..44824689c 100644 --- a/app/views.py +++ b/app/views.py @@ -138,5 +138,3 @@ def purchase(request, productid): result_dict = {'products': products} return render(request, 'app/purchase.html', result_dict) - -"""def profile(request): From 2fd946b6d7007df800556899f36c6dda959adf2a Mon Sep 17 00:00:00 2001 From: Aeromon Date: Mon, 28 Mar 2022 21:14:44 +0800 Subject: [PATCH 102/147] testing purchase.html, urls and views Updated login.html, urls.py,views.py --- app/templates/app/{Profile.html => profile.html} | 0 app/views.py | 9 ++++++++- 2 files changed, 8 insertions(+), 1 deletion(-) rename app/templates/app/{Profile.html => profile.html} (100%) diff --git a/app/templates/app/Profile.html b/app/templates/app/profile.html similarity index 100% rename from app/templates/app/Profile.html rename to app/templates/app/profile.html diff --git a/app/views.py b/app/views.py index 97c061194..fbd80f0b3 100644 --- a/app/views.py +++ b/app/views.py @@ -139,4 +139,11 @@ def purchase(request, productid): return render(request, 'app/purchase.html', result_dict) -def profile(request): +def profile(request, phoneno): + with connection.cursor() as cursor: + cursor.execute("SELECT * FROM allusers WHERE phoneno = %s",[phoneno]) + products = cursor.fetchone() + + result_dict = {'allusers': allusers} + + return render(request, 'app/profile.html', result_dict) \ No newline at end of file From 86bc575f89da309724cc51fba81935d4bd34b486 Mon Sep 17 00:00:00 2001 From: Brandon Tan <101177183+Aeromon@users.noreply.github.com> Date: Mon, 28 Mar 2022 21:19:53 +0800 Subject: [PATCH 103/147] Update views.py --- app/views.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/views.py b/app/views.py index f29277f5a..489274de0 100644 --- a/app/views.py +++ b/app/views.py @@ -137,4 +137,13 @@ def purchase(request, productid): result_dict = {'products': products} - return render(request, 'app/purchase.html', result_dict) \ No newline at end of file + return render(request, 'app/purchase.html', result_dict) + +def profile(request, phoneno): + with connection.cursor() as cursor: + cursor.execute("SELECT * FROM allusers WHERE phoneno = %s",[phoneno]) + products = cursor.fetchone() + + result_dict = {'allusers': allusers} + + return render(request, 'app/profile.html', result_dict) From 24526a90706dbf8547e80f73b842bd40d891b18e Mon Sep 17 00:00:00 2001 From: Aeromon Date: Mon, 28 Mar 2022 21:32:28 +0800 Subject: [PATCH 104/147] testing purchase.html, urls and views Updated login.html, urls.py,views.py --- app/templates/app/index_products.html | 2 -- app/templates/app/profile.html | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/templates/app/index_products.html b/app/templates/app/index_products.html index 2ddc78904..3cd5ab4c8 100644 --- a/app/templates/app/index_products.html +++ b/app/templates/app/index_products.html @@ -10,8 +10,6 @@

The Makan Network

Register
Login -
- logout

diff --git a/app/templates/app/profile.html b/app/templates/app/profile.html index cb3e23438..6dae46988 100644 --- a/app/templates/app/profile.html +++ b/app/templates/app/profile.html @@ -5,6 +5,10 @@ Profile + App Logo
+

The Makan Network

+
+ Logout \ No newline at end of file From 15628b4e4a74a95e4ae8b3ddacdd8d1b9c7b5da9 Mon Sep 17 00:00:00 2001 From: Aeromon Date: Mon, 28 Mar 2022 21:42:28 +0800 Subject: [PATCH 105/147] testing purchase.html, urls and views Updated login.html, urls.py,views.py --- AppStore/urls.py | 3 ++- app/views.py | 11 +++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/AppStore/urls.py b/AppStore/urls.py index 89cd62e2d..f82803d71 100644 --- a/AppStore/urls.py +++ b/AppStore/urls.py @@ -22,11 +22,12 @@ urlpatterns = [ path('admin/', admin.site.urls), path('', app.views.index_products, name='products'), + path ##path('', app.views.index, name='index'), path('add/', app.views.add, name='add'), ##path('buy/', app.views.buy, name='buy'), path('view/', app.views.view, name='view'), path('edit/', app.views.edit, name='edit'), - path('login/', app.views.login, name='login'), + ##path('login/', app.views.login, name='login'), path('purchase/', app.views.purchase, name='purchase'), ] diff --git a/app/views.py b/app/views.py index f29277f5a..8e0b0e63b 100644 --- a/app/views.py +++ b/app/views.py @@ -42,17 +42,16 @@ def add(request): ## Check if customerid is already in the table with connection.cursor() as cursor: - cursor.execute("SELECT * FROM customers WHERE customerid = %s", [request.POST['customerid']]) + cursor.execute("SELECT * FROM allusers WHERE phoneno = %s", [request.POST['phoneno']]) customer = cursor.fetchone() ## No customer with same id if customer == None: ##TODO: date validation - cursor.execute("INSERT INTO customers VALUES (%s, %s, %s, %s, %s, %s, %s)" - , [request.POST['first_name'], request.POST['last_name'], request.POST['email'], - request.POST['dob'] , request.POST['since'], request.POST['customerid'], request.POST['country'] ]) - return redirect('index') + cursor.execute("INSERT INTO allusers VALUES (%s, %s, %s)" + ,[request.POST['first_name'], request.POST['last_name'], request.POST['email']]) + return redirect('login') else: - status = 'Customer with ID %s already exists' % (request.POST['customerid']) + status = 'Customer with phone number %s already exists' % (request.POST['phoneno']) context['status'] = status From 5ddc5e4eb709a5adefd76aaf28de3484187b5602 Mon Sep 17 00:00:00 2001 From: Brandon Tan <101177183+Aeromon@users.noreply.github.com> Date: Mon, 28 Mar 2022 21:52:46 +0800 Subject: [PATCH 106/147] Revert "Changed the settings.py " --- AppStore/settings.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AppStore/settings.py b/AppStore/settings.py index df4def991..a26dfa619 100644 --- a/AppStore/settings.py +++ b/AppStore/settings.py @@ -151,5 +151,5 @@ django_heroku.settings(locals()) import app.views -LOGIN_REDIRECT_URL = ('profile/', app.views.profile), -LOGOUT_REDIRECT_URL = ("products/"), \ No newline at end of file +LOGIN_REDIRECT_URL = ('profile/', app.views.profile, name='profile'), +LOGOUT_REDIRECT_URL = "/" \ No newline at end of file From 82682c87e1bcf5609667b3c2d447a0af46dfae1f Mon Sep 17 00:00:00 2001 From: Aeromon Date: Mon, 28 Mar 2022 22:08:25 +0800 Subject: [PATCH 107/147] testing purchase.html, urls and views Updated login.html, urls.py,views.py --- AppStore/urls.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/AppStore/urls.py b/AppStore/urls.py index f82803d71..71db4c56d 100644 --- a/AppStore/urls.py +++ b/AppStore/urls.py @@ -14,6 +14,7 @@ 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin +from django.contrib.auth import views as auth_views from django.urls import path import app.views @@ -22,12 +23,12 @@ urlpatterns = [ path('admin/', admin.site.urls), path('', app.views.index_products, name='products'), - path + ##path('accounts/login/', [name='login']) ##path('', app.views.index, name='index'), path('add/', app.views.add, name='add'), ##path('buy/', app.views.buy, name='buy'), path('view/', app.views.view, name='view'), path('edit/', app.views.edit, name='edit'), - ##path('login/', app.views.login, name='login'), + path('login/', app.views.login, name='login'), path('purchase/', app.views.purchase, name='purchase'), ] From a19738c64a4ddf8bd3c732a61f87d06c4437e081 Mon Sep 17 00:00:00 2001 From: Aeromon Date: Mon, 28 Mar 2022 22:40:29 +0800 Subject: [PATCH 108/147] testing purchase.html, urls and views Updated login.html, urls.py,views.py --- app/templates/app/{new_user.html => register.html} | 7 +------ app/views.py | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) rename app/templates/app/{new_user.html => register.html} (53%) diff --git a/app/templates/app/new_user.html b/app/templates/app/register.html similarity index 53% rename from app/templates/app/new_user.html rename to app/templates/app/register.html index 0ba0598a5..450b89227 100644 --- a/app/templates/app/new_user.html +++ b/app/templates/app/register.html @@ -16,12 +16,7 @@

New User

- + Phone number*

diff --git a/app/views.py b/app/views.py index c78055158..1c24e4724 100644 --- a/app/views.py +++ b/app/views.py @@ -56,7 +56,7 @@ def add(request): context['status'] = status - return render(request, "app/new_user.html", context) + return render(request, "app/register.html", context) # Create your views here. def edit(request, id): From 60db773683899b15595a18dd93069ff61112667e Mon Sep 17 00:00:00 2001 From: Aeromon Date: Mon, 28 Mar 2022 22:46:21 +0800 Subject: [PATCH 109/147] testing purchase.html, urls and views Updated login.html, urls.py,views.py --- AppStore/settings.py | 4 ++-- app/views.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/AppStore/settings.py b/AppStore/settings.py index a26dfa619..7a3e1c902 100644 --- a/AppStore/settings.py +++ b/AppStore/settings.py @@ -151,5 +151,5 @@ django_heroku.settings(locals()) import app.views -LOGIN_REDIRECT_URL = ('profile/', app.views.profile, name='profile'), -LOGOUT_REDIRECT_URL = "/" \ No newline at end of file +"""LOGIN_REDIRECT_URL = ('profile/', app.views.profile, name='profile'), +LOGOUT_REDIRECT_URL = "/" """ \ No newline at end of file diff --git a/app/views.py b/app/views.py index 1c24e4724..1d683c5b5 100644 --- a/app/views.py +++ b/app/views.py @@ -48,7 +48,7 @@ def add(request): if customer == None: ##TODO: date validation cursor.execute("INSERT INTO allusers VALUES (%s, %s, %s)" - ,[request.POST['first_name'], request.POST['last_name'], request.POST['email']]) + ,[request.POST['userid'], request.POST['password'], request.POST['phoneno']]) return redirect('login') else: status = 'Customer with phone number %s already exists' % (request.POST['phoneno']) From b3dd6441314eea908d6f27e1417fddf877f0c8a4 Mon Sep 17 00:00:00 2001 From: Aeromon Date: Mon, 28 Mar 2022 22:54:17 +0800 Subject: [PATCH 110/147] testing purchase.html, urls and views Updated login.html, urls.py,views.py --- app/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views.py b/app/views.py index 1d683c5b5..edc0a3724 100644 --- a/app/views.py +++ b/app/views.py @@ -43,9 +43,9 @@ def add(request): with connection.cursor() as cursor: cursor.execute("SELECT * FROM allusers WHERE phoneno = %s", [request.POST['phoneno']]) - customer = cursor.fetchone() + user = cursor.fetchone() ## No customer with same id - if customer == None: + if user == None: ##TODO: date validation cursor.execute("INSERT INTO allusers VALUES (%s, %s, %s)" ,[request.POST['userid'], request.POST['password'], request.POST['phoneno']]) From f3636966148121361c869de2d0143855c0b148d5 Mon Sep 17 00:00:00 2001 From: Aeromon Date: Mon, 28 Mar 2022 23:01:00 +0800 Subject: [PATCH 111/147] testing purchase.html, urls and views Updated login.html, urls.py,views.py --- app/templates/app/register.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/templates/app/register.html b/app/templates/app/register.html index 450b89227..5ff96df14 100644 --- a/app/templates/app/register.html +++ b/app/templates/app/register.html @@ -15,8 +15,8 @@

New User

+ Password*

From b638f8b417fef8b3a4acf9ab6611d3e696a2aea9 Mon Sep 17 00:00:00 2001 From: Aeromon Date: Tue, 29 Mar 2022 01:02:30 +0800 Subject: [PATCH 112/147] testing purchase.html, urls and views Updated login.html, urls.py,views.py --- AppStore/urls.py | 10 ++++++---- app/templates/app/login.html | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/AppStore/urls.py b/AppStore/urls.py index 71db4c56d..15bc51b36 100644 --- a/AppStore/urls.py +++ b/AppStore/urls.py @@ -15,6 +15,7 @@ """ from django.contrib import admin from django.contrib.auth import views as auth_views +from django.urls import include from django.urls import path import app.views @@ -23,12 +24,13 @@ urlpatterns = [ path('admin/', admin.site.urls), path('', app.views.index_products, name='products'), - ##path('accounts/login/', [name='login']) - ##path('', app.views.index, name='index'), + path("accounts/", include("django.contrib.auth.urls")), + path("accounts/login/", auth_views.auth_login().as_view, name='login'), + #path('', app.views.index, name='index'), path('add/', app.views.add, name='add'), - ##path('buy/', app.views.buy, name='buy'), + #path('buy/', app.views.buy, name='buy'), path('view/', app.views.view, name='view'), path('edit/', app.views.edit, name='edit'), - path('login/', app.views.login, name='login'), + #path('login/', app.views.login, name='login'), path('purchase/', app.views.purchase, name='purchase'), ] diff --git a/app/templates/app/login.html b/app/templates/app/login.html index 537e82b8d..da3aa9237 100644 --- a/app/templates/app/login.html +++ b/app/templates/app/login.html @@ -42,6 +42,7 @@

Login

Back to home +
Register From 12441ef47f4d520d25c9b6c6bac4269c8fbb660a Mon Sep 17 00:00:00 2001 From: Aeromon Date: Tue, 29 Mar 2022 01:05:38 +0800 Subject: [PATCH 113/147] testing purchase.html, urls and views Updated login.html, urls.py,views.py --- AppStore/settings.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AppStore/settings.py b/AppStore/settings.py index 7a3e1c902..489905cac 100644 --- a/AppStore/settings.py +++ b/AppStore/settings.py @@ -151,5 +151,5 @@ django_heroku.settings(locals()) import app.views -"""LOGIN_REDIRECT_URL = ('profile/', app.views.profile, name='profile'), -LOGOUT_REDIRECT_URL = "/" """ \ No newline at end of file +LOGIN_REDIRECT_URL = '/' +LOGOUT_REDIRECT_URL = "/" \ No newline at end of file From 99700ff37f9edf10f2e3f5b31c3d46c156b87150 Mon Sep 17 00:00:00 2001 From: Aeromon Date: Tue, 29 Mar 2022 01:10:46 +0800 Subject: [PATCH 114/147] testing purchase.html, urls and views Updated login.html, urls.py,views.py --- AppStore/urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AppStore/urls.py b/AppStore/urls.py index 15bc51b36..03fb0e508 100644 --- a/AppStore/urls.py +++ b/AppStore/urls.py @@ -25,7 +25,7 @@ path('admin/', admin.site.urls), path('', app.views.index_products, name='products'), path("accounts/", include("django.contrib.auth.urls")), - path("accounts/login/", auth_views.auth_login().as_view, name='login'), + path("accounts/login/", auth_views.login().as_view, name='login'), #path('', app.views.index, name='index'), path('add/', app.views.add, name='add'), #path('buy/', app.views.buy, name='buy'), From 12f0fdcfc795886cd7a0941f90f3dae027344d11 Mon Sep 17 00:00:00 2001 From: Aeromon Date: Tue, 29 Mar 2022 01:30:09 +0800 Subject: [PATCH 115/147] testing purchase.html, urls and views Updated login.html, urls.py,views.py --- AppStore/urls.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/AppStore/urls.py b/AppStore/urls.py index 03fb0e508..7f3ad9d46 100644 --- a/AppStore/urls.py +++ b/AppStore/urls.py @@ -25,7 +25,8 @@ path('admin/', admin.site.urls), path('', app.views.index_products, name='products'), path("accounts/", include("django.contrib.auth.urls")), - path("accounts/login/", auth_views.login().as_view, name='login'), + #path("accounts/login/", auth_views.login().as_view, name='login'), + path('login/', LoginView.as_view(template_name='app/login.html'), name='login'), #path('', app.views.index, name='index'), path('add/', app.views.add, name='add'), #path('buy/', app.views.buy, name='buy'), From c8ca567a4ddc4d8b1b1a10bcb6de303ae82fe240 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Tue, 29 Mar 2022 20:50:40 +0800 Subject: [PATCH 116/147] Update login.html --- app/templates/app/login.html | 48 +++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/app/templates/app/login.html b/app/templates/app/login.html index da3aa9237..00fa5b0ad 100644 --- a/app/templates/app/login.html +++ b/app/templates/app/login.html @@ -4,35 +4,55 @@ Login - App Logo
-

Login

-
Incorrect username/password combination.
+

Login

+
-
This is an error message
+
From 2ae7e5b31bdb1da9a0ec4499ce17d5bbd6ff8181 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Tue, 29 Mar 2022 20:53:26 +0800 Subject: [PATCH 117/147] Update login.html --- app/templates/app/login.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/templates/app/login.html b/app/templates/app/login.html index 00fa5b0ad..16eeb41ac 100644 --- a/app/templates/app/login.html +++ b/app/templates/app/login.html @@ -47,8 +47,8 @@
- -

Login

+ +

Login

From d287ab98c18fecf5369542f8df71afb0754a4118 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Tue, 29 Mar 2022 21:19:15 +0800 Subject: [PATCH 118/147] Update urls.py --- AppStore/urls.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AppStore/urls.py b/AppStore/urls.py index 7f3ad9d46..dd133168a 100644 --- a/AppStore/urls.py +++ b/AppStore/urls.py @@ -25,8 +25,8 @@ path('admin/', admin.site.urls), path('', app.views.index_products, name='products'), path("accounts/", include("django.contrib.auth.urls")), - #path("accounts/login/", auth_views.login().as_view, name='login'), - path('login/', LoginView.as_view(template_name='app/login.html'), name='login'), + path("accounts/login/", auth_views.login().as_view, name='login'), + #path('login/', LoginView.as_view(template_name='app/login.html'), name='login'), #path('', app.views.index, name='index'), path('add/', app.views.add, name='add'), #path('buy/', app.views.buy, name='buy'), From 5dede1c6f8230cc1e3fa4098b1b54e057777cb84 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Tue, 29 Mar 2022 21:43:40 +0800 Subject: [PATCH 119/147] Update urls.py --- AppStore/urls.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/AppStore/urls.py b/AppStore/urls.py index dd133168a..4fa62b538 100644 --- a/AppStore/urls.py +++ b/AppStore/urls.py @@ -28,10 +28,20 @@ path("accounts/login/", auth_views.login().as_view, name='login'), #path('login/', LoginView.as_view(template_name='app/login.html'), name='login'), #path('', app.views.index, name='index'), - path('add/', app.views.add, name='add'), + path('add', app.views.add, name='add'), #path('buy/', app.views.buy, name='buy'), path('view/', app.views.view, name='view'), path('edit/', app.views.edit, name='edit'), #path('login/', app.views.login, name='login'), path('purchase/', app.views.purchase, name='purchase'), ] + + From 932861d5d7a27d2d65b07f69b2a9a7a2e93b9cca Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Wed, 30 Mar 2022 00:54:39 +0800 Subject: [PATCH 120/147] Update urls.py --- AppStore/urls.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/AppStore/urls.py b/AppStore/urls.py index 4fa62b538..72603cc70 100644 --- a/AppStore/urls.py +++ b/AppStore/urls.py @@ -14,8 +14,8 @@ 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.contrib.auth import views as auth_views -from django.urls import include +#from django.contrib.auth import views as auth_views +#from django.urls import include from django.urls import path import app.views @@ -24,15 +24,15 @@ urlpatterns = [ path('admin/', admin.site.urls), path('', app.views.index_products, name='products'), - path("accounts/", include("django.contrib.auth.urls")), - path("accounts/login/", auth_views.login().as_view, name='login'), + #path("accounts/", include("django.contrib.auth.urls")), + #path("accounts/login/", auth_views.login().as_view, name='login'), #path('login/', LoginView.as_view(template_name='app/login.html'), name='login'), #path('', app.views.index, name='index'), path('add', app.views.add, name='add'), #path('buy/', app.views.buy, name='buy'), path('view/', app.views.view, name='view'), path('edit/', app.views.edit, name='edit'), - #path('login/', app.views.login, name='login'), + path('login/', app.views.login, name='login'), path('purchase/', app.views.purchase, name='purchase'), ] From 2e22a2b790e671a64dff9b973230d4172e533203 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Wed, 30 Mar 2022 00:57:28 +0800 Subject: [PATCH 121/147] Update urls.py --- AppStore/urls.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AppStore/urls.py b/AppStore/urls.py index 72603cc70..988e2b7b2 100644 --- a/AppStore/urls.py +++ b/AppStore/urls.py @@ -36,7 +36,7 @@ path('purchase/', app.views.purchase, name='purchase'), ] - +""" From 4620239db9f295a526a08b00014726b5f056cdaf Mon Sep 17 00:00:00 2001 From: Brandon Tan <101177183+Aeromon@users.noreply.github.com> Date: Wed, 30 Mar 2022 01:07:12 +0800 Subject: [PATCH 122/147] Update urls.py --- AppStore/urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AppStore/urls.py b/AppStore/urls.py index 988e2b7b2..28caef84d 100644 --- a/AppStore/urls.py +++ b/AppStore/urls.py @@ -28,7 +28,7 @@ #path("accounts/login/", auth_views.login().as_view, name='login'), #path('login/', LoginView.as_view(template_name='app/login.html'), name='login'), #path('', app.views.index, name='index'), - path('add', app.views.add, name='add'), + path('add/', app.views.add, name='add'), #path('buy/', app.views.buy, name='buy'), path('view/', app.views.view, name='view'), path('edit/', app.views.edit, name='edit'), From 63bd13588d5c2d1bc1d39a391033ebb41ff54e95 Mon Sep 17 00:00:00 2001 From: Brandon Tan <101177183+Aeromon@users.noreply.github.com> Date: Wed, 30 Mar 2022 01:11:28 +0800 Subject: [PATCH 123/147] Update views.py --- app/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views.py b/app/views.py index edc0a3724..314b5be3a 100644 --- a/app/views.py +++ b/app/views.py @@ -33,7 +33,7 @@ def view(request, id): return render(request, 'app/view_admin.html', result_dict) # Create your views here. -def add(request): +def add(request, phoneno): """Shows the main page""" context = {} status = '' From 5bd4d0727d73efaff06777e86a648a0e7edb79ed Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Wed, 30 Mar 2022 01:21:37 +0800 Subject: [PATCH 124/147] Update views.py --- app/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views.py b/app/views.py index 314b5be3a..7f80b3dfd 100644 --- a/app/views.py +++ b/app/views.py @@ -42,7 +42,7 @@ def add(request, phoneno): ## Check if customerid is already in the table with connection.cursor() as cursor: - cursor.execute("SELECT * FROM allusers WHERE phoneno = %s", [request.POST['phoneno']]) + cursor.execute("SELECT * FROM allusers WHERE phoneno = %s", [phoneno]) user = cursor.fetchone() ## No customer with same id if user == None: From b75f9586256afce988dea2ed1243776ce7ca435c Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Wed, 30 Mar 2022 01:28:29 +0800 Subject: [PATCH 125/147] Update views.py --- app/views.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views.py b/app/views.py index 7f80b3dfd..7ac597b07 100644 --- a/app/views.py +++ b/app/views.py @@ -33,13 +33,14 @@ def view(request, id): return render(request, 'app/view_admin.html', result_dict) # Create your views here. -def add(request, phoneno): +def add(request): """Shows the main page""" context = {} status = '' + if request.POST: - ## Check if customerid is already in the table + ## Check if phoneno is already in the table with connection.cursor() as cursor: cursor.execute("SELECT * FROM allusers WHERE phoneno = %s", [phoneno]) From 5b13eba5e186c33adbaf274686bdcf424972de66 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Wed, 30 Mar 2022 01:34:47 +0800 Subject: [PATCH 126/147] Update views.py --- app/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views.py b/app/views.py index 7ac597b07..7e0f5240e 100644 --- a/app/views.py +++ b/app/views.py @@ -43,7 +43,7 @@ def add(request): ## Check if phoneno is already in the table with connection.cursor() as cursor: - cursor.execute("SELECT * FROM allusers WHERE phoneno = %s", [phoneno]) + cursor.execute("SELECT * FROM allusers WHERE phoneno = %s", [request.POST['phoneno']]) user = cursor.fetchone() ## No customer with same id if user == None: From fb5cb801e9dd8b4a178795754e79a31772a76fcc Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Wed, 30 Mar 2022 01:40:29 +0800 Subject: [PATCH 127/147] Update views.py --- app/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views.py b/app/views.py index 7e0f5240e..f18734514 100644 --- a/app/views.py +++ b/app/views.py @@ -49,7 +49,7 @@ def add(request): if user == None: ##TODO: date validation cursor.execute("INSERT INTO allusers VALUES (%s, %s, %s)" - ,[request.POST['userid'], request.POST['password'], request.POST['phoneno']]) + ,[request.POST['userid'], request.POST['phoneno'], request.POST['password']]) return redirect('login') else: status = 'Customer with phone number %s already exists' % (request.POST['phoneno']) From 88bcae6d401984ed954f256da1ae871745ca612a Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Wed, 30 Mar 2022 01:47:57 +0800 Subject: [PATCH 128/147] Update views.py --- app/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views.py b/app/views.py index f18734514..5da1f1fd7 100644 --- a/app/views.py +++ b/app/views.py @@ -42,8 +42,8 @@ def add(request): if request.POST: ## Check if phoneno is already in the table with connection.cursor() as cursor: - - cursor.execute("SELECT * FROM allusers WHERE phoneno = %s", [request.POST['phoneno']]) + + cursor.execute("SELECT * FROM allusers WHERE phoneno = %s", [request.POST.get(['phoneno']])) user = cursor.fetchone() ## No customer with same id if user == None: From 96f0e40332122c4701140287a03957df58012e38 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Wed, 30 Mar 2022 01:49:42 +0800 Subject: [PATCH 129/147] Update views.py --- app/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views.py b/app/views.py index 5da1f1fd7..e95438cd2 100644 --- a/app/views.py +++ b/app/views.py @@ -43,7 +43,7 @@ def add(request): ## Check if phoneno is already in the table with connection.cursor() as cursor: - cursor.execute("SELECT * FROM allusers WHERE phoneno = %s", [request.POST.get(['phoneno']])) + cursor.execute("SELECT * FROM allusers WHERE phoneno = %s", [request.POST.get(['phoneno'])] user = cursor.fetchone() ## No customer with same id if user == None: From 02d321733144d8ec9e19c3fcd70fa1e141d004c7 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Wed, 30 Mar 2022 01:51:20 +0800 Subject: [PATCH 130/147] Update views.py --- app/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views.py b/app/views.py index e95438cd2..dddc464d6 100644 --- a/app/views.py +++ b/app/views.py @@ -43,7 +43,7 @@ def add(request): ## Check if phoneno is already in the table with connection.cursor() as cursor: - cursor.execute("SELECT * FROM allusers WHERE phoneno = %s", [request.POST.get(['phoneno'])] + cursor.execute("SELECT * FROM allusers WHERE phoneno = %s", [request.POST.get(['phoneno'])]) user = cursor.fetchone() ## No customer with same id if user == None: From 6c8f06498e10f82024335b05f4d8f35832a25781 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Wed, 30 Mar 2022 01:55:37 +0800 Subject: [PATCH 131/147] Update views.py --- app/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views.py b/app/views.py index dddc464d6..7f058fe5a 100644 --- a/app/views.py +++ b/app/views.py @@ -43,7 +43,7 @@ def add(request): ## Check if phoneno is already in the table with connection.cursor() as cursor: - cursor.execute("SELECT * FROM allusers WHERE phoneno = %s", [request.POST.get(['phoneno'])]) + cursor.execute("SELECT * FROM allusers WHERE phoneno = %s", [request.POST.get('{{phoneno}}')]) user = cursor.fetchone() ## No customer with same id if user == None: From fe49168bd9f2f0c837f227252ba4423a619d0726 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Wed, 30 Mar 2022 02:00:25 +0800 Subject: [PATCH 132/147] Update views.py --- app/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views.py b/app/views.py index 7f058fe5a..0ebb78249 100644 --- a/app/views.py +++ b/app/views.py @@ -43,7 +43,7 @@ def add(request): ## Check if phoneno is already in the table with connection.cursor() as cursor: - cursor.execute("SELECT * FROM allusers WHERE phoneno = %s", [request.POST.get('{{phoneno}}')]) + cursor.execute("SELECT * FROM allusers WHERE phoneno = %s", [request.POST.get('phoneno')]) user = cursor.fetchone() ## No customer with same id if user == None: From 602f2d4626dcf298e0b0dde6605c353d5e851113 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Wed, 30 Mar 2022 02:03:15 +0800 Subject: [PATCH 133/147] Update views.py --- app/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views.py b/app/views.py index 0ebb78249..9e65fe61a 100644 --- a/app/views.py +++ b/app/views.py @@ -49,7 +49,7 @@ def add(request): if user == None: ##TODO: date validation cursor.execute("INSERT INTO allusers VALUES (%s, %s, %s)" - ,[request.POST['userid'], request.POST['phoneno'], request.POST['password']]) + ,[request.POST.get('userid'), request.POST.get('phoneno'), request.POST.get('password')]) return redirect('login') else: status = 'Customer with phone number %s already exists' % (request.POST['phoneno']) From 44e45e13286b11e2672d6fcf570e3d5fbf43e56e Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Wed, 30 Mar 2022 02:11:29 +0800 Subject: [PATCH 134/147] Update views.py --- app/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views.py b/app/views.py index 9e65fe61a..ef33b9481 100644 --- a/app/views.py +++ b/app/views.py @@ -43,13 +43,13 @@ def add(request): ## Check if phoneno is already in the table with connection.cursor() as cursor: - cursor.execute("SELECT * FROM allusers WHERE phoneno = %s", [request.POST.get('phoneno')]) + cursor.execute("SELECT * FROM allusers WHERE phoneno = %s", [request.POST['phoneno']]) user = cursor.fetchone() ## No customer with same id if user == None: ##TODO: date validation cursor.execute("INSERT INTO allusers VALUES (%s, %s, %s)" - ,[request.POST.get('userid'), request.POST.get('phoneno'), request.POST.get('password')]) + ,[request.POST['userid'], request.POS['phoneno'], request.POST['password]]) return redirect('login') else: status = 'Customer with phone number %s already exists' % (request.POST['phoneno']) From 8cc6320cd015cbe23ab55b26a69915ced2baa4e3 Mon Sep 17 00:00:00 2001 From: kohlongyang <77948776+kohlongyang@users.noreply.github.com> Date: Wed, 30 Mar 2022 02:12:35 +0800 Subject: [PATCH 135/147] Update views.py --- app/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views.py b/app/views.py index ef33b9481..2941ff92b 100644 --- a/app/views.py +++ b/app/views.py @@ -49,7 +49,7 @@ def add(request): if user == None: ##TODO: date validation cursor.execute("INSERT INTO allusers VALUES (%s, %s, %s)" - ,[request.POST['userid'], request.POS['phoneno'], request.POST['password]]) + ,[request.POST['userid'], request.POS['phoneno'], request.POST['password']]) return redirect('login') else: status = 'Customer with phone number %s already exists' % (request.POST['phoneno']) From b106ad7a5c78b942bf999b8f6e305ee8db8c8bdb Mon Sep 17 00:00:00 2001 From: wanfeijong <37286614+wanfeijong@users.noreply.github.com> Date: Thu, 31 Mar 2022 18:07:36 +0800 Subject: [PATCH 136/147] Update views.py --- app/views.py | 135 +++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 115 insertions(+), 20 deletions(-) diff --git a/app/views.py b/app/views.py index 2941ff92b..b87d9e59a 100644 --- a/app/views.py +++ b/app/views.py @@ -1,6 +1,101 @@ from django.shortcuts import render, redirect from django.db import connection +def home(request): + """Shows the product listing page""" + + ## Use raw query to get all objects + with connection.cursor() as cursor: + cursor.execute("SELECT * FROM products ORDER BY productid") + products = cursor.fetchall() + + result_dict = {'products': products} + + return render(request, 'app/home.html', result_dict) + + + +# Create your views here. +def register(request): + """Shows the main page""" + context = {} + status = '' + + if request.POST: + form = NewUserForm(request.POST) + ## Check if userid is already in the table + with connection.cursor() as cursor: + + cursor.execute("SELECT * FROM allusers WHERE userid = %s", [request.POST['username']]) + user = cursor.fetchone() + ## No customer with same id + if user == None: + ##TODO: date validation + cursor.execute("INSERT INTO allusers(userid, phoneno, password) VALUES (%s, %s, %s)" + , [request.POST['username'], request.POST['phoneno'], request.POST['password1'] ]) + newuser = form.save() + login(request, newuser) + messages.success(request, 'Registration successful.') + return redirect('/') + else: + status = 'User with ID %s already exists' % (request.POST['username']) + + form = NewUserForm() + context['status'] = status + + return render(request, "app/register.html", context) + +def signin(request): + """Shows the login page""" + context = {} + status = '' + + if request.POST: + form = AuthenticationForm(request, data=request.POST) + if form.is_valid(): + username = form.cleaned_data.get('username') + password = form.cleaned_data.get('password1') + user = authenticate(username=username, password1=password1) + if user is not None: + login(request, user) + messages.info(request, f'You are now logged in as {username}.') + return redirect('app/') + else: + messages.error(request,'Invalid username or password.') + else: + status = 'Invalid username or password.' + form = AuthenticationForm() + context['status'] = status + return render(request, 'app/login.html', context) + + +def profile(request, id): + """Shows the main page""" + + ## Use raw query to get all objects + with connection.cursor() as cursor: + cursor.execute("SELECT * FROM allusers WHERE userid = %s",[id]) + user = cursor.fetchone() + + result_dict = {'users': users} + + return render(request, 'app/profile.html', result_dict) + + +def view(request, id): + """Shows the main page""" + + ## Use raw query to get a customer + with connection.cursor() as cursor: + cursor.execute("SELECT * FROM products WHERE productid = %s", [id]) + customer = cursor.fetchone() + result_dict = {'cust': customer} + + return render(request,'app/view.html',result_dict) + + + +""" # Create your views here. def index(request): """Shows the main page""" @@ -112,38 +207,38 @@ def login(request): status = 'Your User Id and Password is incorrect' % (request.POST['customerid']) return render(request, 'app/login.html', context) - +""" # Create your views here. -def index_products(request): +#def index_products(request): """Shows the product listing page""" ## Use raw query to get all objects - with connection.cursor() as cursor: - cursor.execute("SELECT * FROM products ORDER BY productid") - products = cursor.fetchall() +# with connection.cursor() as cursor: +# cursor.execute("SELECT * FROM products ORDER BY productid") +# products = cursor.fetchall() - result_dict = {'products': products} +# result_dict = {'products': products} - return render(request, 'app/index_products.html', result_dict) +# return render(request, 'app/index_products.html', result_dict) -def purchase(request, productid): - """Shows the main page""" +#def purchase(request, productid): +# """Shows the main page""" ## Use raw query to get all objects - with connection.cursor() as cursor: - cursor.execute("SELECT * FROM products WHERE productid = %s",[productid]) - products = cursor.fetchone() +# with connection.cursor() as cursor: +# cursor.execute("SELECT * FROM products WHERE productid = %s",[productid]) +# products = cursor.fetchone() - result_dict = {'products': products} +# result_dict = {'products': products} - return render(request, 'app/purchase.html', result_dict) +# return render(request, 'app/purchase.html', result_dict) -def profile(request, phoneno): - with connection.cursor() as cursor: - cursor.execute("SELECT * FROM allusers WHERE phoneno = %s",[phoneno]) - products = cursor.fetchone() +#def profile(request, phoneno): +# with connection.cursor() as cursor: +# cursor.execute("SELECT * FROM allusers WHERE phoneno = %s",[phoneno]) +# products = cursor.fetchone() - result_dict = {'allusers': allusers} +# result_dict = {'allusers': allusers} - return render(request, 'app/profile.html', result_dict) +# return render(request, 'app/profile.html', result_dict) From 9409a56c4c7fe12248b759a785f0317199bd56d5 Mon Sep 17 00:00:00 2001 From: wanfeijong <37286614+wanfeijong@users.noreply.github.com> Date: Thu, 31 Mar 2022 18:08:01 +0800 Subject: [PATCH 137/147] Create forms.py --- app/forms.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 app/forms.py diff --git a/app/forms.py b/app/forms.py new file mode 100644 index 000000000..58135578a --- /dev/null +++ b/app/forms.py @@ -0,0 +1,20 @@ +from django import forms +from django.contrib.auth.forms import UserCreationForm +from django.contrib.auth.models import User + + +# Create your forms here. + +class NewUserForm(UserCreationForm): + phoneno = forms.IntegerField(required=True) + + class Meta: + model = User + fields = ("username", "phoneno", "password1", "password2") + + def save(self, commit=True): + user = super(NewUserForm, self).save(commit=False) + user.phoneno = self.cleaned_data['phoneno'] + if commit: + user.save() + return user From ec2072209f8862cddf5d950a3d1ebb1dbb07b094 Mon Sep 17 00:00:00 2001 From: wanfeijong <37286614+wanfeijong@users.noreply.github.com> Date: Thu, 31 Mar 2022 18:08:24 +0800 Subject: [PATCH 138/147] Update admin.py --- app/admin.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/admin.py b/app/admin.py index 8c38f3f3d..0b1c4ae31 100644 --- a/app/admin.py +++ b/app/admin.py @@ -1,3 +1,7 @@ from django.contrib import admin +from django.contrib.auth.models import User # Register your models here. + +class PersonAdmin(admin.ModelAdmin): + list_display = ('username', 'phoneno', 'password1') From bb136f9b33dc373aca65de473b751e34e8ce866f Mon Sep 17 00:00:00 2001 From: wanfeijong <37286614+wanfeijong@users.noreply.github.com> Date: Thu, 31 Mar 2022 18:08:52 +0800 Subject: [PATCH 139/147] Create view.html --- app/templates/app/view.html | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 app/templates/app/view.html diff --git a/app/templates/app/view.html b/app/templates/app/view.html new file mode 100644 index 000000000..6b265f7d8 --- /dev/null +++ b/app/templates/app/view.html @@ -0,0 +1,39 @@ + + +

Details for {{cust.0}} {{cust.2}}

+ Back to home +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Product ID: {{ cust.0 }}
Category: {{ cust.5 }}
Price: {{ cust.4 }}
Description: {{ cust.3 }}
Allergens: {{ cust.6 }}
Minimum Order: {{ cust.7 }}
+ + From 99157594b6664e1b03d8c5961720a0b5f6c307bc Mon Sep 17 00:00:00 2001 From: wanfeijong <37286614+wanfeijong@users.noreply.github.com> Date: Thu, 31 Mar 2022 18:10:01 +0800 Subject: [PATCH 140/147] Update register.html --- app/templates/app/register.html | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/app/templates/app/register.html b/app/templates/app/register.html index 5ff96df14..8face32b2 100644 --- a/app/templates/app/register.html +++ b/app/templates/app/register.html @@ -1,3 +1,49 @@ + + + + + + + +

Registration Form

+ + + {% csrf_token %} + +
+ + + + + + + + + + + + + +
+ + + +
+ {% for message in messages %} +

{{message}}

+ {% endfor %} +
+ + + + + + + + Register From 3087a68d4aba43cfa903d63175c3f913aaf38b2c Mon Sep 17 00:00:00 2001 From: wanfeijong <37286614+wanfeijong@users.noreply.github.com> Date: Thu, 31 Mar 2022 18:11:09 +0800 Subject: [PATCH 141/147] Update login.html --- app/templates/app/login.html | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/app/templates/app/login.html b/app/templates/app/login.html index 16eeb41ac..90426980a 100644 --- a/app/templates/app/login.html +++ b/app/templates/app/login.html @@ -1,3 +1,45 @@ + + + + + + + +

Login

+ +
+ {% csrf_token %} + +
+ + + + + + + +
+ + +
+ + +
+ {% for message in messages %} +

{{message}}

+ {% endfor %} +
+ + + + + + + + {% load static %} From 218381e760afd0137370ab7d4fcc29bc0e693a25 Mon Sep 17 00:00:00 2001 From: wanfeijong <37286614+wanfeijong@users.noreply.github.com> Date: Thu, 31 Mar 2022 18:11:34 +0800 Subject: [PATCH 142/147] Create home.html --- app/templates/app/home.html | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 app/templates/app/home.html diff --git a/app/templates/app/home.html b/app/templates/app/home.html new file mode 100644 index 000000000..4500f0483 --- /dev/null +++ b/app/templates/app/home.html @@ -0,0 +1,35 @@ +{% load static %} + + + +

Product Listing

+ Register + Login +

+ + + + + + + + + {% for product in products %} + + + + + + + + + + {% endfor %} +
Product IDNamePriceMinimum Order Category
{{ product.0 }} {{ product.2 }} {{ product.4 }} {{ product.7 }} {{ product.5 }} + +
+ {% csrf_token %} + +
+ + From 00bd50a14f7d7f7d2292b6f4b524af2ec8f7864c Mon Sep 17 00:00:00 2001 From: wanfeijong <37286614+wanfeijong@users.noreply.github.com> Date: Thu, 31 Mar 2022 18:12:35 +0800 Subject: [PATCH 143/147] Update urls.py --- AppStore/urls.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/AppStore/urls.py b/AppStore/urls.py index 28caef84d..671aae83a 100644 --- a/AppStore/urls.py +++ b/AppStore/urls.py @@ -20,7 +20,16 @@ import app.views +urlpatterns = [ + path('admin/', admin.site.urls), + path('', app.views.home, name='home'), + path('register/', app.views.register, name='register'), + path('profile/', app.views.profile, name='profile'), + path('login/', app.views.signin, name='login'), + path('view/', app.views.view, name='view') +] +""" urlpatterns = [ path('admin/', admin.site.urls), path('', app.views.index_products, name='products'), @@ -35,6 +44,7 @@ path('login/', app.views.login, name='login'), path('purchase/', app.views.purchase, name='purchase'), ] +""" """ urlpatterns = [ From 463aa133700c5e05c05a93ef4973da8ab66d0c72 Mon Sep 17 00:00:00 2001 From: wanfeijong <37286614+wanfeijong@users.noreply.github.com> Date: Thu, 31 Mar 2022 18:15:57 +0800 Subject: [PATCH 144/147] Update views.py --- app/views.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/views.py b/app/views.py index b87d9e59a..53c9abd02 100644 --- a/app/views.py +++ b/app/views.py @@ -1,5 +1,9 @@ from django.shortcuts import render, redirect from django.db import connection +from django.contrib.auth import login, authenticate +from django.contrib import messages +from django.contrib.auth.forms import AuthenticationForm +from .forms import NewUserForm def home(request): """Shows the product listing page""" From 0be5efa611de0f2ba11321d760b7c1d24acbdf28 Mon Sep 17 00:00:00 2001 From: wanfeijong <37286614+wanfeijong@users.noreply.github.com> Date: Thu, 31 Mar 2022 18:17:37 +0800 Subject: [PATCH 145/147] Update views.py --- app/views.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views.py b/app/views.py index 53c9abd02..b39b011cd 100644 --- a/app/views.py +++ b/app/views.py @@ -121,7 +121,7 @@ def index(request): # Create your views here. def view(request, id): - """Shows the main page""" + ## Use raw query to get a customer with connection.cursor() as cursor: @@ -133,7 +133,7 @@ def view(request, id): # Create your views here. def add(request): - """Shows the main page""" + context = {} status = '' @@ -160,7 +160,7 @@ def add(request): # Create your views here. def edit(request, id): - """Shows the main page""" + # dictionary for initial data with # field names as keys @@ -192,7 +192,7 @@ def edit(request, id): # Create your views here. def login(request): - """Shows the login page""" + context = {} status = '' From 1221b50027b805197f97bcdaf358825139c3e148 Mon Sep 17 00:00:00 2001 From: wanfeijong <37286614+wanfeijong@users.noreply.github.com> Date: Thu, 31 Mar 2022 18:19:09 +0800 Subject: [PATCH 146/147] Update views.py --- app/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views.py b/app/views.py index b39b011cd..41602fc74 100644 --- a/app/views.py +++ b/app/views.py @@ -102,7 +102,7 @@ def view(request, id): """ # Create your views here. def index(request): - """Shows the main page""" + ## Delete customer if request.POST: From 2518c0acb40fb61b9c4f3cf255b991db82e64aa2 Mon Sep 17 00:00:00 2001 From: wanfeijong <37286614+wanfeijong@users.noreply.github.com> Date: Thu, 31 Mar 2022 18:20:12 +0800 Subject: [PATCH 147/147] Update views.py --- app/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views.py b/app/views.py index 41602fc74..1c394714e 100644 --- a/app/views.py +++ b/app/views.py @@ -215,7 +215,7 @@ def login(request): # Create your views here. #def index_products(request): - """Shows the product listing page""" + ## Use raw query to get all objects # with connection.cursor() as cursor: @@ -227,7 +227,7 @@ def login(request): # return render(request, 'app/index_products.html', result_dict) #def purchase(request, productid): -# """Shows the main page""" + ## Use raw query to get all objects # with connection.cursor() as cursor: