diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..73f69e0 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..787f961 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +Herbworld \ No newline at end of file diff --git a/.idea/Herbworld.iml b/.idea/Herbworld.iml new file mode 100644 index 0000000..9cf6ca9 --- /dev/null +++ b/.idea/Herbworld.iml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..f56ad02 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..ef6921a --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/prettier.xml b/.idea/prettier.xml new file mode 100644 index 0000000..b0ab31a --- /dev/null +++ b/.idea/prettier.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/herb_world/settings.py b/herb_world/settings.py index 8060994..72c1ef0 100644 --- a/herb_world/settings.py +++ b/herb_world/settings.py @@ -35,6 +35,13 @@ ALLOWED_HOSTS = [] +PSQL_HOST = os.environ.get('PSQL_HOST') +PSQL_PORT = os.environ.get('PSQL_PORT') +PSQL_USER = os.environ.get('PSQL_USER') +PSQL_PASSWORD = os.environ.get('PSQL_PASSWORD') +PSQL_DB = os.environ.get('PSQL_DB') + + # Application definition INSTALLED_APPS = [ @@ -82,9 +89,13 @@ # https://docs.djangoproject.com/en/2.2/ref/settings/#databases DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + "default": { + "ENGINE": "django.db.backends.postgresql", + "NAME": PSQL_DB, + "USER": PSQL_USER, + "PASSWORD": PSQL_PASSWORD, + "HOST": PSQL_HOST, + "PORT": PSQL_PORT, } } diff --git a/herbworldapp/templates/herbworldapp/home.html b/herbworldapp/templates/herbworldapp/home.html index a29145c..c41c0db 100644 --- a/herbworldapp/templates/herbworldapp/home.html +++ b/herbworldapp/templates/herbworldapp/home.html @@ -23,10 +23,11 @@ {% block body %} {% csrf_token %} -{% if messages %} - {% for message in messages %} - {{ message }} - {% endfor %} +{% if messages %} + +{% for message in messages %} +{{ message }} +{% endfor %} {% endif %}
@@ -64,7 +65,8 @@

10000<

- Plants bring natural beauty to our living spaces. By creating texture and balance, a room or patio can be transformed into an environment that comforts and welcomes. + Plants bring natural beauty to our living spaces. By creating texture and balance, a room or patio can be + transformed into an environment that comforts and welcomes. But, just like Miss Universe, plants can do more than look pretty. Come and explore the world of home-plants with Us!

@@ -91,8 +93,8 @@

500+

- Each of Nursery partners gaurantee quality plants and plant-related products. - Browse through more than 500 Nurseries and find the one nearest you to bring your green friends home! + Each of Nursery partners gaurantee quality plants and plant-related products. + Browse through more than 500 Nurseries and find the one nearest you to bring your green friends home!

@@ -105,12 +107,8 @@

500+ -
-
-
-
-

Nursery Nearby -

-
- {% for nursery in props reversed %} -
-
-
-
-
- Nursery Name: {{nursery.nursery_name}} -
-
-
-
- Owner Name: {{nursery.user.first_name}} {{nursery.user.last_name}} -
-
-
-
- Email : {{nursery.user.email}} -
-
- Phone : {{nursery.phone}} -
-
-
-
-
+
+
+
+
+
+

Nursery Nearby +

