diff --git a/src/core/tasks.py b/src/core/tasks.py index 27d0468..91a5ac1 100644 --- a/src/core/tasks.py +++ b/src/core/tasks.py @@ -19,7 +19,7 @@ ORDER_REFUND_TEMPLATE = 'storefront/order_refund' def send_order_confirmation_email(order): send_templated_mail( template_name=CONFIRM_ORDER_TEMPLATE, - from_email=settings.DEFAULT_FROM_EMAIL, + from_email=settings.ORDER_FROM_EMAIL, recipient_list=[order['email']], context=order ) @@ -30,7 +30,7 @@ def send_order_confirmation_email(order): def send_order_shipped_email(data): send_templated_mail( template_name=SHIP_ORDER_TEMPLATE, - from_email=settings.DEFAULT_FROM_EMAIL, + from_email=settings.ORDER_FROM_EMAIL, recipient_list=[data['email']], context=data ) diff --git a/src/ptcoffee/config.py b/src/ptcoffee/config.py index f57381e..eb89470 100644 --- a/src/ptcoffee/config.py +++ b/src/ptcoffee/config.py @@ -32,6 +32,7 @@ ANYMAIL_CONFIG = { SERVER_EMAIL = os.environ.get('SERVER_EMAIL', '') DEFAULT_FROM_EMAIL = os.environ.get('DEFAULT_FROM_EMAIL', '') DEFAULT_CONTACT_EMAIL = os.environ.get('DEFAULT_CONTACT_EMAIL', '') +ORDER_FROM_EMAIL = os.environ.get('ORDER_FROM_EMAIL', '') STATIC_ROOT_PATH = os.environ.get('STATIC_ROOT_PATH', '/var/www/ptcoffee-dev/static/') SECURE_HSTS_SECONDS = os.environ.get('SECURE_HSTS_SECONDS', 3600) diff --git a/src/static/images/site_banner.jpg b/src/static/images/site_banner.jpg index d78da3c..71a8105 100644 Binary files a/src/static/images/site_banner.jpg and b/src/static/images/site_banner.jpg differ diff --git a/src/static/styles/main.css b/src/static/styles/main.css index 329a342..5c98062 100644 --- a/src/static/styles/main.css +++ b/src/static/styles/main.css @@ -218,13 +218,26 @@ input[type=submit]:hover, /* Contact form ========================================================================== */ +.contact-form { + display: grid; + grid-template-columns: repeat(2, 1fr); + gap: 0 2rem; +} + +.contact-form p:nth-child(6) { + grid-column: span 2; +} + +.contact-form p:last-child { + grid-column: 2; +} + .contact-form label { display: block; } :is(.contact-form) input, select, textarea { width: 100%; - max-width: 600px; } @@ -476,12 +489,15 @@ section:not(:last-child) { background-image: url("/static/images/site_banner.jpg"); } .site__banner--fairtrade { + padding: 6rem 1rem; background-image: url("/static/images/fairtrade_banner.jpg"); } .site__banner--reviews { + padding: 6rem 1rem; background-image: url("/static/images/reviews_banner.jpg"); } .site__banner--about { + padding: 6rem 1rem; background-image: url("/static/images/coffee_banner.jpg"); } @@ -791,6 +807,15 @@ article + article { grid-column: 2; grid-row: 1; } + + .item__form { + flex-direction: column; + } + + .item__form *:not(:last-child) { + margin-bottom: 1rem; + width: 100%; + } } diff --git a/src/storefront/cart.py b/src/storefront/cart.py index 5ab3a40..4572634 100644 --- a/src/storefront/cart.py +++ b/src/storefront/cart.py @@ -62,10 +62,12 @@ class Cart: self.session.modified = True logger.info(f'\nCart:\n{self.cart}\n') - def remove(self, product): + def remove(self, product, grind): product_id = str(product.id) if product_id in self.cart: - del self.cart[product_id] + del self.cart[product_id]['variations'][grind] + if not self.cart[product_id]['variations']: + del self.cart[product_id] self.save() def __iter__(self): diff --git a/src/storefront/forms.py b/src/storefront/forms.py index 78891a5..51b9ff6 100644 --- a/src/storefront/forms.py +++ b/src/storefront/forms.py @@ -133,8 +133,7 @@ class ContactForm(forms.Form): (OTHER, 'Other (please describe below)'), ] - first_name = forms.CharField() - last_name = forms.CharField() + full_name = forms.CharField() email_address = forms.EmailField() referal = forms.ChoiceField( label='How did you find our website?', diff --git a/src/storefront/templates/storefront/cart_detail.html b/src/storefront/templates/storefront/cart_detail.html index 2b107d2..418d1dd 100644 --- a/src/storefront/templates/storefront/cart_detail.html +++ b/src/storefront/templates/storefront/cart_detail.html @@ -1,4 +1,5 @@ {% extends "base.html" %} +{% load grind_filter %} {% block head_title %}Cart | {% endblock %} @@ -15,20 +16,18 @@ {{product.get_first_img.image}}
-

{{product.name}}

-

Grind:

- {% for key, value in item.variations.items %} -

{{key}}
-

- {% csrf_token %} - {{ value.update_quantity_form }} - -
-

- {% endfor %} -

- Remove from cart +

{{product.name}}

+
Grind:
+ {% for key, value in item.variations.items %} +

{{ key|get_grind_display }}
+

+ {% csrf_token %} + {{ value.update_quantity_form }} + + Remove item +

+ {% endfor %}

${{item.price}}

diff --git a/src/storefront/templates/storefront/contact_form.html b/src/storefront/templates/storefront/contact_form.html index 6e5b12b..252f46a 100644 --- a/src/storefront/templates/storefront/contact_form.html +++ b/src/storefront/templates/storefront/contact_form.html @@ -13,9 +13,9 @@ Please contact us, we’re happy to help you over the phone
(360) 385-5856 Mon-Fri between 9:00 am and 5:00 pm Pacific Time.

+

Or send us a message using the form below and we'll email you back as soon as we can.

-

Or send us a message using the form below and we'll email you back as soon as we can.

{% csrf_token %} {{form.as_p}} diff --git a/src/storefront/templates/storefront/order_form.html b/src/storefront/templates/storefront/order_form.html index ff960ce..3e50ac8 100644 --- a/src/storefront/templates/storefront/order_form.html +++ b/src/storefront/templates/storefront/order_form.html @@ -1,5 +1,6 @@ {% extends "base.html" %} {% load static %} +{% load grind_filter %} {% block head_title %}Checkout | {% endblock %} @@ -38,7 +39,7 @@

{{product.name}}

{% for key, value in item.variations.items %} -

Grind: {{key}}, Qty: {{value.quantity}}

+

Grind: {{ key|get_grind_display }}, Qty: {{value.quantity}}

{% endfor %}
diff --git a/src/storefront/templatetags/__init__.py b/src/storefront/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/storefront/templatetags/grind_filter.py b/src/storefront/templatetags/grind_filter.py new file mode 100644 index 0000000..2478d74 --- /dev/null +++ b/src/storefront/templatetags/grind_filter.py @@ -0,0 +1,8 @@ +from django import template +from core import CoffeeGrind + +def get_grind_display(value): + return next((v[1] for i, v in enumerate(CoffeeGrind.GRIND_CHOICES) if v[0] == value), None) + +register = template.Library() +register.filter('get_grind_display', get_grind_display) diff --git a/src/storefront/tests/test_cart.py b/src/storefront/tests/test_cart.py index 8935654..af47581 100644 --- a/src/storefront/tests/test_cart.py +++ b/src/storefront/tests/test_cart.py @@ -154,7 +154,7 @@ class CartTest(TestCase): update_quantity=False ) self.assertEqual(len(cart), 3) - cart.remove(self.product) + cart.remove(self.product, CoffeeGrind.WHOLE) self.assertEqual(len(cart), 0) def test_cart_get_total_weight(self): diff --git a/src/storefront/urls.py b/src/storefront/urls.py index 7764fd5..b99c650 100644 --- a/src/storefront/urls.py +++ b/src/storefront/urls.py @@ -15,7 +15,7 @@ urlpatterns = [ path('cart/', views.CartView.as_view(), name='cart-detail'), path('cart//add/', views.CartAddProductView.as_view(), name='cart-add'), path('cart//update//', views.CartUpdateProductView.as_view(), name='cart-update'), - path('cart//remove/', views.cart_remove_product_view, name='cart-remove'), + path('cart//remove//', views.cart_remove_product_view, name='cart-remove'), path('coupon/apply/', views.CouponApplyView.as_view(), name='coupon-apply'), diff --git a/src/storefront/views.py b/src/storefront/views.py index c585712..5adae4b 100644 --- a/src/storefront/views.py +++ b/src/storefront/views.py @@ -104,10 +104,10 @@ class CartUpdateProductView(SingleObjectMixin, FormView): return super().form_valid(form) -def cart_remove_product_view(request, pk): +def cart_remove_product_view(request, pk, grind): cart = Cart(request) product = get_object_or_404(Product, id=pk) - cart.remove(product) + cart.remove(product, grind) return redirect('storefront:cart-detail') diff --git a/src/templates/templated_email/storefront/contact_form.email b/src/templates/templated_email/storefront/contact_form.email index eed4a74..92839de 100644 --- a/src/templates/templated_email/storefront/contact_form.email +++ b/src/templates/templated_email/storefront/contact_form.email @@ -2,7 +2,7 @@ {% block plain %} Referred from: {{referal}} - From: {{first_name}} {{last_name}} {{email_address}} + From: {{full_name}} {{email_address}} Message: {{message}} {% endblock %} @@ -10,7 +10,7 @@ {% block html %}

Referred from:
{{referal}}

-

From:
{{first_name}} {{last_name}} {{email_address|urlize}}

+

From:
{{full_name}} {{email_address|urlize}}

Message:
{{message|linebreaks}}

{% endblock %} diff --git a/src/templates/templated_email/storefront/order_confirmation.email b/src/templates/templated_email/storefront/order_confirmation.email index 25c1739..2157214 100644 --- a/src/templates/templated_email/storefront/order_confirmation.email +++ b/src/templates/templated_email/storefront/order_confirmation.email @@ -4,7 +4,7 @@ Hi {{full_name}}, we're getting your order ready to be shipped. We will notify you when it has been sent. - If you have any questions, reply to this email or contact us at support@ptcoffee.com + If you have any questions, send us an email at support@ptcoffee.com. Thanks, Port Townsend Roasting Co. @@ -15,7 +15,7 @@

Hi {{full_name}}, we're getting your order ready to be shipped. We will notify you when it has been sent.

-

If you have any questions, reply to this email or contact us at support@ptcoffee.com

+

If you have any questions, send us an email at support@ptcoffee.com.

Thanks,
Port Townsend Roasting Co.