Merge branch 'release/2.0.14'
This commit is contained in:
commit
8d5f7fe6b9
@ -10,7 +10,7 @@
|
|||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{form.as_p}}
|
{{form.as_p}}
|
||||||
<p class="form__submit">
|
<p class="form__submit">
|
||||||
<input class="action-button" type="submit" value="Create category"> or <a href="{% url 'dashboard:category-detail' category.pk %}">cancel</a>
|
<input class="action-button" type="submit" value="Save changes"> or <a href="{% url 'dashboard:category-detail' category.pk %}">cancel</a>
|
||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@ -27,7 +27,7 @@
|
|||||||
<figcaption><strong>{{variant}}</strong></figcaption>
|
<figcaption><strong>{{variant}}</strong></figcaption>
|
||||||
</figure>
|
</figure>
|
||||||
<span>{{ variant.sku }}</span>
|
<span>{{ variant.sku }}</span>
|
||||||
<span>{{ variant.stock }}</span>
|
<span>{{ variant.stock|default_if_none:"0" }}</span>
|
||||||
<span>{{ variant.total_in_warehouse }}</span>
|
<span>{{ variant.total_in_warehouse }}</span>
|
||||||
<a href="{% url 'dashboard:variant-restock' product.pk variant.pk %}" class="action-button">Restock →</a>
|
<a href="{% url 'dashboard:variant-restock' product.pk variant.pk %}" class="action-button">Restock →</a>
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
|||||||
@ -10,7 +10,7 @@ from django.core.cache import cache
|
|||||||
from django.db.models import OuterRef, Q, Subquery
|
from django.db.models import OuterRef, Q, Subquery
|
||||||
|
|
||||||
from core.models import (
|
from core.models import (
|
||||||
Product, ProductVariant, OrderLine, Coupon, ShippingRate,
|
ProductCategory, Product, ProductVariant, OrderLine, Coupon, ShippingRate,
|
||||||
SiteSettings
|
SiteSettings
|
||||||
)
|
)
|
||||||
from core.usps import USPSApi
|
from core.usps import USPSApi
|
||||||
@ -60,11 +60,11 @@ class CartItem:
|
|||||||
|
|
||||||
class Cart:
|
class Cart:
|
||||||
item_class = CartItem
|
item_class = CartItem
|
||||||
# site_settings = SiteSettings.load()
|
|
||||||
|
|
||||||
def __init__(self, request):
|
def __init__(self, request):
|
||||||
self.request = request
|
self.request = request
|
||||||
self.session = request.session
|
self.session = request.session
|
||||||
|
self.site_settings = SiteSettings.load()
|
||||||
self.coupon_code = self.session.get('coupon_code')
|
self.coupon_code = self.session.get('coupon_code')
|
||||||
cart = self.session.get(settings.CART_SESSION_ID)
|
cart = self.session.get(settings.CART_SESSION_ID)
|
||||||
if not cart:
|
if not cart:
|
||||||
@ -129,6 +129,16 @@ class Cart:
|
|||||||
def __len__(self):
|
def __len__(self):
|
||||||
return sum([item['quantity'] for item in self.cart])
|
return sum([item['quantity'] for item in self.cart])
|
||||||
|
|
||||||
|
def get_item_prices_for_category(self, category):
|
||||||
|
for item in self:
|
||||||
|
if item['variant'].product.category == category:
|
||||||
|
yield item['price_total']
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
|
||||||
|
def get_total_price_for_category(self, category):
|
||||||
|
return sum(self.get_item_prices_for_category(category))
|
||||||
|
|
||||||
def get_all_item_quantities(self):
|
def get_all_item_quantities(self):
|
||||||
for item in self.cart:
|
for item in self.cart:
|
||||||
yield item['quantity']
|
yield item['quantity']
|
||||||
@ -139,8 +149,6 @@ class Cart:
|
|||||||
def get_item_prices(self):
|
def get_item_prices(self):
|
||||||
for item in self:
|
for item in self:
|
||||||
yield item['price_total']
|
yield item['price_total']
|
||||||
# for item in self.cart.values():
|
|
||||||
# yield Decimal(item['price']) * sum([value['quantity'] for value in item['variations'].values()])
|
|
||||||
|
|
||||||
def get_total_price(self):
|
def get_total_price(self):
|
||||||
return sum(self.get_item_prices())
|
return sum(self.get_item_prices())
|
||||||
@ -170,9 +178,11 @@ class Cart:
|
|||||||
return containers
|
return containers
|
||||||
|
|
||||||
def get_shipping_cost(self, container=None):
|
def get_shipping_cost(self, container=None):
|
||||||
# free_shipping_min = self.site_settings.free_shipping_min
|
free_shipping_min = self.site_settings.free_shipping_min
|
||||||
# if self.get_total_price() >= free_shipping_min:
|
if free_shipping_min is not None:
|
||||||
# return Decimal('0.00')
|
category = ProductCategory.objects.get(name='Coffee')
|
||||||
|
if self.get_total_price_for_category(category) >= free_shipping_min:
|
||||||
|
return Decimal('0.00')
|
||||||
|
|
||||||
if container is None:
|
if container is None:
|
||||||
container = self.session.get('shipping_container').container
|
container = self.session.get('shipping_container').container
|
||||||
|
|||||||
@ -58,7 +58,10 @@
|
|||||||
<input type="submit" value="Apply" class="action-button">
|
<input type="submit" value="Apply" class="action-button">
|
||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
<!-- <h5>Free shipping on orders over ${{ site_settings.free_shipping_min|floatformat:"2" }}</h5> -->
|
<h5>
|
||||||
|
Free shipping on coffee orders over ${{ site_settings.free_shipping_min|floatformat:"2" }}<br>
|
||||||
|
<small><em>Merch does not count toward total</em></small>
|
||||||
|
</h5>
|
||||||
<div class="cart__table-wrapper">
|
<div class="cart__table-wrapper">
|
||||||
<table class="cart__totals">
|
<table class="cart__totals">
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@ -65,6 +65,10 @@
|
|||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{form.as_p}}
|
{{form.as_p}}
|
||||||
</form>
|
</form>
|
||||||
|
<h5>
|
||||||
|
Free shipping on coffee orders over ${{ site_settings.free_shipping_min|floatformat:"2" }}<br>
|
||||||
|
<small><em>Merchandise does not count toward total</em></small>
|
||||||
|
</h5>
|
||||||
<div class="cart__table-wrapper">
|
<div class="cart__table-wrapper">
|
||||||
<table class="cart__totals">
|
<table class="cart__totals">
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@ -20,12 +20,12 @@ class RequestFaker:
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
'items': [{
|
'items': [{
|
||||||
'name': 'Decaf: 16 oz',
|
'name': 'Decaf: 16 oz Grind: Whole Beans',
|
||||||
'description': 'Medium Roast',
|
'description': 'Medium Roast',
|
||||||
'unit_amount': {'currency_code': 'USD', 'value': '13.40'},
|
'unit_amount': {'currency_code': 'USD', 'value': '13.40'},
|
||||||
'quantity': '1'
|
'quantity': '1'
|
||||||
}, {
|
}, {
|
||||||
'name': 'Decaf: 16 oz',
|
'name': 'Decaf: 16 oz Grind: Percolator',
|
||||||
'description': 'Medium Roast',
|
'description': 'Medium Roast',
|
||||||
'unit_amount': {'currency_code': 'USD', 'value': '13.40'},
|
'unit_amount': {'currency_code': 'USD', 'value': '13.40'},
|
||||||
'quantity': '2'
|
'quantity': '2'
|
||||||
|
|||||||
@ -36,7 +36,7 @@ class CreateOrderTest(TestCase):
|
|||||||
name='16 oz',
|
name='16 oz',
|
||||||
sku='234987',
|
sku='234987',
|
||||||
price=13.4,
|
price=13.4,
|
||||||
weight=Weight(oz=16),
|
weight=Weight(oz=16)
|
||||||
)
|
)
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|||||||
@ -5,7 +5,6 @@ urlpatterns = [
|
|||||||
path('about/', views.AboutView.as_view(), name='about'),
|
path('about/', views.AboutView.as_view(), name='about'),
|
||||||
path('fair-trade/', views.FairTradeView.as_view(), name='fair-trade'),
|
path('fair-trade/', views.FairTradeView.as_view(), name='fair-trade'),
|
||||||
path('reviews/', views.ReviewListView.as_view(), name='reviews'),
|
path('reviews/', views.ReviewListView.as_view(), name='reviews'),
|
||||||
path('contact/', views.ContactFormView.as_view(), name='contact'),
|
|
||||||
path(
|
path(
|
||||||
'subscriptions/',
|
'subscriptions/',
|
||||||
views.SubscriptionCreateView.as_view(),
|
views.SubscriptionCreateView.as_view(),
|
||||||
|
|||||||
@ -558,17 +558,6 @@ class ReviewListView(TemplateView):
|
|||||||
template_name = 'storefront/reviews.html'
|
template_name = 'storefront/reviews.html'
|
||||||
|
|
||||||
|
|
||||||
class ContactFormView(FormView, SuccessMessageMixin):
|
|
||||||
template_name = 'storefront/contact_form.html'
|
|
||||||
form_class = ContactForm
|
|
||||||
success_url = reverse_lazy('storefront:product-list')
|
|
||||||
success_message = 'Message sent.'
|
|
||||||
|
|
||||||
def form_valid(self, form):
|
|
||||||
form.send_email()
|
|
||||||
return super().form_valid(form)
|
|
||||||
|
|
||||||
|
|
||||||
class SubscriptionCreateView(FormView):
|
class SubscriptionCreateView(FormView):
|
||||||
template_name = 'storefront/subscriptions.html'
|
template_name = 'storefront/subscriptions.html'
|
||||||
form_class = SubscriptionCreateForm
|
form_class = SubscriptionCreateForm
|
||||||
|
|||||||
@ -46,14 +46,9 @@
|
|||||||
<nav class="site__nav">
|
<nav class="site__nav">
|
||||||
<a class="site__logo" href="{% url 'storefront:product-list' %}"><img src="{% static 'images/site_logo.svg' %}" alt="Port Townsend Roasting Co."></a>
|
<a class="site__logo" href="{% url 'storefront:product-list' %}"><img src="{% static 'images/site_logo.svg' %}" alt="Port Townsend Roasting Co."></a>
|
||||||
<ul class="nav__list nav__main">
|
<ul class="nav__list nav__main">
|
||||||
<li class="nav__menu">
|
{% for category in category_list %}
|
||||||
<a class="nav__link" href="{% url 'storefront:product-list' %}">Shop ▼</a>
|
<li><a class="nav__link" href="{% url 'storefront:category-detail' category.pk %}">{{ category }}</a></li>
|
||||||
<ul class="nav__dropdown">
|
{% endfor %}
|
||||||
{% for category in category_list %}
|
|
||||||
<li><a class="nav__link" href="{% url 'storefront:category-detail' category.pk %}">{{ category }}</a></li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
<!-- <li><a class="nav__link" href="{% url 'storefront:subscriptions' %}">Subscriptions</a></li> -->
|
<!-- <li><a class="nav__link" href="{% url 'storefront:subscriptions' %}">Subscriptions</a></li> -->
|
||||||
<li><a class="nav__link" href="{% url 'storefront:fair-trade' %}">Fair trade</a></li>
|
<li><a class="nav__link" href="{% url 'storefront:fair-trade' %}">Fair trade</a></li>
|
||||||
<li><a class="nav__link" href="{% url 'storefront:reviews' %}">Reviews</a></li>
|
<li><a class="nav__link" href="{% url 'storefront:reviews' %}">Reviews</a></li>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user