From d08e8018689df8c92369caf886034846f86d237b Mon Sep 17 00:00:00 2001 From: geraldw12 <101490974+geraldw12@users.noreply.github.com> Date: Mon, 14 Mar 2022 12:54:21 +0800 Subject: [PATCH 01/43] Update .env --- .env | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.env b/.env index 6b111ae9d..ca35d288f 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-209-61-239.compute-1.amazonaws.com' +DB_NAME='dcd7u7lr4i66cg' +DB_USER='agvhdajofpvwos' +DB_PORT='5432' +DB_PASSWORD='4588d241ec02742635d3e433d707292efae1538c71c59934462ed8d4f6caa4f2' From c965fb3b6fe7a142b779ca9149af902374b2ab1b Mon Sep 17 00:00:00 2001 From: geraldw12 <101490974+geraldw12@users.noreply.github.com> Date: Wed, 16 Mar 2022 23:07:52 +0800 Subject: [PATCH 02/43] Update .env --- .env | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.env b/.env index ca35d288f..c44bcdd44 100644 --- a/.env +++ b/.env @@ -14,8 +14,8 @@ LOCAL_DB_USER='postgres' LOCAL_DB_PASSWORD='postgres' ##### Heroku database ###### -DB_HOST='ec2-3-209-61-239.compute-1.amazonaws.com' -DB_NAME='dcd7u7lr4i66cg' -DB_USER='agvhdajofpvwos' +DB_HOST='ec2-3-227-195-74.compute-1.amazonaws.com' +DB_NAME='d49c9ajoa4eit9' +DB_USER='tpbsjdvmhjvsiz' DB_PORT='5432' -DB_PASSWORD='4588d241ec02742635d3e433d707292efae1538c71c59934462ed8d4f6caa4f2' +DB_PASSWORD='04a1f1190056ded288b62a5bfd07cad0966d8d07f840fb356c6c2368e1c32c21' From 91b3eafb5eac1353bfeb9839ffbb87dea08e33c5 Mon Sep 17 00:00:00 2001 From: geraldw12 <101490974+geraldw12@users.noreply.github.com> Date: Wed, 16 Mar 2022 23:10:05 +0800 Subject: [PATCH 03/43] Update tests.py --- app/tests.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app/tests.py b/app/tests.py index 7ce503c2d..4b35197cc 100644 --- a/app/tests.py +++ b/app/tests.py @@ -1,3 +1,4 @@ from django.test import TestCase # Create your tests here. +#test From 1132a602bb33b0a392ffb3c6898dc3b9c37002d8 Mon Sep 17 00:00:00 2001 From: geraldw12 <101490974+geraldw12@users.noreply.github.com> Date: Wed, 16 Mar 2022 23:14:37 +0800 Subject: [PATCH 04/43] Update apps.py --- app/apps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/apps.py b/app/apps.py index 80b2c8d79..11556dec0 100644 --- a/app/apps.py +++ b/app/apps.py @@ -2,4 +2,4 @@ class AppConfig(AppConfig): - name = 'app' + name = 'Petsitting' From 742174f957e19c2b13b0549dd22eb1bf859d6695 Mon Sep 17 00:00:00 2001 From: geraldw12 <101490974+geraldw12@users.noreply.github.com> Date: Thu, 17 Mar 2022 18:31:36 +0800 Subject: [PATCH 05/43] Update apps.py --- app/apps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/apps.py b/app/apps.py index 11556dec0..dd792d5dd 100644 --- a/app/apps.py +++ b/app/apps.py @@ -2,4 +2,4 @@ class AppConfig(AppConfig): - name = 'Petsitting' + name = 'newapp' From c5a87bd17275360e9274c44017905b1af5424d93 Mon Sep 17 00:00:00 2001 From: geraldw12 <101490974+geraldw12@users.noreply.github.com> Date: Thu, 17 Mar 2022 20:20:55 +0800 Subject: [PATCH 06/43] Update apps.py --- app/apps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/apps.py b/app/apps.py index dd792d5dd..404cae616 100644 --- a/app/apps.py +++ b/app/apps.py @@ -2,4 +2,4 @@ class AppConfig(AppConfig): - name = 'newapp' + name = 'petsittingapp' From d64d46e855c4553ff91d6dc6d45e524c9d0a02b7 Mon Sep 17 00:00:00 2001 From: geraldw12 <101490974+geraldw12@users.noreply.github.com> Date: Thu, 17 Mar 2022 20:30:24 +0800 Subject: [PATCH 07/43] Update apps.py --- app/apps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/apps.py b/app/apps.py index 404cae616..80b2c8d79 100644 --- a/app/apps.py +++ b/app/apps.py @@ -2,4 +2,4 @@ class AppConfig(AppConfig): - name = 'petsittingapp' + name = 'app' From 260bec97083606b11ee26c627476aa138a7a059e Mon Sep 17 00:00:00 2001 From: geraldw12 <101490974+geraldw12@users.noreply.github.com> Date: Sat, 19 Mar 2022 00:18:59 +0800 Subject: [PATCH 08/43] Update .env --- .env | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.env b/.env index c44bcdd44..a30fada30 100644 --- a/.env +++ b/.env @@ -14,8 +14,8 @@ LOCAL_DB_USER='postgres' LOCAL_DB_PASSWORD='postgres' ##### Heroku database ###### -DB_HOST='ec2-3-227-195-74.compute-1.amazonaws.com' -DB_NAME='d49c9ajoa4eit9' -DB_USER='tpbsjdvmhjvsiz' +DB_HOST='ec2-3-212-45-192.compute-1.amazonaws.com' +DB_NAME='dcgs0k2jb4ro3j' +DB_USER='zbuggbupzzuxul' DB_PORT='5432' -DB_PASSWORD='04a1f1190056ded288b62a5bfd07cad0966d8d07f840fb356c6c2368e1c32c21' +DB_PASSWORD='4d8fc3397c4bdeadd1cff710320d96fcb0cd61c4f827a48346f05b93b96e45eb' From ac72ad308de476d6efbff3693c1506593bba7bff Mon Sep 17 00:00:00 2001 From: geraldw12 <101490974+geraldw12@users.noreply.github.com> Date: Wed, 30 Mar 2022 17:58:37 +0800 Subject: [PATCH 09/43] 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 fba8722bc..7af81d84a 100644 --- a/app/views.py +++ b/app/views.py @@ -13,7 +13,7 @@ def index(request): ## Use raw query to get all objects with connection.cursor() as cursor: - cursor.execute("SELECT * FROM customers ORDER BY customerid") + cursor.execute("SELECT customerid FROM customers ORDER BY customerid") customers = cursor.fetchall() result_dict = {'records': customers} @@ -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.html", context) From 93026f983f2dcfd6978293578991d4ba2cc00455 Mon Sep 17 00:00:00 2001 From: geraldw12 <101490974+geraldw12@users.noreply.github.com> Date: Wed, 30 Mar 2022 18:01:06 +0800 Subject: [PATCH 10/43] 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 7af81d84a..4dd157240 100644 --- a/app/views.py +++ b/app/views.py @@ -13,7 +13,7 @@ def index(request): ## Use raw query to get all objects with connection.cursor() as cursor: - cursor.execute("SELECT customerid FROM customers ORDER BY customerid") + cursor.execute("SELECT * FROM customers ORDER BY customerid") customers = cursor.fetchall() result_dict = {'records': customers} From 4a75e8475d62686b7d2a902c1cfca844a16df512 Mon Sep 17 00:00:00 2001 From: geraldw12 <101490974+geraldw12@users.noreply.github.com> Date: Wed, 30 Mar 2022 20:14:13 +0800 Subject: [PATCH 11/43] 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 4dd157240..181b89d8a 100644 --- a/app/views.py +++ b/app/views.py @@ -13,7 +13,7 @@ def index(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 customers ORDER BY customerid DESC") customers = cursor.fetchall() result_dict = {'records': customers} From e41ad2c9a8be684897d9a292fb464aab2a8bc4ba Mon Sep 17 00:00:00 2001 From: geraldw12 <101490974+geraldw12@users.noreply.github.com> Date: Wed, 30 Mar 2022 20:27:50 +0800 Subject: [PATCH 12/43] 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 181b89d8a..f074d88fa 100644 --- a/app/views.py +++ b/app/views.py @@ -26,7 +26,7 @@ def view(request, id): ## Use raw query to get a customer with connection.cursor() as cursor: - cursor.execute("SELECT * FROM customers WHERE customerid = %s", [id]) + cursor.execute("SELECT customerid FROM customers WHERE customerid = %s", [id]) customer = cursor.fetchone() result_dict = {'cust': customer} From 0b8d95c1e8c60f9decb9f21d5411967229843480 Mon Sep 17 00:00:00 2001 From: geraldw12 <101490974+geraldw12@users.noreply.github.com> Date: Wed, 30 Mar 2022 20:36:10 +0800 Subject: [PATCH 13/43] 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 f074d88fa..181b89d8a 100644 --- a/app/views.py +++ b/app/views.py @@ -26,7 +26,7 @@ def view(request, id): ## Use raw query to get a customer with connection.cursor() as cursor: - cursor.execute("SELECT customerid FROM customers WHERE customerid = %s", [id]) + cursor.execute("SELECT * FROM customers WHERE customerid = %s", [id]) customer = cursor.fetchone() result_dict = {'cust': customer} From e719bcbf338c9fed6ace31fab8a9125eee1ff612 Mon Sep 17 00:00:00 2001 From: geraldw12 <101490974+geraldw12@users.noreply.github.com> Date: Wed, 30 Mar 2022 20:40:50 +0800 Subject: [PATCH 14/43] Update index.html --- app/templates/app/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/app/index.html b/app/templates/app/index.html index e32368db1..5bc6adef1 100644 --- a/app/templates/app/index.html +++ b/app/templates/app/index.html @@ -3,7 +3,7 @@

