Commit 7a26904f authored by Bryan Carlo Guanlao's avatar Bryan Carlo Guanlao

added product catalog views

parent 11bfd2fa
{% load static %} {% load static %}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head>
<meta charset="UTF-8" /> <head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="stylesheet" type="text/css" href="{% static 'style.css' %}" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Pixie Dust</title> <link rel="stylesheet" type="text/css" href="{% static 'style.css' %}" />
</head> <title>Pixie Dust</title>
<body> </head>
<header class="header" id="nav">
<div class="container"> <body>
<h2 class="logo"><a href="/">Pixie Dust</a></h2> <header class="header" id="nav">
<ul> <div class="container">
{% block content-header %} {% endblock %} <h2 class="logo"><a href="/">Pixie Dust</a></h2>
</ul> <ul>
</div> {% block content-header %} {% endblock %}
</header> </ul>
<div class="parent"> </div> </div>
{% block content %} {% endblock %} </header>
<footer> <div class="parent"> </div>
<div class="footer-container"> {% block content %} {% endblock %}
<a href="/admin-pd">©Last Minute Surplus</a> <footer>
</div> <div class="footer-container">
</footer> <a href="/admin-pd">©Last Minute Surplus</a>
</body> </div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> </footer>
<script src="{% static 'script.js' %}"></script> </body>
</html> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="{% static 'script.js' %}"></script>
</html>
\ No newline at end of file
...@@ -20,7 +20,7 @@ from django.contrib import admin ...@@ -20,7 +20,7 @@ from django.contrib import admin
urlpatterns = [ urlpatterns = [
path('', include('users.urls_main')), path('', include('users.urls_main')),
path('admin-pd/', include('users.urls')), path('admin-pd/', include('users.urls')),
path('admin-pd/products', include('products.urls')), path('admin-pd/products/', include('products.urls')),
path('admin-pd/orders', include('orders.urls')), path('admin-pd/orders/', include('orders.urls')),
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
] ]
# Generated by Django 3.2.12 on 2022-11-27 12:46
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('products', '0001_initial'),
]
operations = [
migrations.AlterModelTable(
name='penorganizer',
table='penorganizer',
),
]
# Generated by Django 3.2.12 on 2022-11-27 12:47
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('products', '0002_alter_penorganizer_table'),
]
operations = [
migrations.AlterModelTable(
name='penorganizer',
table='pen_organizer',
),
]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Product Catalog</title>
</head>
<header>
<h1>This is the products html</h1>
</header>
<main>
<div class="collection" id="folder">
<h2>Folders</h2>
{% for folder in folder_list %}
<div class="card-content-main">
<div class="item_name">{{ folder.item_name }}</div>
<div class="price">₱{{ folder.price }}</div>
</div>
<ul>
{% for description in description_list %}
{% if folder.item_id == description.item_id%}
<li>{{ description.feature_id.feature }}</li>
{% endif %}
{% endfor %}
</ul>
</div>
{% endfor %}
</div>
</main>
<footer>
<div class="footer-container">
<a href="/admin-pd">©Last Minute Surplus</a>
</div>
</footer>
<body>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<header>
<h1>{{product.item_name}} Specs</h1>
</header>
<main>
<div>
{% if product.folder.collection == "F" %}
<div> Lenght: {{product.folder.length}} inches</div>
<div> Width: {{product.folder.width}} inches</div>
<div> Thickness: {{product.folder.thickness}} inches</div>
{% elif product.penorganizer.collection == "PO" %}
<div> Slots: {{product.penorganizer.slots}}</div>
{% elif product.planner.collection == "P" %}
<div> Lenght: {{product.planner.length}} inches</div>
<div> Width: {{product.planner.width}} inches</div>
<div> Thickness: {{product.planner.thickness}} inches</div>
{% endif %}
<div> Personalization: Up to {{product.personalization}} letters</div>
</div><br>
<div class="collection" id="folder">
<div> Features: </div>
{% for description in description_list %}
{% if product.item_id == description.item_id.item_id %}
<li>{{ description.feature_id.feature }}</li>
{% endif %}
</div>
{% endfor %}
<footer>
<div class="footer-container">
<a href="/admin-pd">©Last Minute Surplus</a>
</div>
</footer>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Product Catalog</title>
</head>
<header>
<h1>This is the products html</h1>
</header>
<main>
<div class="collection" id="folder">
<h2>Folders</h2>
{% for folder in folder_list %}
<div class="card-content-main">
<a href="{% url 'products:products-detail' folder.item_id %}">
<div class="item_name">{{ folder.item_name }}</div>
</a>
<div class="price">₱{{ folder.price }}</div><br>
{% endfor %}
</div>
<h2>Pen Organizers</h2>
{% for pen in pen_organizer_list %}
<div class="card-content-main">
<a href="{% url 'products:products-detail' pen.item_id %}">
<div class="item_name">{{ pen.item_name }}</div>
</a>
<div class="price">₱{{ pen.price }}</div><br>
{% endfor %}
</div>
<h2>Planners</h2>
{% for planner in planner_list %}
<div class="card-content-main">
<a href="{% url 'products:products-detail' planner.item_id %}">
<div class="item_name">{{ planner.item_name }}</div>
</a>
<div class="price">₱{{ planner.price }}</div><br>
{% endfor %}
</main>
<footer>
<div class="footer-container">
<a href="/admin-pd">©Last Minute Surplus</a>
</div>
</footer>
</html>
\ No newline at end of file
from django.urls import path from django.urls import path
from . import views from .views import (
ProductsDetailView,
ProductsListView,
)
appname = "products" appname = "products"
urlpatterns = [ urlpatterns = [
path('', views.index, name="index"), path('catalog', ProductsListView.as_view(), name='products-list'),
path('/catalog', views.catalog, name='products'), path('catalog/<int:pk>/details', ProductsDetailView.as_view(),
] name='products-detail')
\ No newline at end of file ]
app_name = 'products'
...@@ -3,17 +3,26 @@ from .models import Product, Folder, PenOrganizer, Planner, Description ...@@ -3,17 +3,26 @@ from .models import Product, Folder, PenOrganizer, Planner, Description
from django.views.generic.list import ListView from django.views.generic.list import ListView
from django.views.generic.detail import DetailView from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView from django.views.generic.edit import CreateView
from django.shortcuts import get_object_or_404
# Create your views here. # Create your views here.
def index(request):
return render(request, "products/products.html")
def catalog(request):
product_list = Product.objects.all() class ProductsListView(ListView):
folder_list = Folder.objects.values('item_name', 'price', 'item_id').distinct() def get(self, request, *args, **kwargs):
pen_organizer_list = PenOrganizer.objects.all() product_list = Product.objects.all()
planner_list = Planner.objects.all() folder_list = Folder.objects.values(
description_list = Description.objects.all() 'item_name', 'price', 'item_id').distinct()
return render(request, "products/products.html", {"product_list":product_list, "folder_list":folder_list, pen_organizer_list = PenOrganizer.objects.all()
"pen_organizer_list":pen_organizer_list, "planner_list":planner_list, planner_list = Planner.objects.all()
"description_list":description_list}) return render(request, 'products/products_list.html',
\ No newline at end of file {"product_list": product_list, "folder_list": folder_list,
"pen_organizer_list": pen_organizer_list, "planner_list": planner_list})
class ProductsDetailView(DetailView):
def get(self, request, *args, **kwargs):
product = get_object_or_404(Product, pk=kwargs['pk'])
description_list = Description.objects.all()
return render(request, 'products/products_detail.html',
{'product': product, 'description_list': description_list})
...@@ -18,14 +18,16 @@ ...@@ -18,14 +18,16 @@
<div class="wrapper"> <div class="wrapper">
{% for folder in folder_list %} {% for folder in folder_list %}
<div class="card"> <div class="card">
<div class="img_wrapper"><img src="https://images.unsplash.com/photo-1615485737442-7d6ab9f64db9?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1470&q=80" alt="product"></div> <div class="img_wrapper"><img
src="https://images.unsplash.com/photo-1615485737442-7d6ab9f64db9?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1470&q=80"
alt="product"></div>
<div class="card-content"> <div class="card-content">
<div class="card-content-main"> <div class="card-content-main">
<div class="item_name">{{ folder.item_name }}</div> <div class="item_name">{{ folder.item_name }}</div>
<div class="price">₱{{ folder.price }}</div> <div class="price">₱{{ folder.price }}</div>
</div> </div>
<ul> <ul>
{% for description in description_list %} {% for description in description_list %}
{% if folder.item_id == description.item_id%} {% if folder.item_id == description.item_id%}
<li>{{ description.feature_id.feature }}</li> <li>{{ description.feature_id.feature }}</li>
{% endif %} {% endif %}
...@@ -33,7 +35,7 @@ ...@@ -33,7 +35,7 @@
</ul> </ul>
</div> </div>
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
</div> </div>
<div class="collection" id="pen_organizer"> <div class="collection" id="pen_organizer">
...@@ -41,14 +43,16 @@ ...@@ -41,14 +43,16 @@
<div class="wrapper"> <div class="wrapper">
{% for pen_organizer in pen_organizer_list %} {% for pen_organizer in pen_organizer_list %}
<div class="card"> <div class="card">
<div class="img_wrapper"><img src="https://images.unsplash.com/photo-1615485737442-7d6ab9f64db9?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1470&q=80" alt="product"></div> <div class="img_wrapper"><img
src="https://images.unsplash.com/photo-1615485737442-7d6ab9f64db9?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1470&q=80"
alt="product"></div>
<div class="card-content"> <div class="card-content">
<div class="card-content-main"> <div class="card-content-main">
<div class="item_name">{{ pen_organizer.item_name }}</div> <div class="item_name">{{ pen_organizer.item_name }}</div>
<div class="price">₱{{ pen_organizer.price }}</div> <div class="price">₱{{ pen_organizer.price }}</div>
</div> </div>
<ul> <ul>
{% for description in description_list %} {% for description in description_list %}
{% if pen_organizer.item_id == description.item_id.item_id%} {% if pen_organizer.item_id == description.item_id.item_id%}
<li>{{ description.feature_id.feature }}</li> <li>{{ description.feature_id.feature }}</li>
{% endif %} {% endif %}
...@@ -64,14 +68,16 @@ ...@@ -64,14 +68,16 @@
<div class="wrapper"> <div class="wrapper">
{% for planner in planner_list %} {% for planner in planner_list %}
<div class="card"> <div class="card">
<div class="img_wrapper"><img src="https://images.unsplash.com/photo-1615485737442-7d6ab9f64db9?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1470&q=80" alt="product"></div> <div class="img_wrapper"><img
src="https://images.unsplash.com/photo-1615485737442-7d6ab9f64db9?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1470&q=80"
alt="product"></div>
<div class="card-content"> <div class="card-content">
<div class="card-content-main"> <div class="card-content-main">
<div class="item_name">{{ planner.item_name }}</div> <div class="item_name">{{ planner.item_name }}</div>
<div class="price">₱{{ planner.price }}</div> <div class="price">₱{{ planner.price }}</div>
</div> </div>
<ul> <ul>
{% for description in description_list %} {% for description in description_list %}
{% if planner.item_id == description.item_id.item_id%} {% if planner.item_id == description.item_id.item_id%}
<li>{{ description.feature_id.feature }}</li> <li>{{ description.feature_id.feature }}</li>
{% endif %} {% endif %}
...@@ -84,4 +90,4 @@ ...@@ -84,4 +90,4 @@
</div> </div>
</section> </section>
<br><br><br><br> <br><br><br><br>
{% endblock %} {% endblock %}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment