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 CustomerUpdateForm(forms.ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = User
|
||||||
|
fields = (
|
||||||
|
'email',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class CustomerShippingAddressUpdateForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = User
|
model = User
|
||||||
fields = (
|
fields = (
|
||||||
'first_name',
|
'first_name',
|
||||||
'last_name',
|
'last_name',
|
||||||
'email',
|
|
||||||
'shipping_street_address_1',
|
'shipping_street_address_1',
|
||||||
'shipping_street_address_2',
|
'shipping_street_address_2',
|
||||||
'shipping_city',
|
'shipping_city',
|
||||||
'shipping_state',
|
'shipping_state',
|
||||||
'shipping_postal_code',
|
'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):
|
class UserSignupForm(SignupForm):
|
||||||
|
|||||||
@ -19,14 +19,14 @@
|
|||||||
<h4>Details</h4>
|
<h4>Details</h4>
|
||||||
</header>
|
</header>
|
||||||
<dl class="panel-datalist">
|
<dl class="panel-datalist">
|
||||||
<dt>Primary email address</dt>
|
<dt>Email address</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<a href="mailto:{{ customer.email }}">{{ customer.email }} ↗</a>
|
<a href="mailto:{{ customer.email }}">{{ customer.email }} ↗</a>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
<dt>Default shipping address</dt>
|
<dt>Shipping address</dt>
|
||||||
<dd>
|
<dd>
|
||||||
{% include 'dashboard/partials/_address.html' with address=customer %}
|
{% include 'dashboard/partials/_address.html' with full_name=customer.get_full_name address=customer %}
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@ -133,7 +133,7 @@
|
|||||||
<div class="panel-section panel-shipping">
|
<div class="panel-section panel-shipping">
|
||||||
<div>
|
<div>
|
||||||
<strong>Shipping address</strong>
|
<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>
|
</div>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
</header>
|
</header>
|
||||||
<div class="panel-section">
|
<div class="panel-section">
|
||||||
<strong>Shipping address</strong>
|
<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>
|
</div>
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
<address>
|
<address>
|
||||||
{{address.shipping_street_address_1}}<br>
|
{{ full_name }}<br>
|
||||||
|
{{ address.shipping_street_address_1 }}<br>
|
||||||
{% if address.shipping_street_address_2 %}
|
{% if address.shipping_street_address_2 %}
|
||||||
{{address.shipping_street_address_2}}<br>
|
{{ address.shipping_street_address_2 }}<br>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{address.shipping_city}}, {{address.shipping_state}}, {{address.shipping_postal_code}}
|
{{ address.shipping_city }}, {{ address.shipping_state }}, {{ address.shipping_postal_code }}
|
||||||
</address>
|
</address>
|
||||||
|
|||||||
@ -126,6 +126,21 @@ table a {
|
|||||||
white-space: normal;
|
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
|
Forms
|
||||||
|
|||||||
@ -255,7 +255,7 @@ class Cart:
|
|||||||
if container is None:
|
if container is None:
|
||||||
container = self.get_shipping_container()
|
container = self.get_shipping_container()
|
||||||
|
|
||||||
if not self.total_weight > Weight(lb=0):
|
if self.total_weight <= Weight(lb=0):
|
||||||
return Decimal('0.00')
|
return Decimal('0.00')
|
||||||
|
|
||||||
if len(self) > 0 and self.session.get('shipping_address'):
|
if len(self) > 0 and self.session.get('shipping_address'):
|
||||||
@ -286,11 +286,11 @@ class Cart:
|
|||||||
)
|
)
|
||||||
|
|
||||||
if usps_rate_request['service'] == ShippingContainer.PRIORITY:
|
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:
|
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:
|
else:
|
||||||
raise ShippingAddressError(
|
raise ShippingAddressError(
|
||||||
'Could not retrieve shipping address.'
|
'Could not retrieve shipping address.'
|
||||||
|
|||||||
@ -5,21 +5,20 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<article>
|
<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>
|
<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 class="customer__detail-section">
|
||||||
<div>
|
<div>
|
||||||
<strong>Email address</strong><br>
|
<strong>Email address</strong> <a href="{% url 'storefront:customer-update' customer.pk %}">Change</a><br>
|
||||||
{{customer.email}}<br>
|
{{customer.email}}
|
||||||
<a href="{% url 'account_email' %}">Manage</a>
|
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<strong>Shipping address</strong>
|
<strong>Shipping address</strong> <a href="{% url 'storefront:customer-shipping-address-update' customer.pk %}">Change</a>
|
||||||
<address>
|
<address>
|
||||||
|
{{ customer.get_full_name }}<br>
|
||||||
{{customer.shipping_street_address_1}}<br>
|
{{customer.shipping_street_address_1}}<br>
|
||||||
{% if shipping_street_address_2 %}
|
{% if shipping_street_address_2 %}
|
||||||
{{customer.shipping_street_address_2}}<br>
|
{{customer.shipping_street_address_2}}<br>
|
||||||
@ -31,7 +30,7 @@
|
|||||||
</section>
|
</section>
|
||||||
{% if customer.subscriptions.count > 0 %}
|
{% if customer.subscriptions.count > 0 %}
|
||||||
<section>
|
<section>
|
||||||
<h3>Your subscriptions</h3>
|
<h3>My subscriptions</h3>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -53,7 +52,7 @@
|
|||||||
</section>
|
</section>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<section>
|
<section>
|
||||||
<h3>Your orders</h3>
|
<h3>My orders</h3>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@ -5,17 +5,22 @@
|
|||||||
<header>
|
<header>
|
||||||
<p><a href="{% url 'storefront:customer-detail' customer.pk %}">← Back</a></p>
|
<p><a href="{% url 'storefront:customer-detail' customer.pk %}">← Back</a></p>
|
||||||
<h1>Update your profile</h1>
|
<h1>Update your profile</h1>
|
||||||
<p>
|
|
||||||
<a href="{% url 'account_change_password' %}">Change password</a>
|
|
||||||
</p>
|
|
||||||
</header>
|
</header>
|
||||||
<section>
|
<section>
|
||||||
<form method="POST" action="{% url 'storefront:customer-update' customer.pk %}">
|
<form method="POST" action="{% url 'storefront:customer-update' customer.pk %}">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{form.as_p}}
|
<table class="form-table">
|
||||||
<p>
|
{{form.as_table}}
|
||||||
<input type="submit" value="Save changes">
|
<tfoot>
|
||||||
</p>
|
<tr>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<button type="submit">Save changes</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
</article>
|
</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(),
|
views.CustomerUpdateView.as_view(),
|
||||||
name='customer-update',
|
name='customer-update',
|
||||||
),
|
),
|
||||||
|
path(
|
||||||
|
'shipping-address/update/',
|
||||||
|
views.CustomerShippingAddressUpdateView.as_view(),
|
||||||
|
name='customer-shipping-address-update',
|
||||||
|
),
|
||||||
path(
|
path(
|
||||||
'orders/<int:order_pk>/',
|
'orders/<int:order_pk>/',
|
||||||
views.OrderDetailView.as_view(),
|
views.OrderDetailView.as_view(),
|
||||||
|
|||||||
@ -36,7 +36,7 @@ from moneyed import Money, USD
|
|||||||
|
|
||||||
from accounts.models import User
|
from accounts.models import User
|
||||||
from accounts.utils import get_or_create_customer
|
from accounts.utils import get_or_create_customer
|
||||||
from accounts.forms import CustomerUpdateForm
|
from accounts.forms import CustomerUpdateForm, CustomerShippingAddressUpdateForm
|
||||||
from core.models import (
|
from core.models import (
|
||||||
ProductCategory, Product, ProductVariant, ProductOption,
|
ProductCategory, Product, ProductVariant, ProductOption,
|
||||||
Order, Transaction, OrderLine, Coupon, ShippingRate,
|
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):
|
class OrderDetailView(UserPassesTestMixin, LoginRequiredMixin, DetailView):
|
||||||
model = Order
|
model = Order
|
||||||
template_name = 'storefront/order_detail.html'
|
template_name = 'storefront/order_detail.html'
|
||||||
|
|||||||
@ -14,8 +14,20 @@
|
|||||||
|
|
||||||
<form method="POST" action="{% url 'account_change_password' %}" class="password_change">
|
<form method="POST" action="{% url 'account_change_password' %}" class="password_change">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form.as_p }}
|
<table class="form-table">
|
||||||
<input type="submit" value="{% trans "Save changes" %}">
|
<tbody>
|
||||||
|
{{ form.as_table }}
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<button type="submit">Save changes</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
</form>
|
</form>
|
||||||
</article>
|
</article>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user