Customers in the App Store

NUS logo
- New customer + Hello

From 3a5bdee75f0432121ce9915e20022dd88c31f891 Mon Sep 17 00:00:00 2001 From: geraldw12 Date: Fri, 1 Apr 2022 15:03:41 +0800 Subject: [PATCH 15/43] add login page --- app/templates/app/login.html | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 app/templates/app/login.html diff --git a/app/templates/app/login.html b/app/templates/app/login.html new file mode 100644 index 000000000..13ba86117 --- /dev/null +++ b/app/templates/app/login.html @@ -0,0 +1,5 @@ + +
+

THis is the login page

+
+ \ No newline at end of file From 387eae0b2e22f6fc3be5c9abdf1936f489b7ff8d Mon Sep 17 00:00:00 2001 From: Jonas Lim Date: Sat, 2 Apr 2022 13:42:29 +0800 Subject: [PATCH 16/43] Enter --- AppStore/urls.py | 1 + app/templates/app/pending.html | 27 ++++++++++++++++++ app/templates/app/view_user.html | 44 ++++++++++++++++++++++++++++++ app/templates/view_offer.html | 0 app/views.py | 40 +++++++++++++++++++++++++-- sql/PetSittingSchema.sql | 47 ++++++++++++++++++++++++++++++++ sql/PetSittingjoboffer.sql | 13 +++++++++ sql/PetSittingpending.sql | 8 ++++++ sql/PetSittingpet.sql | 9 ++++++ sql/PetSittingportfolio.sql | 9 ++++++ sql/PetSittingtransaction.sql | 13 +++++++++ 11 files changed, 209 insertions(+), 2 deletions(-) create mode 100644 app/templates/app/pending.html create mode 100644 app/templates/app/view_user.html create mode 100644 app/templates/view_offer.html create mode 100644 sql/PetSittingSchema.sql create mode 100644 sql/PetSittingjoboffer.sql create mode 100644 sql/PetSittingpending.sql create mode 100644 sql/PetSittingpet.sql create mode 100644 sql/PetSittingportfolio.sql create mode 100644 sql/PetSittingtransaction.sql diff --git a/AppStore/urls.py b/AppStore/urls.py index 5355daa5c..5d0f4802c 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('pending', app.views.pending) ] diff --git a/app/templates/app/pending.html b/app/templates/app/pending.html new file mode 100644 index 000000000..9c3654fa5 --- /dev/null +++ b/app/templates/app/pending.html @@ -0,0 +1,27 @@ + + +

Pending Offers

+

+
+ + + + + + {% for interested_user in records %} + {% for offer in records %} + + + + + + {% endfor %} +
Offer IDInterested UserAction
{{ offer.0 }} {{ interested_user.0 }} + | + + | + + +
+ + \ No newline at end of file diff --git a/app/templates/app/view_user.html b/app/templates/app/view_user.html new file mode 100644 index 000000000..7d65684d4 --- /dev/null +++ b/app/templates/app/view_user.html @@ -0,0 +1,44 @@ + + +

Details for {{offer_user.1}}

+ Back to main menu +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ID: {{ cust.5 }}
First name: {{ cust.0 }}
Last name: {{ cust.1 }}
Email: {{ cust.2 }}
Date of birth: {{ cust.3 }}
Since: {{ cust.4 }}
Country: {{ cust.6 }}
+ + \ No newline at end of file diff --git a/app/templates/view_offer.html b/app/templates/view_offer.html new file mode 100644 index 000000000..e69de29bb diff --git a/app/views.py b/app/views.py index 181b89d8a..f531770b6 100644 --- a/app/views.py +++ b/app/views.py @@ -13,7 +13,7 @@ def index(request): ## Use raw query to get all objects with connection.cursor() as cursor: - cursor.execute("SELECT * FROM customers ORDER BY customerid DESC") + cursor.execute("SELECT * FROM customers ORDER BY customerid") customers = cursor.fetchall() result_dict = {'records': customers} @@ -88,5 +88,41 @@ def edit(request, id): context["obj"] = obj context["status"] = status - return render(request, "app/edit.html", context) + + # Create your views here. + +def pending(request): + """Shows the pending page""" + + ## Use raw query to get all objects + with connection.cursor() as cursor: + cursor.execute("SELECT * FROM pending WHERE username = login_user") + pending_offers = cursor.fetchall() + + result_dict = {'records': pending_offers} + + return render(request,'app/pending.html',result_dict) + +# Create your view_user here. +def view_user(request, i_user): + """Shows the main page""" + + ## Use raw query to get a customer + with connection.cursor() as cursor: + cursor.execute("SELECT * FROM portfolio WHERE username = %s", [i_user]) + pending_offers = cursor.fetchone() + result_dict = {'interested_user': pending_offers} + + return render(request,'app/view_user.html',result_dict) + +def view_offer(request, offerid): + """Shows the main page""" + + ## Use raw query to get a customer + with connection.cursor() as cursor: + cursor.execute("SELECT * FROM joboffer WHERE offerid = %s", [offerid]) + pending_offers = cursor.fetchone() + result_dict = {'offer': pending_offers} + + return render(request,'app/view_offer.html',result_dict) diff --git a/sql/PetSittingSchema.sql b/sql/PetSittingSchema.sql new file mode 100644 index 000000000..bec92cdee --- /dev/null +++ b/sql/PetSittingSchema.sql @@ -0,0 +1,47 @@ +/******************* + + Create the schema + +********************/ + +CREATE TABLE IF NOT EXISTS portfolio ( +username VARCHAR(256) PRIMARY KEY, +email VARCHAR(256) NOT NULL UNIQUE, +phonenum VARCHAR(8), +year_exp INT, +password VARCHAR(64) NOT NULL, +CHECK(length(phonenum) = 8), +CHECK(length(password) >= 8) +); + +CREATE TABLE IF NOT EXISTS pet ( +petname VARCHAR(32) NOT NULL, +petid VARCHAR(256) PRIMARY KEY, +type VARCHAR(62) NOT NULL, +breed VARCHAR(32) NOT NULL, +username VARCHAR(256) REFERENCES portfolio(username) DEFERRABLE +); + +CREATE TABLE IF NOT EXISTS joboffer ( +offerid VARCHAR(32) PRIMARY KEY, +price FLOAT, +location VARCHAR(256) NOT NULL, +date_from DATE NOT NULL, +date_to DATE NOT NULL, +petid VARCHAR(256) REFERENCES pet(petid) DEFERRABLE, +username VARCHAR(256) REFERENCES portfolio(username) DEFERRABLE, +UNIQUE (date_from, date_to, petid), +CHECK(date_to > date_from) +); + +CREATE TABLE IF NOT EXISTS transaction ( +offerid VARCHAR(32) REFERENCES joboffer(offerid) DEFERRABLE, +username VARCHAR(256) REFERENCES portfolio(username) DEFERRABLE, +rating INT, +CHECK (rating >= 0 AND rating <= 5) +); + +CREATE TABLE IF NOT EXISTS pending ( +offerid VARCHAR(32) REFERENCES joboffer(offerid) DEFERRABLE, +username VARCHAR(256) REFERENCES portfolio(username) DEFERRABLE +); diff --git a/sql/PetSittingjoboffer.sql b/sql/PetSittingjoboffer.sql new file mode 100644 index 000000000..cf2eaabe1 --- /dev/null +++ b/sql/PetSittingjoboffer.sql @@ -0,0 +1,13 @@ +/*************************** + + Populate the joboffer table + +****************************/ + +INSERT INTO joboffer VALUES (432, 23, 'bangkit', '2022-01-01','2022-01-04', 123, 'johnny123'); +INSERT INTO joboffer VALUES (9000, 29, 'jelapang', '2022-05-09','2022-05-14', 456, 'gerald123'); +INSERT INTO joboffer VALUES (7022, 23, 'clmeenti', '2022-02-05','2022-02-08', 789, 'siewkit8899'); +INSERT INTO joboffer VALUES (433, 26, 'bangkit', '2022-01-05','2022-01-09', 123, 'johnny123'); +INSERT INTO joboffer VALUES (9001, 277, 'jelapang', '2022-03-09','2022-03-14', 456, 'gerald123'); +INSERT INTO joboffer VALUES (7023, 28, 'clmeenti', '2022-04-05','2022-04-08', 789, 'siewkit8899'); +INSERT INTO joboffer VALUES (434, 26, 'bangkit', '2022-01-09','2022-01-13', 123, 'johnny123'); \ No newline at end of file diff --git a/sql/PetSittingpending.sql b/sql/PetSittingpending.sql new file mode 100644 index 000000000..e6d724d5b --- /dev/null +++ b/sql/PetSittingpending.sql @@ -0,0 +1,8 @@ +/*************************** + + Populate the portfolio table + +****************************/ + +INSERT INTO pending VALUES (432, 'gerald123'); +INSERT INTO pending VALUES (432, 'siewkit8899'); \ No newline at end of file diff --git a/sql/PetSittingpet.sql b/sql/PetSittingpet.sql new file mode 100644 index 000000000..dcdaadd11 --- /dev/null +++ b/sql/PetSittingpet.sql @@ -0,0 +1,9 @@ +/*************************** + + Populate the pet table + +****************************/ + +INSERT INTO pet VALUES ('tom', 123, 'dog', 'huskey', 'johnny123'); +INSERT INTO pet VALUES ('dick', 456, 'dog', 'chiwa', 'gerald123'); +INSERT INTO pet VALUES ('harry', 789, 'cat', 'meow', 'siewkit8899'); \ No newline at end of file diff --git a/sql/PetSittingportfolio.sql b/sql/PetSittingportfolio.sql new file mode 100644 index 000000000..4c3bebad3 --- /dev/null +++ b/sql/PetSittingportfolio.sql @@ -0,0 +1,9 @@ +/*************************** + + Populate the portfolio table + +****************************/ + +INSERT INTO portfolio VALUES ('johnny123','johnny@gmail.com',98213764,2,'panda1234567'); +INSERT INTO portfolio VALUES ('gerald123','gerald@gmail.com',97591323,4,'gerald1234567'); +INSERT INTO portfolio VALUES ('siewkit8899','siewkitty@gmail.com',96856569,9,'battle968'); \ No newline at end of file diff --git a/sql/PetSittingtransaction.sql b/sql/PetSittingtransaction.sql new file mode 100644 index 000000000..b9e136b5b --- /dev/null +++ b/sql/PetSittingtransaction.sql @@ -0,0 +1,13 @@ +/*************************** + + Populate the joboffer table + +****************************/ + +INSERT INTO transaction VALUES (432, 'johnny123', 2); +INSERT INTO transaction VALUES (9000, 'gerald123', 5); +INSERT INTO transaction VALUES (7022, 'siewkit8899', 3); +INSERT INTO transaction VALUES (433, 'johnny123', 4); +INSERT INTO transaction VALUES (9001, 'gerald123', 3); +INSERT INTO transaction VALUES (7023, 'siewkit8899', 3); +INSERT INTO transaction VALUES (434, 'johnny123', 2); From 064237953146c76999f427afd07cc52f3f9cbc73 Mon Sep 17 00:00:00 2001 From: Jonas Lim Date: Sat, 2 Apr 2022 14:19:47 +0800 Subject: [PATCH 17/43] Enter --- AppStore/urls.py | 4 ++-- app/views.py | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/AppStore/urls.py b/AppStore/urls.py index 5d0f4802c..f531b69b7 100644 --- a/AppStore/urls.py +++ b/AppStore/urls.py @@ -14,7 +14,7 @@ 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path +from django.urls import path, include import app.views @@ -25,5 +25,5 @@ path('add', app.views.add, name='add'), path('view/', app.views.view, name='view'), path('edit/', app.views.edit, name='edit'), - path('pending', app.views.pending) + path('pending/', app.views.pending) ] diff --git a/app/views.py b/app/views.py index f531770b6..9be3cde8e 100644 --- a/app/views.py +++ b/app/views.py @@ -97,7 +97,7 @@ def pending(request): ## Use raw query to get all objects with connection.cursor() as cursor: - cursor.execute("SELECT * FROM pending WHERE username = login_user") + cursor.execute("SELECT * FROM pending WHERE username = 'Johnny123'") pending_offers = cursor.fetchall() result_dict = {'records': pending_offers} @@ -111,8 +111,8 @@ def view_user(request, i_user): ## Use raw query to get a customer with connection.cursor() as cursor: cursor.execute("SELECT * FROM portfolio WHERE username = %s", [i_user]) - pending_offers = cursor.fetchone() - result_dict = {'interested_user': pending_offers} + interested_user = cursor.fetchone() + result_dict = {'interested_user': interested_user} return render(request,'app/view_user.html',result_dict) @@ -122,7 +122,7 @@ def view_offer(request, offerid): ## Use raw query to get a customer with connection.cursor() as cursor: cursor.execute("SELECT * FROM joboffer WHERE offerid = %s", [offerid]) - pending_offers = cursor.fetchone() - result_dict = {'offer': pending_offers} + offers = cursor.fetchone() + result_dict = {'offer': offers} return render(request,'app/view_offer.html',result_dict) From ee1f19fd92fdb7363f7eb92ca70e0facd5dbc5cd Mon Sep 17 00:00:00 2001 From: Jonas Lim Date: Sat, 2 Apr 2022 14:29:47 +0800 Subject: [PATCH 18/43] Enter --- .vscode/launch.json | 14 ++++++++++++++ app/templates/app/pending.html | 15 +++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..622975385 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,14 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "pwa-chrome", + "request": "launch", + "name": "Open index.html", + "file": "c:\\Users\\jonas\\Petsitting\\app\\templates\\app\\index.html" + } + ] +} \ No newline at end of file diff --git a/app/templates/app/pending.html b/app/templates/app/pending.html index 9c3654fa5..03dd2e706 100644 --- a/app/templates/app/pending.html +++ b/app/templates/app/pending.html @@ -8,17 +8,16 @@