+
+
+ {% csrf_token %} +
+ +
+ +
+
+
+ You searched for{% for key, value in search.items %} + {{ value | safe }} + {% endfor %} + {% for nursery in props reversed %} +
+
+
+
+
+ Nursery Name: {{ nursery.nursery_name }} +
+
+ {#
#} + {#
#} + {# Owner#} + {# Name: {{ nursery.user.first_name }} {{ nursery.user.last_name }}#} + {#
#} + {#
#} +
+
+ Nursery Id : {{ nursery.nursery_id }} +
+
+ Phone : {{ nursery.phone }} +
+
+
+
+ +
+
+
+
+
+ {% endfor %}
-
-
- {% endfor %}
-
-
diff --git a/herbworldapp/templates/herbworldapp/productlist.html b/herbworldapp/templates/herbworldapp/productlist.html index 14f840f..519cb8e 100644 --- a/herbworldapp/templates/herbworldapp/productlist.html +++ b/herbworldapp/templates/herbworldapp/productlist.html @@ -2,248 +2,270 @@ {% load static %} {% block title %} -Product + Product {% endblock %} -{%block css%} - -#feedback-form { -width: 100%; -padding: 20px 50px 40px; -box-shadow: 1px 4px 10px 1px #aaa; -} - - -#feedback-form h2{ -text-align: center; -margin-bottom: 30px; -} - -#feedback-form input { -margin-bottom: 15px; -margin-top: 15px; -} - -#feedback-form input[type=text] { -display: block; -height: 32px; -padding: 6px 16px; -width: 100%; -border: none; -background-color: #f3f3f3; -} - -#feedback-form textarea { -display: block; -padding: 6px 16px; -width: 100%; -border: none; -background-color: #f3f3f3; -} - - - -.loginheading{ -font-weight: 400; -font-size: 3vw; -} -.loginheading1{ -color: #216B39; -font-weight: 800; -text-decoration: none; -} -.loginheading2{ -color: #000000; -font-weight: 800; -text-decoration: none; -} - -.cardbutton { -background-color: rgba(33,107,57); -cursor: pointer; -transition: 0.4s; -color: white; -} - -.cardbutton:hover { -background-color: rgba(33,107,57); -border: 3px solid #FFFFFF; -transform: scale(0.9, 0.9); -color: white; -border-radius: 25px; -} - -.productdetails{ -width: 100%; -padding: 20px; -box-shadow: 1px 4px 10px 1px #aaa; -} - - -.buynow{ -display: flex; -flex-direction: row-reverse; -} +{% block css %} + + #feedback-form { + width: 100%; + padding: 20px 50px 40px; + box-shadow: 1px 4px 10px 1px #aaa; + } + + + #feedback-form h2{ + text-align: center; + margin-bottom: 30px; + } + + #feedback-form input { + margin-bottom: 15px; + margin-top: 15px; + } + + #feedback-form input[type=text] { + display: block; + height: 32px; + padding: 6px 16px; + width: 100%; + border: none; + background-color: #f3f3f3; + } + + #feedback-form textarea { + display: block; + padding: 6px 16px; + width: 100%; + border: none; + background-color: #f3f3f3; + } + + + + .loginheading{ + font-weight: 400; + font-size: 3vw; + } + .loginheading1{ + color: #216B39; + font-weight: 800; + text-decoration: none; + } + .loginheading2{ + color: #000000; + font-weight: 800; + text-decoration: none; + } + + .cardbutton { + background-color: rgba(33,107,57); + cursor: pointer; + transition: 0.4s; + color: white; + } + + .cardbutton:hover { + background-color: rgba(33,107,57); + border: 3px solid #FFFFFF; + transform: scale(0.9, 0.9); + color: white; + border-radius: 25px; + } + + .productdetails{ + width: 100%; + padding: 20px; + box-shadow: 1px 4px 10px 1px #aaa; + } + + + .buynow{ + display: flex; + flex-direction: row-reverse; + } {% endblock %} {% block body %} -
-
-
-
-
-

Plants Nearby -

-
- {% for product in props %} -
-
-
-
-
- -
-
-
-
- Product Name: {{product.name}} -
-
- Product Id: {{product.product_id}} -
-
-
-
- Product Price: {{product.price}} -
-
- Product Quantity: {{product.quantity}} -
-
-
-
Product Description: {{product.description}}
-
-
- +
+
+
+
+
+

Plants Nearby +

-
-
+ + {% for product in props %} +
+
+
+
+
+ +
+
+
+
+ Product Name: {{ product.name }} +
+
+ Product Id: {{ product.product_id }} +
+
+
+
+ Product Price: {{ product.price }} +
+
+ Product Quantity: {{ product.quantity }} +
+
+
+
Product + Description: {{ product.description }}
+
+
+ +
+
+
+
+
+
+ {% endfor %}
-
-
- {% endfor %} -
- {% for product in props reversed %} - -
+
-{% endblock %} +{% endblock %} \ No newline at end of file diff --git a/herbworldapp/urls.py b/herbworldapp/urls.py index 3cf727d..40ca5f0 100644 --- a/herbworldapp/urls.py +++ b/herbworldapp/urls.py @@ -14,7 +14,7 @@ path("login/customerlogin", views.customerLogin, name="customerLogin"), path("login/customersignup", views.customerSignup, name="customerSignup"), path("logout/", views.logoutHome, name="logout"), - + path("nursery-search/", views.nurserySearch, name="nurserySearch"), path("myorders/", views.myOrders, name="myOrders"), @@ -26,7 +26,8 @@ path("manageproducts/", views.manageProducts, name="manageProducts"), path("manageproducts/addproduct", views.addProduct, name="addProduct"), path("manageproducts/delproduct", views.delProduct, name="delProduct"), - path("manageproducts/updateproduct", views.updateProduct, name="updateProduct"), + path("manageproducts/updateproduct", + views.updateProduct, name="updateProduct"), path("nurserylist/", views.nurseryList, name="nurseryList"), path("nurserylist/order", views.createOrder, name="createOrder"), diff --git a/herbworldapp/views.py b/herbworldapp/views.py index f93dd64..b899c4f 100644 --- a/herbworldapp/views.py +++ b/herbworldapp/views.py @@ -5,6 +5,8 @@ from django.core.mail import send_mail from django.contrib import messages from django.conf import settings +from django.db import connection + def home(request): return render(request, 'herbworldapp/home.html') @@ -19,8 +21,8 @@ def contactUs(request): message = request.POST['message'] try: email_from = settings.EMAIL_HOST_USER - recipient_list = [email_from,] - send_mail(name, message, from_email,recipient_list) + recipient_list = [email_from, ] + send_mail(name, message, from_email, recipient_list) except Exception: messages.info(request, "Email Not Send") return redirect('home') @@ -121,35 +123,47 @@ def addProduct(request): quantity = request.POST['productquantity'] product_id = request.POST['productid'] description = request.POST['productdescription'] - image = request.FILES["prod_image"] + image = request.FILES["prod_image"] print(image) nursery_id = request.user.username productdata = Product(name=name, price=price, quantity=quantity, - product_id=product_id, description=description, - nursery_id=nursery_id,product_image=image) + product_id=product_id, description=description, + nursery_id=nursery_id, product_image=image) productdata.save() return redirect('/manageproducts') def nurseryList(request): - props = Manager.objects.all() - return render(request, 'herbworldapp/nurserylist.html', {'props': props}) + cursor = connection.cursor() + sql_query = '''SELECT * FROM herbworldapp_manager''' + cursor.execute(sql_query) + props = cursor.fetchall() + nursery_list = [] + for prop in props: + nursery = {} + nursery['nursery_id'] = prop[0] + nursery['phone'] = prop[1] + nursery['nursery_name'] = prop[4] + nursery_list.append(nursery) + return render(request, 'herbworldapp/nurserylist.html', {'props': nursery_list}) def showNurseryProducts(request, username): props = Product.objects.filter(nursery_id=username) return render(request, 'herbworldapp/productlist.html', {'props': props}) + def delProduct(request): if request.method == 'POST': del_prodID = request.POST['productid'] - #del_prodID = int(del_prodID) - delete_prod = Product.objects.get(product_id = del_prodID) + # del_prodID = int(del_prodID) + delete_prod = Product.objects.get(product_id=del_prodID) delete_prod.delete() props = Product.objects.filter(nursery_id=request.user.username) return redirect('/manageproducts') + def createOrder(request): if request.method == 'POST': order_id = len(Order.objects.all()) + 1 @@ -162,13 +176,16 @@ def createOrder(request): price = request.POST['productprice'] address = request.POST['customeraddress'] - order_total = int(price)*int(quantity) + order_total = int(price) * int(quantity) orderdata = Order(order_id=order_id, product_id=product_id, nursery_id=nursery_id, - customer_id=customer_id, email=email, phone=phone, quantity=quantity, order_total=order_total, address=address) + customer_id=customer_id, email=email, phone=phone, quantity=quantity, + order_total=order_total, + address=address) orderdata.save() return redirect('home') + def updateProduct(request): if request.method == 'POST': product_id = request.POST['productid'] @@ -178,7 +195,7 @@ def updateProduct(request): desc = request.POST['productdescription'] Product.objects.filter(product_id=product_id).update(name=product_name, price=price, quantity=quantity, - description=desc) + description=desc) return redirect('/manageproducts') @@ -187,24 +204,50 @@ def myOrders(request): props = Order.objects.filter(customer_id=request.user.username) return render(request, 'herbworldapp/orderlist.html', {'props': props}) + def cancelOrder(request): if request.method == 'POST': cancel_orderID = request.POST['orderid'] cancel_orderID = int(cancel_orderID) - cancel_order = Order.objects.get(order_id = cancel_orderID) + cancel_order = Order.objects.get(order_id=cancel_orderID) cancel_order.delete() props = Order.objects.filter(customer_id=request.user.username) return redirect('home') + def manageOrders(request): props = Order.objects.filter(nursery_id=request.user.username) return render(request, 'herbworldapp/manageOrders.html', {'props': props}) + def confirmOrder(request): if request.method == 'POST': del_prodID = request.POST['productid'] - #del_prodID = int(del_prodID) - delete_prod = Product.objects.get(product_id = del_prodID) + # del_prodID = int(del_prodID) + delete_prod = Product.objects.get(product_id=del_prodID) delete_prod.delete() props = Product.objects.filter(nursery_id=request.user.username) return redirect('/manageorders') + + +def nurserySearch(request): + if request.method == 'POST': + nursery_name = request.POST['nursery_name'] + print(nursery_name) + # sql_query = '''SELECT * FROM herbworldapp_manager WHERE nursery_name='%{}%' '''.format(search_query) + # sql_query2 = '''SELECT * FROM herbworldapp_manager''' + cursor = connection.cursor() + sql_query = '''SELECT * FROM herbworldapp_manager WHERE nursery_name LIKE '%{}%';'''.format(nursery_name) + cursor.execute(sql_query) + props = cursor.fetchall() + nursery_list = [] + for prop in props: + nursery = {} + nursery['nursery_id'] = prop[0] + nursery['phone'] = prop[1] + nursery['nursery_name'] = prop[4] + nursery_list.append(nursery) + return render(request, 'herbworldapp/nurserylist.html', + {'props': nursery_list, 'search': {'name': nursery_name}}) + props = Manager.objects.all() + return render(request, 'herbworldapp/nurserylist.html', {'props': props}) diff --git a/media/herbworldapp/images/bundle-philo-crassulamini-betel-fittonia.webp b/media/herbworldapp/images/bundle-philo-crassulamini-betel-fittonia.webp new file mode 100644 index 0000000..1bfaf46 Binary files /dev/null and b/media/herbworldapp/images/bundle-philo-crassulamini-betel-fittonia.webp differ diff --git a/media/herbworldapp/images/bundle-philo-crassulamini-betel-fittonia_DW4EhRQ.webp b/media/herbworldapp/images/bundle-philo-crassulamini-betel-fittonia_DW4EhRQ.webp new file mode 100644 index 0000000..1bfaf46 Binary files /dev/null and b/media/herbworldapp/images/bundle-philo-crassulamini-betel-fittonia_DW4EhRQ.webp differ diff --git a/requirements.txt b/requirements.txt index ae0f013..0d5c1b9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,10 @@ asgiref==3.4.1 +autopep8==1.6.0 Django==3.2.7 Pillow==8.3.2 +psycopg2==2.9.3 +pycodestyle==2.8.0 python-dotenv==0.19.0 pytz==2021.1 sqlparse==0.4.2 +toml==0.10.2