diff --git a/src/core/models.py b/src/core/models.py index a64e201..60d809b 100644 --- a/src/core/models.py +++ b/src/core/models.py @@ -62,6 +62,15 @@ class Product(models.Model): def get_absolute_url(self): return reverse('dashboard:product-detail', kwargs={'pk': self.pk}) + def get_first_img(self): + return self.productphoto_set.first() + + def get_second_img(self): + try: + return self.productphoto_set.all()[1] + except IndexError: + pass + class Meta: ordering = ['sorting', 'name'] diff --git a/src/dashboard/templates/dashboard/order_detail.html b/src/dashboard/templates/dashboard/order_detail.html index be1a2de..995eb32 100644 --- a/src/dashboard/templates/dashboard/order_detail.html +++ b/src/dashboard/templates/dashboard/order_detail.html @@ -28,7 +28,7 @@
{% with product=item.product %}
- {{product.productphoto_set.first.image}} + {{product.get_first_img.image}}
{{product.name}}
Grind: {{item.customer_note}}
{{product.sku}} diff --git a/src/dashboard/templates/dashboard/order_fulfill.html b/src/dashboard/templates/dashboard/order_fulfill.html index f5f7620..2e7b351 100644 --- a/src/dashboard/templates/dashboard/order_fulfill.html +++ b/src/dashboard/templates/dashboard/order_fulfill.html @@ -27,7 +27,7 @@ {% with product=form.instance.product %} {{form.id}}
- {{product.productphoto_set.first.image}} + {{product.get_first_img.image}}
{{product.name}}
{{product.sku}} diff --git a/src/dashboard/templates/dashboard/product_confirm_delete.html b/src/dashboard/templates/dashboard/product_confirm_delete.html index 8f6d1a1..52df169 100644 --- a/src/dashboard/templates/dashboard/product_confirm_delete.html +++ b/src/dashboard/templates/dashboard/product_confirm_delete.html @@ -8,7 +8,7 @@
- {{product.productphoto_set.first.image}} + {{product.get_first_img.image}}
{% csrf_token %}

Are you sure you want to delete "{{ object }}"?

diff --git a/src/dashboard/templates/dashboard/product_detail.html b/src/dashboard/templates/dashboard/product_detail.html index f367505..17f56c4 100644 --- a/src/dashboard/templates/dashboard/product_detail.html +++ b/src/dashboard/templates/dashboard/product_detail.html @@ -12,7 +12,7 @@
- {{product.productphoto_set.first.image}} + {{product.get_first_img.image}}

{{product.name}}

diff --git a/src/dashboard/templates/dashboard/product_list.html b/src/dashboard/templates/dashboard/product_list.html index 002ed80..2f266d3 100644 --- a/src/dashboard/templates/dashboard/product_list.html +++ b/src/dashboard/templates/dashboard/product_list.html @@ -17,7 +17,7 @@ {% for product in product_list %}
- {{product.productphoto_set.first.image}} + {{product.get_first_img.image}}
{{product.name}} {{product.visible_in_listings|yesno:"Yes,No"}} diff --git a/src/media/products/images/decaf.png b/src/media/products/images/decaf.png deleted file mode 100644 index 5de7e2a..0000000 Binary files a/src/media/products/images/decaf.png and /dev/null differ diff --git a/src/static/scripts/index.js b/src/static/scripts/index.js index 27fd2b6..a6ac125 100644 --- a/src/static/scripts/index.js +++ b/src/static/scripts/index.js @@ -1,5 +1,9 @@ import { getCookie, setCookie } from "./cookie.js" +/* + * Newsletter modal + */ + // Get the modal const modal = document.querySelector(".modal-menu"); diff --git a/src/static/scripts/product_list.js b/src/static/scripts/product_list.js new file mode 100644 index 0000000..3f3619b --- /dev/null +++ b/src/static/scripts/product_list.js @@ -0,0 +1,17 @@ +/* + * Image hover swap + */ +function valueSwap(v1, v2) { + return [v2, v1] +} + +const productItemImages = document.querySelectorAll('.product__with-img-swap') + +productItemImages.forEach(productItemImage => { + productItemImage.addEventListener('mouseover', event => { + [event.target.src, event.target.dataset.altimgSrc] = valueSwap(event.target.src, event.target.dataset.altimgSrc) + }) + productItemImage.addEventListener('mouseout', event => { + [event.target.src, event.target.dataset.altimgSrc] = valueSwap(event.target.src, event.target.dataset.altimgSrc) + }) +}) diff --git a/src/static/styles/main.css b/src/static/styles/main.css index de030f6..e8fea5d 100644 --- a/src/static/styles/main.css +++ b/src/static/styles/main.css @@ -246,6 +246,10 @@ footer > section { margin: 0 auto; } +section:not(:last-child) { + margin-bottom: 1rem; +} + /* ========================================================================== Modal @@ -390,6 +394,7 @@ footer > section { margin: 0; padding: 0; display: flex; + flex-wrap: wrap; } .nav__menu { @@ -538,6 +543,11 @@ article + article { color: var(--fg-alt-color); } +.product__first-img--hidden, +.product__second-img--hidden { + display: none; +} + @media screen and (max-width: 900px) { .product__list { grid-template-columns: 1fr; diff --git a/src/storefront/tasks.py b/src/storefront/tasks.py index ae3350f..dadbf7f 100644 --- a/src/storefront/tasks.py +++ b/src/storefront/tasks.py @@ -14,7 +14,7 @@ COTACT_FORM_TEMPLATE = 'storefront/contact_form' def contact_form_email(formdata): send_templated_mail( template_name=COTACT_FORM_TEMPLATE, - from_email=formdata['email_address'], + from_email=settings.DEFAULT_FROM_EMAIL, recipient_list=[settings.DEFAULT_CONTACT_EMAIL], context=formdata ) diff --git a/src/storefront/templates/storefront/cart_detail.html b/src/storefront/templates/storefront/cart_detail.html index 60cd87c..9312e1d 100644 --- a/src/storefront/templates/storefront/cart_detail.html +++ b/src/storefront/templates/storefront/cart_detail.html @@ -10,7 +10,7 @@
{% with product=item.product %}
- {{product.productphoto_set.first.image}} + {{product.get_first_img.image}}