Pending Offers

Interested User Action - {% for interested_user in records %} - {% for offer in records %} + {% for offer_user in records %} - {{ offer.0 }} - {{ interested_user.0 }} + {{ offer_user.0 }} + {{ offer_user.1 }} - | - + | + | - - + + {% endfor %} From 9a3a5f124ec864f9202aa3983fd0f6e4f8fd6e4a Mon Sep 17 00:00:00 2001 From: Jonas Lim Date: Sat, 2 Apr 2022 14:43:21 +0800 Subject: [PATCH 19/43] nter --- app/templates/app/pending.html | 4 ++-- app/views.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/templates/app/pending.html b/app/templates/app/pending.html index 03dd2e706..7c0442801 100644 --- a/app/templates/app/pending.html +++ b/app/templates/app/pending.html @@ -13,8 +13,8 @@

Pending Offers

{{ offer_user.0 }} {{ offer_user.1 }} - | - + | + | diff --git a/app/views.py b/app/views.py index 9be3cde8e..26e4cae76 100644 --- a/app/views.py +++ b/app/views.py @@ -112,9 +112,9 @@ def view_user(request, i_user): with connection.cursor() as cursor: cursor.execute("SELECT * FROM portfolio WHERE username = %s", [i_user]) interested_user = cursor.fetchone() - result_dict = {'interested_user': interested_user} + result_dict2 = {'interested_user': interested_user} - return render(request,'app/view_user.html',result_dict) + return render(request,'app/view_user.html',result_dict2) def view_offer(request, offerid): """Shows the main page""" @@ -123,6 +123,6 @@ def view_offer(request, offerid): with connection.cursor() as cursor: cursor.execute("SELECT * FROM joboffer WHERE offerid = %s", [offerid]) offers = cursor.fetchone() - result_dict = {'offer': offers} + result_dict1 = {'offer': offers} - return render(request,'app/view_offer.html',result_dict) + return render(request,'app/view_offer.html',result_dict1) From 27b1da32736ea1823e564c0f68390129ebef18ef Mon Sep 17 00:00:00 2001 From: Jonas Lim Date: Sat, 2 Apr 2022 14:52:25 +0800 Subject: [PATCH 20/43] Enter --- app/templates/app/pending.html | 2 +- app/views.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/templates/app/pending.html b/app/templates/app/pending.html index 7c0442801..d1ce5e784 100644 --- a/app/templates/app/pending.html +++ b/app/templates/app/pending.html @@ -10,7 +10,7 @@

Pending Offers

{% for offer_user in records %} - {{ offer_user.0 }} + {{ helloworld }} {{ offer_user.1 }} | diff --git a/app/views.py b/app/views.py index 26e4cae76..e49c645aa 100644 --- a/app/views.py +++ b/app/views.py @@ -101,8 +101,9 @@ def pending(request): pending_offers = cursor.fetchall() result_dict = {'records': pending_offers} + helloworld = {"hello" : "world"} - return render(request,'app/pending.html',result_dict) + return render(request,'app/pending.html',result_dict, helloworld) # Create your view_user here. def view_user(request, i_user): From 5a81d596ac4a03ac6a2d97ee75d0f0c238f7bf54 Mon Sep 17 00:00:00 2001 From: Jonas Lim Date: Sat, 2 Apr 2022 14:57:56 +0800 Subject: [PATCH 21/43] Enter --- .vscode/launch.json | 1 + app/views.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 622975385..9dbe9aa3c 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,6 +4,7 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ + { "type": "pwa-chrome", "request": "launch", diff --git a/app/views.py b/app/views.py index e49c645aa..f1d91b52c 100644 --- a/app/views.py +++ b/app/views.py @@ -92,7 +92,7 @@ def edit(request, id): # Create your views here. -def pending(request): +def pending(request, *args, **kwargs): """Shows the pending page""" ## Use raw query to get all objects From 386dac77af3e6ec107b619b1b9c8adeed4ea3dbb Mon Sep 17 00:00:00 2001 From: Jonas Lim Date: Sat, 2 Apr 2022 15:32:09 +0800 Subject: [PATCH 22/43] Enter --- .vscode/launch.json | 2 +- add_sql.sh | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 9dbe9aa3c..ae56c489a 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,7 +4,7 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ - + { "type": "pwa-chrome", "request": "launch", diff --git a/add_sql.sh b/add_sql.sh index 2304183ff..35273aba7 100755 --- a/add_sql.sh +++ b/add_sql.sh @@ -33,3 +33,9 @@ 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/PetsittingSchema.sql +psql ${URI} -f sql/Petsittingjoboffer.sql +psql ${URI} -f sql/Petsittingpending.sql +psql ${URI} -f sql/Petsittingpet.sql +psql ${URI} -f sql/Petsittingportfolio.sql +psql ${URI} -f sql/Petsittingtransaction.sql \ No newline at end of file From eca922d429ed120bafe390124a0b1d56b4c76e81 Mon Sep 17 00:00:00 2001 From: Jonas Lim Date: Sat, 2 Apr 2022 15:45:44 +0800 Subject: [PATCH 23/43] Enter --- add_sql.sh | 10 +++++----- app/templates/app/pending.html | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/add_sql.sh b/add_sql.sh index 35273aba7..33de6467f 100755 --- a/add_sql.sh +++ b/add_sql.sh @@ -1,9 +1,9 @@ # Construct the URI from the .env -DB_HOST='' -DB_NAME='' -DB_USER='' -DB_PORT='' -DB_PASSWORD='' +DB_HOST='localhost' +DB_NAME='prosgres' +DB_USER='postgrs' +DB_PORT='5432' +DB_PASSWORD='baboon13' while IFS= read -r line do diff --git a/app/templates/app/pending.html b/app/templates/app/pending.html index d1ce5e784..166db7fb5 100644 --- a/app/templates/app/pending.html +++ b/app/templates/app/pending.html @@ -10,7 +10,7 @@

Pending Offers

{% for offer_user in records %} - {{ helloworld }} + {{helloworld}} {{ offer_user.1 }} | From 7c7e0a6e62bb62678b8799bf3a99e8edad331a98 Mon Sep 17 00:00:00 2001 From: Jonas Lim Date: Sat, 2 Apr 2022 18:03:18 +0800 Subject: [PATCH 24/43] Enter --- .env | 4 ++-- AppStore/urls.py | 2 +- app/views.py | 5 ++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.env b/.env index a30fada30..0daba83a1 100644 --- a/.env +++ b/.env @@ -8,10 +8,10 @@ DEBUG = True RUN_LOCAL_DB = True ##### Local database ###### -LOCAL_DB_NAME='appstore' +LOCAL_DB_NAME='petsitting' LOCAL_DB_USER='postgres' # Leave the below empty if you haven't set up a local password -LOCAL_DB_PASSWORD='postgres' +LOCAL_DB_PASSWORD='baboon13' ##### Heroku database ###### DB_HOST='ec2-3-212-45-192.compute-1.amazonaws.com' diff --git a/AppStore/urls.py b/AppStore/urls.py index f531b69b7..9ebbaaff3 100644 --- a/AppStore/urls.py +++ b/AppStore/urls.py @@ -25,5 +25,5 @@ path('add', app.views.add, name='add'), path('view/', app.views.view, name='view'), path('edit/', app.views.edit, name='edit'), - path('pending/', app.views.pending) + path('pending/', app.views.pending, name='pending') ] diff --git a/app/views.py b/app/views.py index f1d91b52c..6d9be2c33 100644 --- a/app/views.py +++ b/app/views.py @@ -97,13 +97,12 @@ def pending(request, *args, **kwargs): ## Use raw query to get all objects with connection.cursor() as cursor: - cursor.execute("SELECT * FROM pending WHERE username = 'Johnny123'") + cursor.execute("SELECT * FROM pending") pending_offers = cursor.fetchall() result_dict = {'records': pending_offers} - helloworld = {"hello" : "world"} - return render(request,'app/pending.html',result_dict, helloworld) + return render(request,'app/pending.html',result_dict) # Create your view_user here. def view_user(request, i_user): From 24bec5f70f2aec045f14eb21242dd8a02023f784 Mon Sep 17 00:00:00 2001 From: Jonas Lim Date: Sat, 2 Apr 2022 18:03:47 +0800 Subject: [PATCH 25/43] Enter --- app/templates/app/pending.html | 7 ++----- sql/PetSittingSchema.sql | 1 + 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/templates/app/pending.html b/app/templates/app/pending.html index 166db7fb5..5b270109d 100644 --- a/app/templates/app/pending.html +++ b/app/templates/app/pending.html @@ -13,11 +13,8 @@

Pending Offers

{{helloworld}} {{ offer_user.1 }} - | - - | - - + | + {% endfor %} diff --git a/sql/PetSittingSchema.sql b/sql/PetSittingSchema.sql index bec92cdee..0788e59e4 100644 --- a/sql/PetSittingSchema.sql +++ b/sql/PetSittingSchema.sql @@ -42,6 +42,7 @@ CHECK (rating >= 0 AND rating <= 5) ); CREATE TABLE IF NOT EXISTS pending ( +username VARCHAR(256) REFERENCES portfolio(username) DEFERRABL offerid VARCHAR(32) REFERENCES joboffer(offerid) DEFERRABLE, username VARCHAR(256) REFERENCES portfolio(username) DEFERRABLE ); From 1ab7dd2d621a5303b1b74d6050bce0b1a4b27cb3 Mon Sep 17 00:00:00 2001 From: Jonas Lim Date: Sun, 3 Apr 2022 14:32:32 +0800 Subject: [PATCH 26/43] Enter --- .vscode/settings.json | 5 +++++ app/templates/app/pending.html | 12 ++++++------ app/views.py | 4 ++-- 3 files changed, 13 insertions(+), 8 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..c48c3a243 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.associations": { + "\"python.pythonPath\"": "\"Your_venv_path/bin/python\"" + } +} \ No newline at end of file diff --git a/app/templates/app/pending.html b/app/templates/app/pending.html index 5b270109d..e2ad67c0a 100644 --- a/app/templates/app/pending.html +++ b/app/templates/app/pending.html @@ -8,14 +8,14 @@

Pending Offers

Interested User Action - {% for offer_user in records %} + {% for pending_offers in pending_records %} - {{helloworld}} - {{ offer_user.1 }} + {{ pending_offers.0 }} + {{ pending_offers.1 }} - | - - + | + + {% endfor %} diff --git a/app/views.py b/app/views.py index 6d9be2c33..93b733dbc 100644 --- a/app/views.py +++ b/app/views.py @@ -92,7 +92,7 @@ def edit(request, id): # Create your views here. -def pending(request, *args, **kwargs): +def pending(request): """Shows the pending page""" ## Use raw query to get all objects @@ -100,7 +100,7 @@ def pending(request, *args, **kwargs): cursor.execute("SELECT * FROM pending") pending_offers = cursor.fetchall() - result_dict = {'records': pending_offers} + result_dict = {'pending_records': pending_offers} return render(request,'app/pending.html',result_dict) From 21fb0f96b6f071bdb14ea19b2858980ded2ab114 Mon Sep 17 00:00:00 2001 From: Jonas Lim Date: Sun, 3 Apr 2022 14:54:37 +0800 Subject: [PATCH 27/43] Enter --- AppStore/urls.py | 6 +++--- app/templates/{ => app}/view_offer.html | 0 app/views.py | 27 ++++++++++++------------- 3 files changed, 16 insertions(+), 17 deletions(-) rename app/templates/{ => app}/view_offer.html (100%) diff --git a/AppStore/urls.py b/AppStore/urls.py index 9ebbaaff3..ad8a8597c 100644 --- a/AppStore/urls.py +++ b/AppStore/urls.py @@ -21,9 +21,9 @@ urlpatterns = [ path('admin/', admin.site.urls), - path('', app.views.index, name='index'), + path('pending/', app.views.pending, name='pending'), + #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('pending/', app.views.pending, name='pending') + path('edit/', app.views.edit, name='edit') ] diff --git a/app/templates/view_offer.html b/app/templates/app/view_offer.html similarity index 100% rename from app/templates/view_offer.html rename to app/templates/app/view_offer.html diff --git a/app/views.py b/app/views.py index 93b733dbc..c68dd0e25 100644 --- a/app/views.py +++ b/app/views.py @@ -1,6 +1,18 @@ from django.shortcuts import render, redirect from django.db import connection +def pending(request): + """Shows the pending page""" + + ## Use raw query to get all objects + with connection.cursor() as cursor: + cursor.execute("SELECT * FROM pending") + pending_offers = cursor.fetchall() + + result_dict = {'pending_records': pending_offers} + + return render(request,'app/pending.html',result_dict) + # Create your views here. def index(request): """Shows the main page""" @@ -20,6 +32,7 @@ def index(request): return render(request,'app/index.html',result_dict) + # Create your views here. def view(request, id): """Shows the main page""" @@ -90,20 +103,6 @@ def edit(request, id): context["status"] = status return render(request, "app/edit.html", context) - # Create your views here. - -def pending(request): - """Shows the pending page""" - - ## Use raw query to get all objects - with connection.cursor() as cursor: - cursor.execute("SELECT * FROM pending") - pending_offers = cursor.fetchall() - - result_dict = {'pending_records': pending_offers} - - return render(request,'app/pending.html',result_dict) - # Create your view_user here. def view_user(request, i_user): """Shows the main page""" From fd673964c0e734d21f0163a039f56407697d5ca3 Mon Sep 17 00:00:00 2001 From: Jonas Lim Date: Mon, 4 Apr 2022 15:33:16 +0800 Subject: [PATCH 28/43] Enter --- app/templates/app/mypets.html | 25 ++++++++++ app/views.py | 93 ++++++++++++++++++++--------------- 2 files changed, 78 insertions(+), 40 deletions(-) create mode 100644 app/templates/app/mypets.html diff --git a/app/templates/app/mypets.html b/app/templates/app/mypets.html new file mode 100644 index 000000000..dc1a5050b --- /dev/null +++ b/app/templates/app/mypets.html @@ -0,0 +1,25 @@ +{% load static %} + + +

My Pets

+ +

