finish work on custom invoice address

This commit is contained in:
Thomas Steen Rasmussen 2018-08-27 11:52:42 +02:00
parent 80e9c01f87
commit f396708156
5 changed files with 41 additions and 10 deletions

View file

@ -0,0 +1,22 @@
# Generated by Django 2.0.4 on 2018-08-27 08:20
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('shop', '0055_order_customer_address'),
]
operations = [
migrations.RemoveField(
model_name='order',
name='customer_address',
),
migrations.AddField(
model_name='order',
name='invoice_address',
field=models.TextField(blank=True, help_text='The invoice address for this order. Leave blank to use the email associated with the logged in user.'),
),
]

View file

@ -87,12 +87,6 @@ class Order(CreatedUpdatedModel):
default=True,
)
customer_address = models.TextField(
help_text=_('The additional customer address for this order'),
blank=True
)
CREDIT_CARD = 'credit_card'
BLOCKCHAIN = 'blockchain'
BANK_TRANSFER = 'bank_transfer'
@ -134,6 +128,11 @@ class Order(CreatedUpdatedModel):
blank=True,
)
invoice_address = models.TextField(
help_text=_('The invoice address for this order. Leave blank to use the email associated with the logged in user.'),
blank=True
)
objects = OrderQuerySet.as_manager()
def __str__(self):

View file

@ -68,9 +68,17 @@
{% if not order.open == None %}
<h4>Comment:</h4>
<input type="text" class="form-control" name="customer_comment" style="width: 100%;" placeholder="Please enter any comments or shipping address here..." value="{{ order.customer_comment }}"></p>
<textarea class="form-control" name="customer_comment" style="width: 100%;" placeholder="Please enter any comments or shipping address here...">{{ order.customer_comment }}</textarea></p>
{% elif order.open == None and order.comment %}
<div class="alert alert-info">{{ order.comment }}</div>
<div class="alert alert-info">{{ order.comment|linebreaks }}</div>
{% endif %}
{% if not order.open == None %}
<h4>Invoice Address:</h4>
<textarea class="form-control" name="invoice_address" style="width: 100%;" placeholder="Please enter the invoice address. Leave blank to use the email associated with the logged in user.">{{ order.invoice_address }}</textarea></p>
{% elif order.open == None and order.invoice_address %}
<h4>Invoice Address:</h4>
<div class="alert alert-info">{{ order.invoice_address|linebreaks }}</div>
{% endif %}
{% if order.open %}

View file

@ -14,9 +14,9 @@
</td>
</tr>
</table>
{% if invoice.order.customer_address %}
{% if invoice.order.invoice_address %}
<h2>CUSTOMER</h2>
<p class="lead">{{ invoice.order.customer_address|linebreaks }}</p>
<p class="lead">{{ invoice.order.invoice_address|linebreaks }}</p>
{% else %}
<h3>Customer: {{ invoice.order.user.email }}</h3>
{% endif %}

View file

@ -306,6 +306,7 @@ class OrderDetailView(LoginRequiredMixin, EnsureUserOwnsOrderMixin, EnsureOrderH
order.payment_method = payment_method
order.open = None
order.customer_comment = request.POST.get('customer_comment') or ''
order.invoice_address = request.POST.get('invoice_address') or ''
order.save()
reverses = {
@ -337,6 +338,7 @@ class OrderDetailView(LoginRequiredMixin, EnsureUserOwnsOrderMixin, EnsureOrderH
order_product.quantity = new_quantity
order_product.save()
order.customer_comment = request.POST.get('customer_comment') or ''
order.invoice_address = request.POST.get('invoice_address') or ''
order.save()
product_remove = request.POST.get('remove_product')