{{product.name}}

diff --git a/src/storefront/templates/storefront/fairtrade.html b/src/storefront/templates/storefront/fairtrade.html index 4b34b9b..7799b75 100644 --- a/src/storefront/templates/storefront/fairtrade.html +++ b/src/storefront/templates/storefront/fairtrade.html @@ -12,7 +12,7 @@
-

We pay a steep premium for these beans, which are typically from smaller farms that are organized into co-ops. These farms take pride in their coffees, as the farmers make a living wage and their families are able to live in a healthier, more secure environment than farmers who grow a conventional coffee crop. The quality of our coffee is consistent, in part due to the quality of organic and fair trade beans.

+

We value fair, guaranteed wages for growers and sustainable stewardship of the land where it’s grown. We pay a steep premium for these beans, which are typically from smaller farms that are organized into co-ops. These farms take pride in their coffees, as the farmers make a living wage and their families are able to live in a healthier, more secure environment than farmers who grow a conventional coffee crop. The quality of our coffee is consistent, in part due to the quality of organic and fair trade beans.

Fair trade
diff --git a/src/storefront/templates/storefront/order_detail.html b/src/storefront/templates/storefront/order_detail.html index 195e5ec..e1c45a4 100644 --- a/src/storefront/templates/storefront/order_detail.html +++ b/src/storefront/templates/storefront/order_detail.html @@ -23,7 +23,7 @@ {% with product=item.product %} - {{product.productphoto_set.first.image}} + {{product.get_first_img.image}} {{product.name}} {{item.quantity}} diff --git a/src/storefront/templates/storefront/order_form.html b/src/storefront/templates/storefront/order_form.html index 41d95f1..cc93262 100644 --- a/src/storefront/templates/storefront/order_form.html +++ b/src/storefront/templates/storefront/order_form.html @@ -30,7 +30,7 @@
{% with product=item.product %}
- {{product.productphoto_set.first.image}} + {{product.get_first_img.image}}

{{product.name}}

diff --git a/src/storefront/templates/storefront/partials/_newsletter.html b/src/storefront/templates/storefront/partials/_newsletter.html index d82f757..bc4e462 100644 --- a/src/storefront/templates/storefront/partials/_newsletter.html +++ b/src/storefront/templates/storefront/partials/_newsletter.html @@ -15,9 +15,7 @@
-

- Subscribe to get 10% off your first order! -

+

Subscribe to get 10% off your first order!

@@ -30,9 +28,7 @@

- +
diff --git a/src/storefront/templates/storefront/product_detail.html b/src/storefront/templates/storefront/product_detail.html index ec5f583..2f956f2 100644 --- a/src/storefront/templates/storefront/product_detail.html +++ b/src/storefront/templates/storefront/product_detail.html @@ -13,7 +13,7 @@ {% endfor %}

{{product.name}}

diff --git a/src/storefront/templates/storefront/product_list.html b/src/storefront/templates/storefront/product_list.html index 1c87a82..bc374b3 100644 --- a/src/storefront/templates/storefront/product_list.html +++ b/src/storefront/templates/storefront/product_list.html @@ -1,4 +1,9 @@ {% extends 'base.html' %} +{% load static %} + +{% block head %} + +{% endblock %} {% block content %}
@@ -6,7 +11,7 @@ {% for product in product_list %}
- {{product.productphoto_set.first.image}} + {{product.get_first_img.image}}

{{ product.name }}

diff --git a/src/templates/base.html b/src/templates/base.html index 731db24..80aaa1d 100644 --- a/src/templates/base.html +++ b/src/templates/base.html @@ -28,7 +28,7 @@