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

added product catalog views

parent 11bfd2fa
{% load static %}
<!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" />
<link rel="stylesheet" type="text/css" href="{% static 'style.css' %}" />
<title>Pixie Dust</title>
</head>
<body>
<header class="header" id="nav">
<div class="container">
<h2 class="logo"><a href="/">Pixie Dust</a></h2>
<ul>
{% block content-header %} {% endblock %}
</ul>
</div>
</header>
<div class="parent"> </div>
{% block content %} {% endblock %}
<footer>
<div class="footer-container">
<a href="/admin-pd">©Last Minute Surplus</a>
</div>
</footer>
</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="{% static 'script.js' %}"></script>
</html>
<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" />
<link rel="stylesheet" type="text/css" href="{% static 'style.css' %}" />
<title>Pixie Dust</title>
</head>
<body>
<header class="header" id="nav">
<div class="container">
<h2 class="logo"><a href="/">Pixie Dust</a></h2>
<ul>
{% block content-header %} {% endblock %}
</ul>
</div>
</header>
<div class="parent"> </div>
{% block content %} {% endblock %}
<footer>
<div class="footer-container">
<a href="/admin-pd">©Last Minute Surplus</a>
</div>
</footer>
</body>
<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
urlpatterns = [
path('', include('users.urls_main')),
path('admin-pd/', include('users.urls')),
path('admin-pd/products', include('products.urls')),
path('admin-pd/orders', include('orders.urls')),
path('admin-pd/products/', include('products.urls')),
path('admin-pd/orders/', include('orders.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 . import views
from .views import (
ProductsDetailView,
ProductsListView,
)
appname = "products"
urlpatterns = [
path('', views.index, name="index"),
path('/catalog', views.catalog, name='products'),
]
\ No newline at end of file
path('catalog', ProductsListView.as_view(), name='products-list'),
path('catalog/<int:pk>/details', ProductsDetailView.as_view(),
name='products-detail')
]
app_name = 'products'
......@@ -3,17 +3,26 @@ from .models import Product, Folder, PenOrganizer, Planner, Description
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView
from django.shortcuts import get_object_or_404
# Create your views here.
def index(request):
return render(request, "products/products.html")
def catalog(request):
product_list = Product.objects.all()
folder_list = Folder.objects.values('item_name', 'price', 'item_id').distinct()
pen_organizer_list = PenOrganizer.objects.all()
planner_list = Planner.objects.all()
description_list = Description.objects.all()
return render(request, "products/products.html", {"product_list":product_list, "folder_list":folder_list,
"pen_organizer_list":pen_organizer_list, "planner_list":planner_list,
"description_list":description_list})
\ No newline at end of file
class ProductsListView(ListView):
def get(self, request, *args, **kwargs):
product_list = Product.objects.all()
folder_list = Folder.objects.values(
'item_name', 'price', 'item_id').distinct()
pen_organizer_list = PenOrganizer.objects.all()
planner_list = Planner.objects.all()
return render(request, 'products/products_list.html',
{"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 @@
<div class="wrapper">
{% for folder in folder_list %}
<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-main">
<div class="item_name">{{ folder.item_name }}</div>
<div class="price">₱{{ folder.price }}</div>
<div class="price">₱{{ folder.price }}</div>
</div>
<ul>
{% for description in description_list %}
{% for description in description_list %}
{% if folder.item_id == description.item_id%}
<li>{{ description.feature_id.feature }}</li>
{% endif %}
......@@ -33,7 +35,7 @@
</ul>
</div>
</div>
{% endfor %}
{% endfor %}
</div>
</div>
<div class="collection" id="pen_organizer">
......@@ -41,14 +43,16 @@
<div class="wrapper">
{% for pen_organizer in pen_organizer_list %}
<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-main">
<div class="item_name">{{ pen_organizer.item_name }}</div>
<div class="price">₱{{ pen_organizer.price }}</div>
<div class="price">₱{{ pen_organizer.price }}</div>
</div>
<ul>
{% for description in description_list %}
{% for description in description_list %}
{% if pen_organizer.item_id == description.item_id.item_id%}
<li>{{ description.feature_id.feature }}</li>
{% endif %}
......@@ -64,14 +68,16 @@
<div class="wrapper">
{% for planner in planner_list %}
<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-main">
<div class="item_name">{{ planner.item_name }}</div>
<div class="price">₱{{ planner.price }}</div>
<div class="price">₱{{ planner.price }}</div>
</div>
<ul>
{% for description in description_list %}
{% for description in description_list %}
{% if planner.item_id == description.item_id.item_id%}
<li>{{ description.feature_id.feature }}</li>
{% endif %}
......@@ -84,4 +90,4 @@
</div>
</section>
<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