+ + + + + + + + {% for animal in pets %} + + + + + + + + {% endfor %} +
Pet NamePet IDTypeBreed
{{ pets.0 }} {{ pets.1 }} {{ pets.2 }} {{ pets.3 }}
+ + \ No newline at end of file diff --git a/app/views.py b/app/views.py index c68dd0e25..58d253606 100644 --- a/app/views.py +++ b/app/views.py @@ -1,36 +1,24 @@ from django.shortcuts import render, redirect from django.db import connection -def pending(request): - """Shows the pending page""" +# # Create your views here. +# def index(request): +# """Shows the main page""" - ## Use raw query to get all objects - with connection.cursor() as cursor: - cursor.execute("SELECT * FROM pending") - pending_offers = cursor.fetchall() +# ## Delete customer +# if request.POST: +# if request.POST['action'] == 'delete': +# with connection.cursor() as cursor: +# cursor.execute("DELETE FROM customers WHERE customerid = %s", [request.POST['id']]) - result_dict = {'pending_records': pending_offers} +# ## Use raw query to get all objects +# with connection.cursor() as cursor: +# cursor.execute("SELECT * FROM customers ORDER BY customerid") +# customers = cursor.fetchall() - return render(request,'app/pending.html',result_dict) +# result_dict = {'records': customers} -# Create your views here. -def index(request): - """Shows the main page""" - - ## Delete customer - if request.POST: - if request.POST['action'] == 'delete': - with connection.cursor() as cursor: - cursor.execute("DELETE FROM customers WHERE customerid = %s", [request.POST['id']]) - - ## 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/index.html',result_dict) +# return render(request,'app/index.html',result_dict) # Create your views here. @@ -103,25 +91,50 @@ def edit(request, id): context["status"] = status return render(request, "app/edit.html", context) -# Create your view_user here. -def view_user(request, i_user): - """Shows the main page""" - - ## Use raw query to get a customer +def pending(request): + """Shows the pending page""" + + ## Use raw query to get all objects with connection.cursor() as cursor: - cursor.execute("SELECT * FROM portfolio WHERE username = %s", [i_user]) - interested_user = cursor.fetchone() - result_dict2 = {'interested_user': interested_user} - return render(request,'app/view_user.html',result_dict2) + cursor.execute("SELECT offerid, interested_username FROM pending WHERE username = 'johnny123'") + pendingoffers = cursor.fetchall() -def view_offer(request, offerid): - """Shows the main page""" + result_dict = {'pendingrecords': pendingoffers} + + return render(request,'app/pending.html',result_dict) + +def view_offer(request,offerid): + """Shows the offer info page""" ## Use raw query to get a customer with connection.cursor() as cursor: cursor.execute("SELECT * FROM joboffer WHERE offerid = %s", [offerid]) - offers = cursor.fetchone() - result_dict1 = {'offer': offers} + offer = cursor.fetchone() + result_dict = {'pendingoffers': offer} + + return render(request,'app/view_offer.html',result_dict) + +def view_user(request, username): + """Shows the user info page""" + + ## Use raw query to get a customer + with connection.cursor() as cursor: + cursor.execute("SELECT * FROM portfolio WHERE username = %s", [username]) + user = cursor.fetchone() + result_dict = {'pendingusers': user} + + return render(request,'app/view_user.html',result_dict) + +def mypets(request): + """Shows the pending page""" + + ## Use raw query to get all objects + with connection.cursor() as cursor: + + cursor.execute("SELECT * FROM pet WHERE username = 'johnny123'") + animal = cursor.fetchall() + + result_dict = {'pets': animal} - return render(request,'app/view_offer.html',result_dict1) + return render(request,'app/mypets.html',result_dict) From 8f8efb6325995958ecbe2ec7aaa24a5acfc8b086 Mon Sep 17 00:00:00 2001 From: Jonas Lim Date: Mon, 4 Apr 2022 17:59:17 +0800 Subject: [PATCH 29/43] Enter --- AppStore/urls.py | 9 +++- app/templates/app/history.html | 35 ++++++++++++++ app/templates/app/interested.html | 6 +++ app/templates/app/mypets.html | 10 ++-- app/templates/app/pending.html | 11 +++-- app/templates/app/sit_pet.html | 25 ++++++++++ app/templates/app/view_offer.html | 41 ++++++++++++++++ app/templates/app/view_pet.html | 45 ++++++++++++++++++ app/templates/app/view_user.html | 77 ++++++++++++++----------------- app/urls.py | 18 ++++++++ app/views.py | 40 +++++++++++++++- sql/AppStoreSchema.sql | 63 ++++++++++++++++--------- sql/PetSittingtransaction.sql | 8 +--- 13 files changed, 305 insertions(+), 83 deletions(-) create mode 100644 app/templates/app/history.html create mode 100644 app/templates/app/interested.html create mode 100644 app/templates/app/sit_pet.html create mode 100644 app/templates/app/view_pet.html create mode 100644 app/urls.py diff --git a/AppStore/urls.py b/AppStore/urls.py index ad8a8597c..288619664 100644 --- a/AppStore/urls.py +++ b/AppStore/urls.py @@ -21,8 +21,15 @@ urlpatterns = [ path('admin/', admin.site.urls), + path('', app.views.sit_pet, name='sit_pet'), + path('view_pet/', app.views.view_pet, name='view_pet'), + path('view_pet/interested/', app.views.interested, name='interested'), + path('mypets/', app.views.mypets, name='mypets'), path('pending/', app.views.pending, name='pending'), - #path('', app.views.index, name='index'),# + path('pending/view_offer/', app.views.view_offer, name='view_offer'), + path('pending/view_user/', app.views.view_user, name='view_user'), + path('history', app.views.history, name = 'history'), + #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') diff --git a/app/templates/app/history.html b/app/templates/app/history.html new file mode 100644 index 000000000..862222074 --- /dev/null +++ b/app/templates/app/history.html @@ -0,0 +1,35 @@ + + +

Transaction History

+ These are your history + + Back to home +

+ + + + + + + + + + + {% comment %} {% endcomment %} + + {% for transactions in history %} + + + + + + + + + + + + {% endfor %} +
Job Offer IDPriceLocationDate_fromDate_toPet IDPetsitterAction
{{ transactions.0 }} {{ transactions.1 }} {{ transactions.2 }} {{ transactions.3 }} {{ transactions.4 }} {{ transactions.5 }} {{ transactions.6 }}
+ + \ No newline at end of file diff --git a/app/templates/app/interested.html b/app/templates/app/interested.html new file mode 100644 index 000000000..ab7dbdf16 --- /dev/null +++ b/app/templates/app/interested.html @@ -0,0 +1,6 @@ + + +

Offer sent! The owner will get back to you!

+ Back to home + + \ No newline at end of file diff --git a/app/templates/app/mypets.html b/app/templates/app/mypets.html index dc1a5050b..ba2dbe81d 100644 --- a/app/templates/app/mypets.html +++ b/app/templates/app/mypets.html @@ -2,7 +2,7 @@

My Pets

- + Back to home

@@ -13,10 +13,10 @@

My Pets

{% for animal in pets %} - - - - + + + + {% endfor %} diff --git a/app/templates/app/pending.html b/app/templates/app/pending.html index e2ad67c0a..a2e236dae 100644 --- a/app/templates/app/pending.html +++ b/app/templates/app/pending.html @@ -1,6 +1,7 @@

Pending Offers

+ Back to home

{{ pets.0 }} {{ pets.1 }} {{ pets.2 }} {{ pets.3 }} {{ animal.0 }} {{ animal.1 }} {{ animal.2 }} {{ animal.3 }}
@@ -8,13 +9,13 @@

Pending Offers

- {% for pending_offers in pending_records %} + {% for pendingoffers in pendingrecords %} - - + + {% endfor %} diff --git a/app/templates/app/sit_pet.html b/app/templates/app/sit_pet.html new file mode 100644 index 000000000..549a7a74c --- /dev/null +++ b/app/templates/app/sit_pet.html @@ -0,0 +1,25 @@ +{% load static %} + + +

Sit a Pet

+ Back to home +

+
Interested User Action
{{ pending_offers.0 }} {{ pending_offers.1 }} {{ pendingoffers.0 }} {{ pendingoffers.1 }} - | - + | +
+ + + + + + {% for alloffers in total %} + + + + + + + {% endfor %} +
Offer IDPet IDAction
{{ alloffers.0 }} {{ alloffers.1 }} + | +
+ + \ No newline at end of file diff --git a/app/templates/app/view_offer.html b/app/templates/app/view_offer.html index e69de29bb..e83e24a46 100644 --- a/app/templates/app/view_offer.html +++ b/app/templates/app/view_offer.html @@ -0,0 +1,41 @@ + + +

Details for Offer {{pendingoffers.0}}

+ Back to home +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Offer ID: {{ pendingoffers.0 }}
Price: {{ pendingoffers.1 }}
Location: {{ pendingoffers.2 }}
Date From: {{ pendingoffers.3 }}
Date To: {{ pendingoffers.4 }}
Pet ID: {{ pendingoffers.5 }}
+ , + + \ No newline at end of file diff --git a/app/templates/app/view_pet.html b/app/templates/app/view_pet.html new file mode 100644 index 000000000..ab97e0523 --- /dev/null +++ b/app/templates/app/view_pet.html @@ -0,0 +1,45 @@ + + +

Details for Pet {{allpet.7}}

+ Back to home +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Pet Name: {{ allpet.0 }}
Pet Type: {{ allpet.1 }}
Breed: {{ allpet.2 }}
Date From: {{ allpet.3 }}
Date To: {{ allpet.4 }}
Location : {{ allpet.5 }}
Price : {{ allpet.6 }}
+ + \ No newline at end of file diff --git a/app/templates/app/view_user.html b/app/templates/app/view_user.html index 7d65684d4..56b55c358 100644 --- a/app/templates/app/view_user.html +++ b/app/templates/app/view_user.html @@ -1,44 +1,35 @@ - - -

Details for {{offer_user.1}}

-
Back to main menu -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ID: {{ cust.5 }}
First name: {{ cust.0 }}
Last name: {{ cust.1 }}
Email: {{ cust.2 }}
Date of birth: {{ cust.3 }}
Since: {{ cust.4 }}
Country: {{ cust.6 }}
- + + +

