add comment to orders

This commit is contained in:
Thomas Steen Rasmussen 2016-11-09 14:34:55 +01:00
parent 741ae97c91
commit a691a0d0b4
4 changed files with 33 additions and 1 deletions

View file

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.3 on 2016-11-09 11:46
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('shop', '0031_auto_20161109_1000'),
]
operations = [
migrations.AddField(
model_name='order',
name='customer_comment',
field=models.TextField(default=b'', help_text='If you have any comments about the order please enter them here.', verbose_name='Customer comment'),
),
]

View file

@ -117,6 +117,13 @@ class Order(CreatedUpdatedModel):
default=False,
)
customer_comment = models.TextField(
verbose_name=_('Customer comment'),
help_text=_('If you have any comments about the order please enter them here.'),
default='',
)
objects = OrderQuerySet.as_manager()
def __unicode__(self):

View file

@ -38,7 +38,6 @@
name="{{ order_product.id }}"
value="{{ order_product.quantity }}" />
{% bootstrap_button '<i class="glyphicon glyphicon-remove"></i>' button_type="submit" button_class="btn-danger" name="remove_product" value=order_product.pk %}
</form>
{% else %}
{{ order_product.quantity }}
{% endif %}
@ -65,6 +64,9 @@
</table>
<h3>Comment:</h3>
<input type="text" class="form-control" name="customer_comment" style="width: 100%;" placeholder="If you have any comments for this order please enter them here..." value="{{ order.customer_comment }}" {% if order.open == None %}readonly{% endif %}></p>
{% if not order.open == None %}
{% bootstrap_button "Update order" button_type="submit" button_class="btn-primary" name="update_order" %}
{% endif %}

View file

@ -299,6 +299,7 @@ class OrderDetailView(
# Set payment method and mark the order as closed
order.payment_method = payment_method
order.open = None
order.customer_comment = request.POST.get('customer_comment')
order.save()
reverses = {
@ -329,6 +330,8 @@ class OrderDetailView(
new_quantity = int(request.POST.get(order_product_id))
order_product.quantity = new_quantity
order_product.save()
order.customer_comment = request.POST.get('customer_comment')
order.save()
product_remove = request.POST.get('remove_product')
if product_remove: