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>
<head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="{% static 'style.css' %}" /> <link rel="stylesheet" type="text/css" href="{% static 'style.css' %}" />
<title>Pixie Dust</title> <title>Pixie Dust</title>
</head> </head>
<body>
<body>
<header class="header" id="nav"> <header class="header" id="nav">
<div class="container"> <div class="container">
<h2 class="logo"><a href="/">Pixie Dust</a></h2> <h2 class="logo"><a href="/">Pixie Dust</a></h2>
...@@ -24,7 +26,8 @@ ...@@ -24,7 +26,8 @@
<a href="/admin-pd">©Last Minute Surplus</a> <a href="/admin-pd">©Last Minute Surplus</a>
</div> </div>
</footer> </footer>
</body> </body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="{% static 'script.js' %}"></script> <script src="{% static 'script.js' %}"></script>
</html> </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')
] ]
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):
class ProductsListView(ListView):
def get(self, request, *args, **kwargs):
product_list = Product.objects.all() product_list = Product.objects.all()
folder_list = Folder.objects.values('item_name', 'price', 'item_id').distinct() folder_list = Folder.objects.values(
'item_name', 'price', 'item_id').distinct()
pen_organizer_list = PenOrganizer.objects.all() pen_organizer_list = PenOrganizer.objects.all()
planner_list = Planner.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() description_list = Description.objects.all()
return render(request, "products/products.html", {"product_list":product_list, "folder_list":folder_list, return render(request, 'products/products_detail.html',
"pen_organizer_list":pen_organizer_list, "planner_list":planner_list, {'product': product, 'description_list': description_list})
"description_list":description_list})
\ No newline at end of file
...@@ -18,7 +18,9 @@ ...@@ -18,7 +18,9 @@
<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>
...@@ -41,7 +43,9 @@ ...@@ -41,7 +43,9 @@
<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>
...@@ -64,7 +68,9 @@ ...@@ -64,7 +68,9 @@
<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>
......
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