configurator is finished summary page has been added

main
mtyton 2023-07-21 21:34:37 +02:00
rodzic 10b9527261
commit 3a8ffd73c5
10 zmienionych plików z 115 dodań i 11 usunięć

Wyświetl plik

@ -6,6 +6,9 @@ services:
- "1025:1025"
- "8025:8025"
comfy:
depends_on:
- smtp-server
- db
build:
dockerfile: Dockerfile.local
context: ./

Wyświetl plik

@ -0,0 +1,23 @@
# Generated by Django 4.1.9 on 2023-07-20 16:50
from django.db import migrations, models
import uuid
class Migration(migrations.Migration):
dependencies = [
("store", "0011_productparam_delete_templateparamvalue_and_more"),
]
operations = [
migrations.AddField(
model_name="order",
name="uuid",
field=models.UUIDField(default=uuid.uuid4, editable=False),
),
migrations.AddField(
model_name="product",
name="uuid",
field=models.UUIDField(default=uuid.uuid4, editable=False),
),
]

Wyświetl plik

@ -1,6 +1,7 @@
import pdfkit
import datetime
import builtins
import uuid
from decimal import Decimal
from typing import (
@ -202,6 +203,7 @@ class Product(ClusterableModel):
)
price = models.FloatField()
available = models.BooleanField(default=True)
uuid = models.UUIDField(default=uuid.uuid4, editable=False)
objects = ProductManager()
@ -439,6 +441,7 @@ class Order(models.Model):
sent = models.BooleanField(default=False)
order_number = models.CharField(max_length=255, null=True)
uuid = models.UUIDField(default=uuid.uuid4, editable=False)
objects = OrderManager()
@property

Wyświetl plik