Details for {{pendingusers.0}}

+ Back to home +

+ + + + + + + + + + + + + + + + + + + + + + {% comment %} + + + + {% endcomment %} + +
Username: {{ pendingusers.0 }}
Email: {{ pendingusers.1 }}
Phone Number: {{ pendingusers.2 }}
Years of Experience: {{ pendingusers.3 }}
Rating: {{ insert avg rating with query }}
+ \ No newline at end of file diff --git a/app/urls.py b/app/urls.py new file mode 100644 index 000000000..c0c30b7fe --- /dev/null +++ b/app/urls.py @@ -0,0 +1,18 @@ +# from django.contrib import admin +# from django.urls import path, include + +# import app.views + +# urlpatterns = [ +# path('', app.views.sit_pet, name='sit_pet'), +# path('view_pet/', app.views.view_pet, name='view_pet'), +# path('view_pet/interested/', app.views.interested, name='interested'), +# path('mypets/', app.views.mypets, name='mypets'), +# path('pending/', app.views.pending, name='pending'), +# path('pending/view_offer/', app.views.view_offer, name='view_offer'), +# path('pending/view_user/', app.views.view_user, name='view_user'), +# #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') +# ] diff --git a/app/views.py b/app/views.py index 58d253606..ab751562f 100644 --- a/app/views.py +++ b/app/views.py @@ -127,7 +127,7 @@ def view_user(request, username): return render(request,'app/view_user.html',result_dict) def mypets(request): - """Shows the pending page""" + """Shows the mypets page""" ## Use raw query to get all objects with connection.cursor() as cursor: @@ -138,3 +138,41 @@ def mypets(request): result_dict = {'pets': animal} return render(request,'app/mypets.html',result_dict) + +def sit_pet(request): + """Shows the sit a pet page""" + + with connection.cursor() as cursor: + cursor.execute("SELECT offerid, petid FROM joboffer") + alloffers = cursor.fetchall() + + result_dict = {'total': alloffers} + + return render(request,'app/sit_pet.html', result_dict) + +def view_pet(request, petid): + """Shows the main page""" + + ## Use raw query to get a customer + with connection.cursor() as cursor: + cursor.execute("SELECT p.petname, p.type, p.breed, j.date_from, j.date_to, j.location, j.price, p.petid FROM pet p, joboffer j WHERE p.petid = %s AND p.petid = j.petid", [petid]) + eachpet = cursor.fetchone() + result_dict = {'allpet': eachpet} + + return render(request,'app/view_pet.html',result_dict) + +def interested(request): + """Shows the interested page""" + return render(request,'app/interested.html') + +def history(request): + """Shows the history page""" + + ## Use raw query to get all objects + with connection.cursor() as cursor: + cursor.execute("SELECT * FROM joboffer j, transaction t WHERE t.username = 'johnny123' AND t.username = j.username AND t.offerid = j.offerid") + transactions = cursor.fetchall() + + result_dict = {'history': transactions} + + return render(request,'app/history.html',result_dict) diff --git a/sql/AppStoreSchema.sql b/sql/AppStoreSchema.sql index c2bfc03c6..0daaa14fe 100644 --- a/sql/AppStoreSchema.sql +++ b/sql/AppStoreSchema.sql @@ -4,24 +4,45 @@ ********************/ -CREATE TABLE IF NOT EXISTS customers ( - first_name VARCHAR(64) NOT NULL, - last_name VARCHAR(64) NOT NULL, - email VARCHAR(64) UNIQUE NOT NULL, - dob DATE NOT NULL, - since DATE NOT NULL, - customerid VARCHAR(16) PRIMARY KEY, - country VARCHAR(16) NOT NULL); - -CREATE TABLE IF NOT EXISTS games( - name VARCHAR(32), - version CHAR(3), - price NUMERIC NOT NULL, - PRIMARY KEY (name, version)); - - CREATE TABLE downloads( - customerid VARCHAR(16) REFERENCES customers(customerid) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, - name VARCHAR(32), - version CHAR(3), - PRIMARY KEY (customerid, name, version), - FOREIGN KEY (name, version) REFERENCES games(name, version) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED); \ No newline at end of file +CREATE TABLE IF NOT EXISTS portfolio ( +username VARCHAR(256) PRIMARY KEY, +email VARCHAR(256) NOT NULL UNIQUE, +phonenum VARCHAR(8), +year_exp INT, +password VARCHAR(64) NOT NULL, +CHECK(length(phonenum) = 8), +CHECK(length(password) >= 8) +); + +CREATE TABLE IF NOT EXISTS pet ( +petname VARCHAR(32) NOT NULL, +petid VARCHAR(256) PRIMARY KEY, +type VARCHAR(62) NOT NULL, +breed VARCHAR(32) NOT NULL, +username VARCHAR(256) REFERENCES portfolio(username) DEFERRABLE +); + +CREATE TABLE IF NOT EXISTS joboffer ( +offerid VARCHAR(32) PRIMARY KEY, +price FLOAT, +location VARCHAR(256) NOT NULL, +date_from DATE NOT NULL, +date_to DATE NOT NULL, +petid VARCHAR(256) REFERENCES pet(petid) DEFERRABLE, +username VARCHAR(256) REFERENCES portfolio(username) DEFERRABLE, +UNIQUE (date_from, date_to, petid), +CHECK(date_to > date_from) +); + +CREATE TABLE IF NOT EXISTS transaction ( +offerid VARCHAR(32) REFERENCES joboffer(offerid) DEFERRABLE, +username VARCHAR(256) REFERENCES portfolio(username) DEFERRABLE, +petsitter VARCHAR(256) REFERENCES portfolio(username) DEFERRABLE, +rating INT, +CHECK (rating >= 0 AND rating <= 5) +); + +CREATE TABLE IF NOT EXISTS pending ( +offerid VARCHAR(32) REFERENCES joboffer(offerid) DEFERRABLE, +username VARCHAR(256) REFERENCES portfolio(username) DEFERRABLE +); \ No newline at end of file diff --git a/sql/PetSittingtransaction.sql b/sql/PetSittingtransaction.sql index b9e136b5b..f64343528 100644 --- a/sql/PetSittingtransaction.sql +++ b/sql/PetSittingtransaction.sql @@ -4,10 +4,4 @@ ****************************/ -INSERT INTO transaction VALUES (432, 'johnny123', 2); -INSERT INTO transaction VALUES (9000, 'gerald123', 5); -INSERT INTO transaction VALUES (7022, 'siewkit8899', 3); -INSERT INTO transaction VALUES (433, 'johnny123', 4); -INSERT INTO transaction VALUES (9001, 'gerald123', 3); -INSERT INTO transaction VALUES (7023, 'siewkit8899', 3); -INSERT INTO transaction VALUES (434, 'johnny123', 2); +INSERT INTO transaction VALUES (432, 'johnny123', 'gerald123', 2); From 957de20c560fa1876ab4880e1a539741d654cf58 Mon Sep 17 00:00:00 2001 From: Jonas Lim Date: Wed, 6 Apr 2022 19:04:37 +0800 Subject: [PATCH 30/43] Enter --- app/views.py | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/app/views.py b/app/views.py index ab751562f..87ad2e440 100644 --- a/app/views.py +++ b/app/views.py @@ -91,6 +91,10 @@ def edit(request, id): context["status"] = status return render(request, "app/edit.html", context) +def main_page(request): + """Shows the main page""" + return render(request,'app/main_page.html') + def pending(request): """Shows the pending page""" @@ -126,6 +130,58 @@ def view_user(request, username): return render(request,'app/view_user.html',result_dict) +def register_user(request): + """Shows the main page""" + context = {} + status = '' + + if request.POST: + ## Check if username is already in the table + with connection.cursor() as cursor: + + cursor.execute("SELECT * FROM portfolio WHERE username = %s", [request.POST['username']]) + user = cursor.fetchone() + ## No user with same username + if user == None: + ##TODO: date validation + cursor.execute("INSERT INTO portfolio VALUES (%s, %s, %s, %s, %s)" + , [request.POST['username'], request.POST['email'], request.POST['phonenum'], + request.POST['year_exp'] , request.POST['password'] ]) + return redirect('login') + else: + status = 'User with username %s already exists' % (request.POST['username']) + + + context['status'] = status + + return render(request, "app/register_user.html", context) + +def register_pet(request): + """Shows the main page""" + context = {} + status = '' + + if request.POST: + ## Check if petid is already in the table + with connection.cursor() as cursor: + + cursor.execute("SELECT * FROM pet WHERE petid = %s", [request.POST['petid']]) + pet = cursor.fetchone() + ## No pet with same petid + if pet == None: + ##TODO: date validation + cursor.execute("INSERT INTO pet VALUES (%s, %s, %s, %s, %s)" + , [request.POST['petname'], request.POST['petid'], request.POST['type'], + request.POST['breed'] , request.POST['username'] ]) + return redirect('index') + else: + status = 'Pet with ID %s already exists' % (request.POST['petid']) + + + context['status'] = status + + return render(request, "app/register_pet.html", context) + def mypets(request): """Shows the mypets page""" From d4a84cf4f2799e88b3d66b9e7520e7626392a037 Mon Sep 17 00:00:00 2001 From: Jonas Lim Date: Wed, 6 Apr 2022 23:12:01 +0800 Subject: [PATCH 31/43] Enter --- AppStore/urls.py | 25 ++++++++++++++----------- app/templates/app/history.html | 10 +++++----- app/templates/app/main_page.html | 15 +++++++++++++++ app/templates/app/mypets.html | 2 +- app/templates/app/pending.html | 2 +- app/templates/app/register_pet.html | 23 +++++++++++++++++++++++ app/templates/app/register_user.html | 23 +++++++++++++++++++++++ app/templates/app/sit_pet.html | 2 +- app/templates/app/view_offer.html | 2 +- app/templates/app/view_pet.html | 2 +- app/templates/app/view_user.html | 2 +- app/urls.py | 18 ------------------ sql/PetSittingSchema.sql | 25 +++++++++++++++++-------- sql/PetSittingpending.sql | 17 ++++++++++++++--- sql/PetSittingtransaction.sql | 11 +++++++++-- sql/Petsittingto_rate.sql | 10 ++++++++++ 16 files changed, 136 insertions(+), 53 deletions(-) create mode 100644 app/templates/app/main_page.html create mode 100644 app/templates/app/register_pet.html create mode 100644 app/templates/app/register_user.html delete mode 100644 app/urls.py create mode 100644 sql/Petsittingto_rate.sql diff --git a/AppStore/urls.py b/AppStore/urls.py index 288619664..c43d2e562 100644 --- a/AppStore/urls.py +++ b/AppStore/urls.py @@ -21,16 +21,19 @@ urlpatterns = [ path('admin/', admin.site.urls), - path('', app.views.sit_pet, name='sit_pet'), - path('view_pet/', app.views.view_pet, name='view_pet'), - path('view_pet/interested/', app.views.interested, name='interested'), - path('mypets/', app.views.mypets, name='mypets'), - path('pending/', app.views.pending, name='pending'), - path('pending/view_offer/', app.views.view_offer, name='view_offer'), - path('pending/view_user/', app.views.view_user, name='view_user'), - path('history', app.views.history, name = 'history'), + path('main_page/', app.views.main_page, name='main_page'), + path('main_page/sit_pet/', app.views.sit_pet, name='sit_pet'), + path('main_page/sit_pet/view_pet/', app.views.view_pet, name='view_pet'), + path('main_page/sit_pet/view_pet/interested/', app.views.interested, name='interested'), + path('register_user/', app.views.register_user, name = 'register_user'), + path('main_page/register_pet/', app.views.register_pet, name = 'register_pet'), + path('main_page/mypets/', app.views.mypets, name='mypets'), + path('main_page/pending/', app.views.pending, name='pending'), + path('main_page/pending/view_offer/', app.views.view_offer, name='view_offer'), + path('main_page/pending/view_user/', app.views.view_user, name='view_user'), + path('main_page/history/', app.views.history, name = 'history'), #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('add', app.views.add, name='add'), + #path('view/', app.views.view, name='view'), + #path('edit/', app.views.edit, name='edit') ] diff --git a/app/templates/app/history.html b/app/templates/app/history.html index 862222074..f89ada047 100644 --- a/app/templates/app/history.html +++ b/app/templates/app/history.html @@ -2,8 +2,8 @@

