From 486c575cb49fcacf3758410cf5563a1f4f7c2fb2 Mon Sep 17 00:00:00 2001 From: mtyton Date: Thu, 8 Jun 2023 01:39:06 +0200 Subject: [PATCH] minor fixes, disabled mailing temporarily --- artel/store/admin.py | 9 ++++++++- artel/store/models.py | 8 ++++---- artel/store/templates/store/order_confirm.html | 5 ++++- artel/store/views.py | 1 + 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/artel/store/admin.py b/artel/store/admin.py index 104d31f..afd0798 100644 --- a/artel/store/admin.py +++ b/artel/store/admin.py @@ -35,6 +35,12 @@ class ProductAdmin(ModelAdmin): list_display = ("title", "price") + +class DocumentTemplateAdmin(ModelAdmin): + model = models.DocumentTemplate + list_display = ("name", "doc_type") + + class StoreAdminGroup(ModelAdminGroup): menu_label = "Store" menu_icon = 'folder-open-inverse' @@ -44,7 +50,8 @@ class StoreAdminGroup(ModelAdminGroup): ProductCategoryAdmin, ProductCategoryParamAdmin, ProductTemplateAdmin, - ProductAdmin + ProductAdmin, + DocumentTemplateAdmin ) diff --git a/artel/store/models.py b/artel/store/models.py index 785da07..1b44557 100644 --- a/artel/store/models.py +++ b/artel/store/models.py @@ -187,7 +187,7 @@ class CustomerData(models.Model): class OrderProductManager(models.Manager): def create_from_cart(self, cart, order): - for item in cart: + for item in cart.get_items(): self.create( product=item.product, order=order, @@ -222,8 +222,8 @@ class OrderManager(models.Manager): order=order, template=receipt_template ) - send_mail(agreement) - send_mail(receipt) + #send_mail(agreement) + #send_mail(receipt) return order @@ -249,7 +249,7 @@ class DocumentTemplate(models.Model): name = models.CharField(max_length=255) file = models.FileField(upload_to="documents") doc_type = models.CharField(max_length=255, choices=DocumentTypeChoices.choices) - created_at = models.DateTimeField(auto_now_add=True) + created_at = models.DateTimeField(auto_now_add=True, null=True) def __str__(self): return self.name diff --git a/artel/store/templates/store/order_confirm.html b/artel/store/templates/store/order_confirm.html index f4a49e9..73d0d22 100644 --- a/artel/store/templates/store/order_confirm.html +++ b/artel/store/templates/store/order_confirm.html @@ -65,7 +65,10 @@
To Pay: {{cart.total_price}}
- Confirm +
+ {% csrf_token %} + +
diff --git a/artel/store/views.py b/artel/store/views.py index 483daa7..9b47681 100644 --- a/artel/store/views.py +++ b/artel/store/views.py @@ -139,6 +139,7 @@ class OrderConfirmView(View): cart, customer_data ) self.request.session.pop("customer_data_id") + cart.clear() # TODO - messages return HttpResponseRedirect(reverse("cart"))