Finish address template changes
This commit is contained in:
parent
cf4a1e5ec7
commit
e75f1dc1bc
@ -27,18 +27,32 @@ class AccountUpdateForm(UserChangeForm):
|
||||
|
||||
|
||||
class CustomerUpdateForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = User
|
||||
fields = (
|
||||
'email',
|
||||
)
|
||||
|
||||
|
||||
class CustomerShippingAddressUpdateForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = User
|
||||
fields = (
|
||||
'first_name',
|
||||
'last_name',
|
||||
'email',
|
||||
'shipping_street_address_1',
|
||||
'shipping_street_address_2',
|
||||
'shipping_city',
|
||||
'shipping_state',
|
||||
'shipping_postal_code',
|
||||
)
|
||||
labels = {
|
||||
'shipping_street_address_1': 'Street line 1',
|
||||
'shipping_street_address_2': 'Street line 2',
|
||||
'shipping_city': 'City',
|
||||
'shipping_state': 'State',
|
||||
'shipping_postal_code': 'ZIP code',
|
||||
}
|
||||
|
||||
|
||||
class UserSignupForm(SignupForm):
|
||||
|
||||
@ -19,14 +19,14 @@
|
||||
<h4>Details</h4>
|
||||
</header>
|
||||
<dl class="panel-datalist">
|
||||
<dt>Primary email address</dt>
|
||||
<dt>Email address</dt>
|
||||
<dd>
|
||||
<a href="mailto:{{ customer.email }}">{{ customer.email }} ↗</a>
|
||||
</dd>
|
||||
|
||||
<dt>Default shipping address</dt>
|
||||
<dt>Shipping address</dt>
|
||||
<dd>
|
||||
{% include 'dashboard/partials/_address.html' with address=customer %}
|
||||
{% include 'dashboard/partials/_address.html' with full_name=customer.get_full_name address=customer %}
|
||||
</dd>
|
||||
</dl>
|
||||
</section>
|
||||
|
||||
@ -133,7 +133,7 @@
|
||||
<div class="panel-section panel-shipping">
|
||||
<div>
|
||||
<strong>Shipping address</strong>
|
||||
{% include 'dashboard/partials/_address.html' with address=order %}
|
||||
{% include 'dashboard/partials/_address.html' with full_name=order.customer.get_full_name address=order %}
|
||||
</div>
|
||||
<table>
|
||||
<thead>
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
</header>
|
||||
<div class="panel-section">
|
||||
<strong>Shipping address</strong>
|
||||
{% include 'dashboard/partials/_address.html' with address=order %}
|
||||
{% include 'dashboard/partials/_address.html' with full_name=order.customer.get_full_name address=order %}
|
||||
</div>
|
||||
<form method="POST">
|
||||
{% csrf_token %}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<address>
|
||||
{{ full_name }}<br>
|
||||
{{ address.shipping_street_address_1 }}<br>
|
||||
{% if address.shipping_street_address_2 %}
|
||||
{{ address.shipping_street_address_2 }}<br>
|
||||
|
||||
@ -126,6 +126,21 @@ table a {
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.form-table {
|
||||
width: unset;
|
||||
border: none;
|
||||
}
|
||||
.form-table th,
|
||||
.form-table td {
|
||||
border: none;
|
||||
}
|
||||
.form-table th {
|
||||
padding: 0 1rem 1rem 0;
|
||||
}
|
||||
.form-table td {
|
||||
padding: 0 0 1rem 0;
|
||||
}
|
||||
|
||||
|
||||
/* ==========================================================================
|
||||
Forms
|
||||
|
||||
@ -255,7 +255,7 @@ class Cart:
|
||||
if container is None:
|
||||
container = self.get_shipping_container()
|
||||
|
||||
if not self.total_weight > Weight(lb=0):
|
||||
if self.total_weight <= Weight(lb=0):
|
||||
return Decimal('0.00')
|
||||
|
||||
if len(self) > 0 and self.session.get('shipping_address'):
|
||||
@ -286,11 +286,11 @@ class Cart:
|
||||
)
|
||||
|
||||
if usps_rate_request['service'] == ShippingContainer.PRIORITY:
|
||||
shipping_cost = Decimal(postage['Rate'])
|
||||
shipping_price = Decimal(postage['Rate'])
|
||||
elif usps_rate_request['service'] == ShippingContainer.PRIORITY_COMMERCIAL:
|
||||
shipping_cost = Decimal(postage['CommercialRate'])
|
||||
shipping_price = Decimal(postage['CommercialRate'])
|
||||
|
||||
return shipping_cost
|
||||
return shipping_price
|
||||
else:
|
||||
raise ShippingAddressError(
|
||||
'Could not retrieve shipping address.'
|
||||
|
||||
@ -5,21 +5,20 @@
|
||||
|
||||
{% block content %}
|
||||
<article>
|
||||
<header class="article__header--with-action">
|
||||
<h1>{{customer.get_full_name}}</h1>
|
||||
<a href="{% url 'storefront:customer-update' customer.pk %}" class="btn">Edit profile</a>
|
||||
</header>
|
||||
<section>
|
||||
<h4>Info</h4>
|
||||
<h2>My Account</h2>
|
||||
<p>
|
||||
<a href="{% url 'account_change_password' %}">Change password</a>
|
||||
</p>
|
||||
<div class="customer__detail-section">
|
||||
<div>
|
||||
<strong>Email address</strong><br>
|
||||
{{customer.email}}<br>
|
||||
<a href="{% url 'account_email' %}">Manage</a>
|
||||
<strong>Email address</strong> <a href="{% url 'storefront:customer-update' customer.pk %}">Change</a><br>
|
||||
{{customer.email}}
|
||||
</div>
|
||||
<div>
|
||||
<strong>Shipping address</strong>
|
||||
<strong>Shipping address</strong> <a href="{% url 'storefront:customer-shipping-address-update' customer.pk %}">Change</a>
|
||||
<address>
|
||||
{{ customer.get_full_name }}<br>
|
||||
{{customer.shipping_street_address_1}}<br>
|
||||
{% if shipping_street_address_2 %}
|
||||
{{customer.shipping_street_address_2}}<br>
|
||||
@ -31,7 +30,7 @@
|
||||
</section>
|
||||
{% if customer.subscriptions.count > 0 %}
|
||||
<section>
|
||||
<h3>Your subscriptions</h3>
|
||||
<h3>My subscriptions</h3>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
@ -53,7 +52,7 @@
|
||||
</section>
|
||||
{% endif %}
|
||||
<section>
|
||||
<h3>Your orders</h3>
|
||||
<h3>My orders</h3>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
@ -5,17 +5,22 @@
|
||||
<header>
|
||||
<p><a href="{% url 'storefront:customer-detail' customer.pk %}">← Back</a></p>
|
||||
<h1>Update your profile</h1>
|
||||
<p>
|
||||
<a href="{% url 'account_change_password' %}">Change password</a>
|
||||
</p>
|
||||
</header>
|
||||
<section>
|
||||
<form method="POST" action="{% url 'storefront:customer-update' customer.pk %}">
|
||||
{% csrf_token %}
|
||||
{{form.as_p}}
|
||||
<p>
|
||||
<input type="submit" value="Save changes">
|
||||
</p>
|
||||
<table class="form-table">
|
||||
{{form.as_table}}
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
<button type="submit">Save changes</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</form>
|
||||
</section>
|
||||
</article>
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<article>
|
||||
<header>
|
||||
<p><a href="{% url 'storefront:customer-detail' customer.pk %}">← Back</a></p>
|
||||
<h1>Update your shipping address</h1>
|
||||
</header>
|
||||
<section>
|
||||
<form method="POST">
|
||||
{% csrf_token %}
|
||||
<table class="form-table">
|
||||
{{form.as_table}}
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
<button type="submit">Save changes</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</form>
|
||||
</section>
|
||||
</article>
|
||||
{% endblock %}
|
||||
@ -89,6 +89,11 @@ urlpatterns = [
|
||||
views.CustomerUpdateView.as_view(),
|
||||
name='customer-update',
|
||||
),
|
||||
path(
|
||||
'shipping-address/update/',
|
||||
views.CustomerShippingAddressUpdateView.as_view(),
|
||||
name='customer-shipping-address-update',
|
||||
),
|
||||
path(
|
||||
'orders/<int:order_pk>/',
|
||||
views.OrderDetailView.as_view(),
|
||||
|
||||
@ -36,7 +36,7 @@ from moneyed import Money, USD
|
||||
|
||||
from accounts.models import User
|
||||
from accounts.utils import get_or_create_customer
|
||||
from accounts.forms import CustomerUpdateForm
|
||||
from accounts.forms import CustomerUpdateForm, CustomerShippingAddressUpdateForm
|
||||
from core.models import (
|
||||
ProductCategory, Product, ProductVariant, ProductOption,
|
||||
Order, Transaction, OrderLine, Coupon, ShippingRate,
|
||||
@ -557,6 +557,24 @@ class CustomerUpdateView(UserPassesTestMixin, LoginRequiredMixin, UpdateView):
|
||||
)
|
||||
|
||||
|
||||
class CustomerShippingAddressUpdateView(UserPassesTestMixin, LoginRequiredMixin, UpdateView):
|
||||
model = User
|
||||
template_name = 'storefront/customer_shipping_address_form.html'
|
||||
context_object_name = 'customer'
|
||||
form_class = CustomerShippingAddressUpdateForm
|
||||
permission_denied_message = 'Not authorized.'
|
||||
raise_exception = True
|
||||
|
||||
def test_func(self):
|
||||
return self.request.user.pk == self.get_object().pk
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse(
|
||||
'storefront:customer-detail', kwargs={'pk': self.object.pk}
|
||||
)
|
||||
|
||||
|
||||
|
||||
class OrderDetailView(UserPassesTestMixin, LoginRequiredMixin, DetailView):
|
||||
model = Order
|
||||
template_name = 'storefront/order_detail.html'
|
||||
|
||||
@ -14,8 +14,20 @@
|
||||
|
||||
<form method="POST" action="{% url 'account_change_password' %}" class="password_change">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<input type="submit" value="{% trans "Save changes" %}">
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
{{ form.as_table }}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
<button type="submit">Save changes</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</form>
|
||||
</article>
|
||||
{% endblock %}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user