Transaction History

These are your history - - Back to home +

+ Back to home

@@ -14,8 +14,7 @@

Transaction History

- - {% comment %} {% endcomment %} + {% for transactions in history %} @@ -26,7 +25,8 @@

Transaction History

- + + {% endfor %} diff --git a/app/templates/app/main_page.html b/app/templates/app/main_page.html new file mode 100644 index 000000000..fd2ae1e1b --- /dev/null +++ b/app/templates/app/main_page.html @@ -0,0 +1,15 @@ + + +

Main Page

+ +

{{ status|safe }}

+ + + + + + {% comment %} {% endcomment %} + + {% comment %} {% endcomment %} + + \ No newline at end of file diff --git a/app/templates/app/mypets.html b/app/templates/app/mypets.html index ba2dbe81d..18485abc1 100644 --- a/app/templates/app/mypets.html +++ b/app/templates/app/mypets.html @@ -2,7 +2,7 @@

My Pets

- Back to home + Back to home

Date_to Pet ID PetsitterActionRating
{{ transactions.3 }} {{ transactions.4 }} {{ transactions.5 }} {{ transactions.6 }} {{ transactions.9 }} {{ transactions.10 }}
diff --git a/app/templates/app/pending.html b/app/templates/app/pending.html index a2e236dae..f5162c52a 100644 --- a/app/templates/app/pending.html +++ b/app/templates/app/pending.html @@ -1,7 +1,7 @@

Pending Offers

- Back to home + Back to home

diff --git a/app/templates/app/register_pet.html b/app/templates/app/register_pet.html new file mode 100644 index 000000000..9b5ad2ad2 --- /dev/null +++ b/app/templates/app/register_pet.html @@ -0,0 +1,23 @@ + + +

Register a new Pet

+ Back to home + +

{{ status|safe }}

+ + + + {% csrf_token %} + +
diff --git a/app/templates/app/view_offer.html b/app/templates/app/view_offer.html index e83e24a46..516fc56f3 100644 --- a/app/templates/app/view_offer.html +++ b/app/templates/app/view_offer.html @@ -1,7 +1,7 @@

Details for Offer {{pendingoffers.0}}

- Back to home + Back to home

diff --git a/app/templates/app/view_pet.html b/app/templates/app/view_pet.html index ab97e0523..42bccc8d7 100644 --- a/app/templates/app/view_pet.html +++ b/app/templates/app/view_pet.html @@ -1,7 +1,7 @@

Details for Pet {{allpet.7}}

- Back to home + Back to home

diff --git a/app/templates/app/view_user.html b/app/templates/app/view_user.html index 56b55c358..52d8dc053 100644 --- a/app/templates/app/view_user.html +++ b/app/templates/app/view_user.html @@ -1,7 +1,7 @@

Details for {{pendingusers.0}}

- Back to home + Back to home