@ -10,7 +10,7 @@ $(document).on('click', '.add-to-cart-button', function(event) {
const csrfToken = $(this).data('csrf-token');
console.log(productID);
formData.append('product_id', productID);
formData.append('quantity', quantity); // Serialize the form data correctly
formData.append('quantity', 1); // Serialize the form data correctly
button.prop('disabled', true);
$.ajax({
type: 'POST',

Wyświetl plik

@ -1,6 +1,27 @@
{% extends 'base.html' %}
{% block content %}
<div class="modal" tabindex="-1" role="dialog" id="addToCartModal" aria-labelledby="addToCartLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Added to cart</h5>
</div>
<div class="modal-body">
<p>Item has been added to cart.</p>
</div>
<div class="modal-footer">
<a class="btn btn-secondary" href="{{store_url}}">Continue shopping</button>
<a href="{% url 'cart' %}" class="btn btn-primary">Go to cart</a>
</div>
</div>
</div>
</div>
<div class="container">
<a class="btn btn-outline-primary btn-lg" href="{% url 'product-configure' variant.template.pk %}">Wróć do konfiguratora</a>
</div>
<section class="h-100">
<div class="container">
<div class="row">
@ -38,9 +59,13 @@
{% endif %}
</div>
<div class="col-9 text-end">
<a class="btn btn-outline-primary btn-lg" href="{% url 'product-configure' variant.template.pk %}">Wróć do konfiguratora</a>
{% if variant.available %}
<button class="btn btn-outline-success btn-lg">Zamów produkt</button>
<button class="btn btn-outline-success btn-lg add-to-cart-button" data-product-id="{{variant.id}}"
data-add-to-cart-url="{% url 'cart-action-add-product' %}" data-csrf-token='{{ csrf_token }}'
data-bs-toggle="modal" data-bs-target="#addToCartModal">
Zamów produkt
</button>
{% else %}
<button class="btn btn-outline-success btn-lg">Złóż zapytanie ofertowe</button>
{% endif %}

Wyświetl plik

@ -0,0 +1,31 @@
{% extends 'base.html' %}
{% block content %}
<div class="d-flex justify-content-center align-items-center">
<div class="card col-9 bg-white shadow-md p-5">
<div class="mb-4 text-center">
<svg xmlns="http://www.w3.org/2000/svg" class="text-success" width="75" height="75"
fill="currentColor" class="bi bi-check-circle" viewBox="0 0 16 16">
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z" />
<path
d="M10.97 4.97a.235.235 0 0 0-.02.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-1.071-1.05z" />
</svg>
</div>
<div class="text-center">
<h1>Dziękujemy za zakup!</h1>
<div>
Twoje zamówienia zostały przekazane do realizacji.
Oczekuj maili z dokumentami to zamówień.<br/>
<b>Twoje numery zamówień:</b>
<div class="col-12 text-center">
{% for order in orders %}
<div class="row">{{order.order_number}}</div>
{% endfor %}
</div>
</div>
<a class="btn btn-outline-primary" href="{{store_url}}">Powrót do sklepu</a>
</div>
</div>
{% endblock %}

Wyświetl plik

@ -5,7 +5,7 @@
<div class="row d-flex justify-content-between align-items-center">
<div class="col-md-2 col-lg-2 col-xl-2">
<img
src="{{item.product.main_image.url}}"
src="{{item.product.main_image.image.url}}"
class="img-fluid rounded-3">
</div>
<div class="col-md-3 col-lg-3 col-xl-3">

Wyświetl plik

@ -5,7 +5,7 @@
<div class="row d-flex justify-content-between align-items-center">
<div class="col-md-2 col-lg-2 col-xl-2">
<img
src="{{item.product.main_image.url}}"
src="{{item.product.main_image.image.url}}"
class="img-fluid rounded-3">
</div>
<div class="col-md-3 col-lg-3 col-xl-3">

Wyświetl plik

@ -13,5 +13,6 @@ urlpatterns = [
path('product-configure/summary/<int:variant_pk>/', store_views.ConfigureProductSummaryView.as_view(), name='configure-product-summary'),
path('cart/', store_views.CartView.as_view(), name='cart'),
path("order/", store_views.OrderView.as_view(), name="order"),
path("order/confirm/", store_views.OrderConfirmView.as_view(), name="order-confirm")
path("order/confirm/", store_views.OrderConfirmView.as_view(), name="order-confirm"),
path("order/success/", store_views.OrderSuccessView.as_view(), name="order-success")
] + router.urls

Wyświetl plik

@ -26,7 +26,7 @@ from store.models import (
Order,
Product,
ProductTemplate,
ProductCategoryParamValue
ProductListPage
)
@ -127,9 +127,11 @@ class ConfigureProductSummaryView(View):
def get(self, request, variant_pk: int, *args, **kwargs):
variant = Product.objects.get(pk=variant_pk)
context = {
"variant": variant,
"params_values": variant.params.all()
"params_values": variant.params.all(),
"store_url": ProductListPage.objects.first().get_url()
}
return render(request, self.template_name, context)
@ -186,11 +188,27 @@ class OrderConfirmView(View):
def post(self, request):
customer_data = request.session["customer_data"]
cart = SessionCart(self.request)
Order.objects.create_from_cart(
order = Order.objects.create_from_cart(
cart.get_items(),
None, customer_data
)
request.session.pop("customer_data")
cart.clear()
messages.success(request, "Zamówienie zostało złożone, sprawdź swój email.")
return HttpResponseRedirect(reverse("cart"))
request.session["order_uuids"] = [str(elem) for elem in order.values_list("uuid", flat=True)]
return HttpResponseRedirect(reverse("order-success"))
class OrderSuccessView(View):
template_name = "store/order_success.html"
def get_context_data(self, **kwargs: Any) -> Dict[str, Any]:
return {
"orders": Order.objects.filter(uuid__in=self.request.session.get("order_uuids")),
"store_url": ProductListPage.objects.first().get_url()
}
def get(self, request, *args, **kwargs):
if not self.request.session.get("order_uuids"):
return HttpResponseRedirect(reverse("cart"))
return render(request, self.template_name, self.get_context_data())