diff --git a/app/urls.py b/app/urls.py deleted file mode 100644 index c0c30b7fe..000000000 --- a/app/urls.py +++ /dev/null @@ -1,18 +0,0 @@ -# from django.contrib import admin -# from django.urls import path, include - -# import app.views - -# urlpatterns = [ -# path('', app.views.sit_pet, name='sit_pet'), -# path('view_pet/', app.views.view_pet, name='view_pet'), -# path('view_pet/interested/', app.views.interested, name='interested'), -# path('mypets/', app.views.mypets, name='mypets'), -# path('pending/', app.views.pending, name='pending'), -# path('pending/view_offer/', app.views.view_offer, name='view_offer'), -# path('pending/view_user/', app.views.view_user, name='view_user'), -# #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') -# ] diff --git a/sql/PetSittingSchema.sql b/sql/PetSittingSchema.sql index 0788e59e4..1d0771a8e 100644 --- a/sql/PetSittingSchema.sql +++ b/sql/PetSittingSchema.sql @@ -29,20 +29,29 @@ location VARCHAR(256) NOT NULL, date_from DATE NOT NULL, date_to DATE NOT NULL, petid VARCHAR(256) REFERENCES pet(petid) DEFERRABLE, -username VARCHAR(256) REFERENCES portfolio(username) DEFERRABLE, UNIQUE (date_from, date_to, petid), CHECK(date_to > date_from) ); -CREATE TABLE IF NOT EXISTS transaction ( +CREATE TABLE IF NOT EXISTS pending ( offerid VARCHAR(32) REFERENCES joboffer(offerid) DEFERRABLE, -username VARCHAR(256) REFERENCES portfolio(username) DEFERRABLE, +petsitter VARCHAR(256) REFERENCES portfolio(username) DEFERRABLE, +UNIQUE (offerid, petsitter) +); + +CREATE TABLE IF NOT EXISTS transaction ( +offerid VARCHAR(32) REFERENCES joboffer(offerid) DEFERRABLE UNIQUE, +petsitter VARCHAR(256) REFERENCES portfolio(username) DEFERRABLE +); + +CREATE TABLE IF NOT EXISTS to_rate ( +offerid VARCHAR(32) REFERENCES joboffer(offerid) DEFERRABLE UNIQUE, rating INT, CHECK (rating >= 0 AND rating <= 5) ); -CREATE TABLE IF NOT EXISTS pending ( -username VARCHAR(256) REFERENCES portfolio(username) DEFERRABL -offerid VARCHAR(32) REFERENCES joboffer(offerid) DEFERRABLE, -username VARCHAR(256) REFERENCES portfolio(username) DEFERRABLE -); + + + + + diff --git a/sql/PetSittingpending.sql b/sql/PetSittingpending.sql index e6d724d5b..539fdbf98 100644 --- a/sql/PetSittingpending.sql +++ b/sql/PetSittingpending.sql @@ -1,8 +1,19 @@ /*************************** - Populate the portfolio table + Populate the pending table ****************************/ -INSERT INTO pending VALUES (432, 'gerald123'); -INSERT INTO pending VALUES (432, 'siewkit8899'); \ No newline at end of file +INSERT INTO pending VALUES (1, 'siewkit8899'); +INSERT INTO pending VALUES (1, 'gerald123'); +INSERT INTO pending VALUES (2, 'siewkit8899'); +INSERT INTO pending VALUES (2, 'johnny123'); +INSERT INTO pending VALUES (3, 'gerald123'); +INSERT INTO pending VALUES (3, 'johnny123'); +INSERT INTO pending VALUES (4, 'siewkit8899'); +INSERT INTO pending VALUES (4, 'gerald123'); +INSERT INTO pending VALUES (5, 'siewkit8899'); +INSERT INTO pending VALUES (5, 'gerald123'); + +select * from joboffer + diff --git a/sql/PetSittingtransaction.sql b/sql/PetSittingtransaction.sql index f64343528..ab7988a59 100644 --- a/sql/PetSittingtransaction.sql +++ b/sql/PetSittingtransaction.sql @@ -1,7 +1,14 @@ /*************************** - Populate the joboffer table + Populate the transaction table ****************************/ -INSERT INTO transaction VALUES (432, 'johnny123', 'gerald123', 2); +INSERT INTO transaction VALUES (1, 'siewkit8899'); +INSERT INTO transaction VALUES (2, 'johnny123'); +INSERT INTO transaction VALUES (3, 'gerald123'); +INSERT INTO transaction VALUES (4, 'siewkit8899'); +INSERT INTO transaction VALUES (5, 'gerald123'); + +select * from transaction +select * from pending \ No newline at end of file diff --git a/sql/Petsittingto_rate.sql b/sql/Petsittingto_rate.sql new file mode 100644 index 000000000..24145acaa --- /dev/null +++ b/sql/Petsittingto_rate.sql @@ -0,0 +1,10 @@ +/*************************** + + Populate the to_rate table + +****************************/ + +INSERT INTO to_rate VALUES (1, 5); +INSERT INTO to_rate VALUES (2, 3); +INSERT INTO to_rate VALUES (3, 4); +INSERT INTO to_rate VALUES (4, 2); \ No newline at end of file From 12afe748b6b934fd893e48df5c09249cb2942fbb Mon Sep 17 00:00:00 2001 From: Jonas Lim Date: Thu, 7 Apr 2022 01:01:43 +0800 Subject: [PATCH 32/43] Enter --- app/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views.py b/app/views.py index 87ad2e440..72d9ab84b 100644 --- a/app/views.py +++ b/app/views.py @@ -101,7 +101,7 @@ def pending(request): ## Use raw query to get all objects with connection.cursor() as cursor: - cursor.execute("SELECT offerid, interested_username FROM pending WHERE username = 'johnny123'") + cursor.execute("select * from pending where offerid in (select offerid from joboffer where petid in (select petid from pet where username = 'johnny123')) order by offerid") pendingoffers = cursor.fetchall() result_dict = {'pendingrecords': pendingoffers} @@ -199,7 +199,7 @@ def sit_pet(request): """Shows the sit a pet page""" with connection.cursor() as cursor: - cursor.execute("SELECT offerid, petid FROM joboffer") + cursor.execute("SELECT offerid, petid FROM joboffer WHERE petid NOT IN (SELECT petid FROM pet WHERE username = 'johnny123')") alloffers = cursor.fetchall() result_dict = {'total': alloffers} From 262292767cc0cd784fbb9ee39b03f388ec7a646f Mon Sep 17 00:00:00 2001 From: Jonas Lim Date: Thu, 7 Apr 2022 01:10:26 +0800 Subject: [PATCH 33/43] eNTER --- app/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views.py b/app/views.py index 72d9ab84b..e181b4ae9 100644 --- a/app/views.py +++ b/app/views.py @@ -101,7 +101,7 @@ def pending(request): ## Use raw query to get all objects with connection.cursor() as cursor: - cursor.execute("select * from pending where offerid in (select offerid from joboffer where petid in (select petid from pet where username = 'johnny123')) order by offerid") + cursor.execute("SELECT * FROM pending WHERE offerid IN (SELECT offerid FROM joboffer WHERE petid IN (SELECT petid FROM pet WHERE username = 'johnny123')) ORDER BY offerid") pendingoffers = cursor.fetchall() result_dict = {'pendingrecords': pendingoffers} From 1d983b48b47fc7816d3459e350f3b5c869daf2ef Mon Sep 17 00:00:00 2001 From: Jonas Lim Date: Thu, 7 Apr 2022 20:20:39 +0800 Subject: [PATCH 34/43] Enter --- AppStore/urls.py | 3 + app/templates/app/give_review.html | 18 ++++++ app/templates/app/history.html | 60 ++++++++++++++------ app/templates/app/interested.html | 10 ++-- app/templates/app/main_page.html | 4 +- app/templates/app/offer_accepted.html | 6 ++ app/templates/app/pending.html | 45 +++++++-------- app/templates/app/register_job.html | 22 ++++++++ app/templates/app/register_pet.html | 6 +- app/templates/app/view_offer.html | 2 - app/templates/app/view_user.html | 9 +-- app/views.py | 80 +++++++++++++++++++++------ sql/PetSittingjoboffer.sql | 15 ++--- 13 files changed, 199 insertions(+), 81 deletions(-) create mode 100644 app/templates/app/give_review.html create mode 100644 app/templates/app/offer_accepted.html create mode 100644 app/templates/app/register_job.html diff --git a/AppStore/urls.py b/AppStore/urls.py index c43d2e562..8a25ddc20 100644 --- a/AppStore/urls.py +++ b/AppStore/urls.py @@ -22,6 +22,7 @@ urlpatterns = [ path('admin/', admin.site.urls), path('main_page/', app.views.main_page, name='main_page'), + path('register_job/', app.views.register_job, name = 'register_job'), path('main_page/sit_pet/', app.views.sit_pet, name='sit_pet'), path('main_page/sit_pet/view_pet/', app.views.view_pet, name='view_pet'), path('main_page/sit_pet/view_pet/interested/', app.views.interested, name='interested'), @@ -31,7 +32,9 @@ path('main_page/pending/', app.views.pending, name='pending'), path('main_page/pending/view_offer/', app.views.view_offer, name='view_offer'), path('main_page/pending/view_user/', app.views.view_user, name='view_user'), + path('main_page/pending/offer_accepted/', app.views.offer_accepted, name='offer_accepted'), path('main_page/history/', app.views.history, name = 'history'), + path('main_page/history/give_review/', app.views.give_review, name = 'give_review'), #path('', app.views.index, name='index'), #path('add', app.views.add, name='add'), #path('view/', app.views.view, name='view'), diff --git a/app/templates/app/give_review.html b/app/templates/app/give_review.html new file mode 100644 index 000000000..9e46370e6 --- /dev/null +++ b/app/templates/app/give_review.html @@ -0,0 +1,18 @@ + + +

Leave a review!

+ Back to home + + +
+ + {% csrf_token %} + +
+ +
+ + + + \ No newline at end of file diff --git a/app/templates/app/history.html b/app/templates/app/history.html index f89ada047..e10b7ff00 100644 --- a/app/templates/app/history.html +++ b/app/templates/app/history.html @@ -1,35 +1,61 @@

Transaction History

- These are your history -

Back to home

-
+
+ Remember to give a rating! - - + + - + - {% for transactions in history %} + {% for transactions_nr in history_nr %} - - - - - - - - - - + + + + + + + + + {% endfor %}
Job Offer ID Price LocationDate_fromDate_toDate FromDate To Pet ID PetsitterRatingAction
{{ transactions.0 }} {{ transactions.1 }} {{ transactions.2 }} {{ transactions.3 }} {{ transactions.4 }} {{ transactions.5 }} {{ transactions.9 }} {{ transactions.10 }} {{ transactions_nr.0 }} {{ transactions_nr.1 }} {{ transactions_nr.2 }} {{ transactions_nr.3 }} {{ transactions_nr.4 }} {{ transactions_nr.5 }} {{ transactions_nr.6 }} +
+

+ + Past Transactions + + + + + + + + + + + {% for transactions_r in history_r %} + + + + + + + + + + + + {% endfor %} +
Job Offer IDPriceLocationDate FromDate ToPet IDPetsitterRating
{{ transactions_r.0 }} {{ transactions_r.1 }} {{ transactions_r.2 }} {{ transactions_r.3 }} {{ transactions_r.4 }} {{ transactions_r.5 }} {{ transactions_r.6 }} {{ transactions_r.7 }}
\ No newline at end of file diff --git a/app/templates/app/interested.html b/app/templates/app/interested.html index ab7dbdf16..e5686c585 100644 --- a/app/templates/app/interested.html +++ b/app/templates/app/interested.html @@ -1,6 +1,6 @@ - - -

Offer sent! The owner will get back to you!

- Back to home - + + +

Offer sent! The owner will get back to you!

+ Back to home + \ No newline at end of file diff --git a/app/templates/app/main_page.html b/app/templates/app/main_page.html index fd2ae1e1b..be5eb9d26 100644 --- a/app/templates/app/main_page.html +++ b/app/templates/app/main_page.html @@ -7,9 +7,9 @@

Main Page

+

- {% comment %} {% endcomment %} + - {% comment %} {% endcomment %} \ No newline at end of file diff --git a/app/templates/app/offer_accepted.html b/app/templates/app/offer_accepted.html new file mode 100644 index 000000000..d28be4fa9 --- /dev/null +++ b/app/templates/app/offer_accepted.html @@ -0,0 +1,6 @@ + + +

Offer accepted, please leave a review after the sitting!

+ Back to home + + \ No newline at end of file diff --git a/app/templates/app/pending.html b/app/templates/app/pending.html index f5162c52a..f450bcd90 100644 --- a/app/templates/app/pending.html +++ b/app/templates/app/pending.html @@ -1,24 +1,25 @@ - - -

Pending Offers

- Back to home -

- - - - - - - {% for pendingoffers in pendingrecords %} - - - - + + {% endfor %} +
Offer IDInterested UserAction
{{ pendingoffers.0 }} {{ pendingoffers.1 }} + + +

Pending Offers

+ Back to home +

+ + + + + + + {% for pendingoffers in pendingrecords %} + + + + - - {% endfor %} -
Offer IDInterested UserAction
{{ pendingoffers.0 }} {{ pendingoffers.1 }} | - -
- + | + +
+ \ No newline at end of file diff --git a/app/templates/app/register_job.html b/app/templates/app/register_job.html new file mode 100644 index 000000000..5ac199cd8 --- /dev/null +++ b/app/templates/app/register_job.html @@ -0,0 +1,22 @@ + + +

Register a new job

+ Back to home + +

{{ status|safe }}

+ +
+ + {% csrf_token %} + + price *