Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Use more descriptive field name
akjanikf2d0bf9600f8
diff --git a/saleor/checkout/views/summary.py b/saleor/checkout/views/summary.pyindex 385ca44acc..8cf43a2810 100644--- a/saleor/checkout/views/summary.py+++ b/saleor/checkout/views/summary.py@@ -26,7 +26,7 @@ def create_order(checkout):checkout.cart.clear()user = None if checkout.user.is_anonymous else checkout.userorder.create_history_entry(- status=OrderStatus.OPEN, user=user, comment=pgettext_lazy(+ status=OrderStatus.OPEN, user=user, content=pgettext_lazy('Order status history entry', 'Order was placed'))order.send_confirmation_email()return order, redirect('order:payment', token=order.token)diff --git a/saleor/dashboard/order/views.py b/saleor/dashboard/order/views.pyindex 3f21e9da05..76ec594deb 100644--- a/saleor/dashboard/order/views.py+++ b/saleor/dashboard/order/views.py@@ -91,7 +91,7 @@ def order_add_note(request, order_pk):msg = pgettext_lazy('Dashboard message related to an order','Added note')- order.create_history_entry(comment=msg, user=request.user)+ order.create_history_entry(content=msg, user=request.user)messages.success(request, msg)if note.is_public:form.send_confirmation_email()@@ -116,7 +116,7 @@ def capture_payment(request, order_pk, payment_pk):msg = pgettext_lazy('Dashboard message related to a payment','Captured %(amount)s') % {'amount': gross(amount)}- payment.order.create_history_entry(comment=msg, user=request.user)+ payment.order.create_history_entry(content=msg, user=request.user)messages.success(request, msg)return redirect('dashboard:order-details', order_pk=order.pk)status = 400 if form.errors else 200@@ -139,7 +139,7 @@ def refund_payment(request, order_pk, payment_pk):msg = pgettext_lazy('Dashboard message related to a payment','Refunded %(amount)s') % {'amount': gross(amount)}- payment.order.create_history_entry(comment=msg, user=request.user)+ payment.order.create_history_entry(content=msg, user=request.user)messages.success(request, msg)return redirect('dashboard:order-details', order_pk=order.pk)status = 400 if form.errors else 200@@ -157,7 +157,7 @@ def release_payment(request, order_pk, payment_pk):form = ReleasePaymentForm(request.POST or None, payment=payment)if form.is_valid() and form.release():msg = pgettext_lazy('Dashboard message', 'Released payment')- payment.order.create_history_entry(comment=msg, user=request.user)+ payment.order.create_history_entry(content=msg, user=request.user)messages.success(request, msg)return redirect('dashboard:order-details', order_pk=order.pk)status = 400 if form.errors else 200@@ -184,7 +184,7 @@ def orderline_change_quantity(request, order_pk, line_pk):'product': line.product, 'old_quantity': old_quantity,'new_quantity': line.quantity}with transaction.atomic():- order.create_history_entry(comment=msg, user=request.user)+ order.create_history_entry(content=msg, user=request.user)form.save()messages.success(request, msg)return redirect('dashboard:order-details', order_pk=order.pk)@@ -221,7 +221,7 @@ def orderline_split(request, order_pk, line_pk):' to %(new_group)s') % {'how_many': how_many, 'item': line, 'old_group': old_group,'new_group': target_group}- order.create_history_entry(comment=msg, user=request.user)+ order.create_history_entry(content=msg, user=request.user)messages.success(request, msg)return redirect('dashboard:order-details', order_pk=order.pk)elif form.errors:@@ -244,7 +244,7 @@ def orderline_cancel(request, order_pk, line_pk):'Dashboard message related to an order line','Cancelled item %s') % linewith transaction.atomic():- order.create_history_entry(comment=msg, user=request.user)+ order.create_history_entry(content=msg, user=request.user)form.cancel_line()messages.success(request, msg)return redirect('dashboard:order-details', order_pk=order.pk)@@ -271,7 +271,7 @@ def ship_delivery_group(request, order_pk, group_pk):'Dashboard message related to a shipment group','Shipped %s') % groupmessages.success(request, msg)- group.order.create_history_entry(comment=msg, user=request.user)+ group.order.create_history_entry(content=msg, user=request.user)return redirect('dashboard:order-details', order_pk=order_pk)elif form.errors:status = 400@@ -294,7 +294,7 @@ def cancel_delivery_group(request, order_pk, group_pk):'Dashboard message related to a shipment group','Cancelled %s') % groupmessages.success(request, msg)- group.order.create_history_entry(comment=msg, user=request.user)+ group.order.create_history_entry(content=msg, user=request.user)return redirect('dashboard:order-details', order_pk=order_pk)elif form.errors:status = 400@@ -324,7 +324,7 @@ def add_variant_to_group(request, order_pk, group_pk):msg = pgettext_lazy('Dashboard message related to a shipment group','Added %(quantity)d x %(variant)s to %(group)s') % msg_dict- order.create_history_entry(comment=msg, user=request.user)+ order.create_history_entry(content=msg, user=request.user)messages.success(request, msg)except InsufficientStock:msg = pgettext_lazy(@@ -357,7 +357,7 @@ def address_view(request, order_pk, address_type):form = AddressForm(request.POST or None, instance=address)if form.is_valid():form.save()- order.create_history_entry(comment=success_msg, user=request.user)+ order.create_history_entry(content=success_msg, user=request.user)messages.success(request, success_msg)return redirect('dashboard:order-details', order_pk=order_pk)ctx = {'order': order, 'address_type': address_type, 'form': form}@@ -374,7 +374,7 @@ def cancel_order(request, order_pk):msg = pgettext_lazy('Dashboard message', 'Cancelled order')with transaction.atomic():form.cancel_order()- order.create_history_entry(comment=msg, user=request.user)+ order.create_history_entry(content=msg, user=request.user)messages.success(request, 'Order cancelled')return redirect('dashboard:order-details', order_pk=order.pk)# TODO: send status confirmation email@@ -395,7 +395,7 @@ def remove_order_voucher(request, order_pk):msg = pgettext_lazy('Dashboard message', 'Removed voucher from order')with transaction.atomic():form.remove_voucher()- order.create_history_entry(comment=msg, user=request.user)+ order.create_history_entry(content=msg, user=request.user)messages.success(request, msg)return redirect('dashboard:order-details', order_pk=order.pk)elif form.errors:diff --git a/saleor/order/migrations/0030_auto_20180116_0932.py b/saleor/order/migrations/0030_auto_20180116_0932.pydeleted file mode 100644index 1192ebaf94..0000000000--- a/saleor/order/migrations/0030_auto_20180116_0932.py+++ /dev/null@@ -1,20 +0,0 @@-# -*- coding: utf-8 -*--# Generated by Django 1.11.5 on 2018-01-16 15:32-from __future__ import unicode_literals--from django.db import migrations, models---class Migration(migrations.Migration):-- dependencies = [- ('order', '0029_auto_20180111_0845'),- ]-- operations = [- migrations.AlterField(- model_name='orderhistoryentry',- name='comment',- field=models.CharField(blank=True, default='', max_length=255),- ),- ]diff --git a/saleor/order/models.py b/saleor/order/models.pyindex 1d5669a520..9326565ee5 100644--- a/saleor/order/models.py+++ b/saleor/order/models.py@@ -146,10 +146,10 @@ class Order(models.Model, ItemSet):def is_pre_authorized(self):return self.payments.filter(status=PaymentStatus.PREAUTH).exists()- def create_history_entry(self, comment='', status=None, user=None):+ def create_history_entry(self, content='', status=None, user=None):if not status:status = self.status- self.history.create(status=status, comment=comment, user=user)+ self.history.create(status=status, content=content, user=user)def is_shipping_required(self):return any(group.is_shipping_required() for group in self.groups.all())@@ -348,7 +348,7 @@ class OrderHistoryEntry(models.Model):order = models.ForeignKey(Order, related_name='history', on_delete=models.CASCADE)status = models.CharField(max_length=32, choices=OrderStatus.CHOICES)- comment = models.CharField(max_length=255, default='', blank=True)+ content = models.TextField(default='', blank=True)user = models.ForeignKey(settings.AUTH_USER_MODEL, blank=True, null=True,on_delete=models.SET_NULL)@@ -369,7 +369,7 @@ class OrderNote(models.Model):date = models.DateTimeField(db_index=True, auto_now_add=True)order = models.ForeignKey(Order, related_name='notes', on_delete=models.CASCADE)- content = models.CharField(max_length=250)+ content = models.TextField()is_public = models.BooleanField(default=True)class Meta:diff --git a/saleor/order/signals.py b/saleor/order/signals.pyindex ae754d82e9..4a77e39a5f 100644--- a/saleor/order/signals.py+++ b/saleor/order/signals.py@@ -13,7 +13,7 @@ def order_status_change(sender, instance, **kwargs):order = instance.orderif order.is_fully_paid():order.create_history_entry(- status=order.status, comment=pgettext_lazy(+ status=order.status, content=pgettext_lazy('Order status history entry', 'Order fully paid'))instance.send_confirmation_email()try:diff --git a/saleor/order/utils.py b/saleor/order/utils.pyindex d377b30946..1efa80e41f 100644--- a/saleor/order/utils.py+++ b/saleor/order/utils.py@@ -152,7 +152,7 @@ def change_order_line_quantity(line, new_quantity):order = line.delivery_group.orderif not order.get_lines():order.create_history_entry(- status=order.status, comment=pgettext_lazy(+ status=order.status, content=pgettext_lazy('Order status history entry','Order cancelled. No items in order'))@@ -171,7 +171,7 @@ def remove_empty_groups(line, force=False):source_group.delete()if not order.get_lines():order.create_history_entry(- status=order.status, comment=pgettext_lazy(+ status=order.status, content=pgettext_lazy('Order status history entry','Order cancelled. No items in order'))diff --git a/tests/dashboard/test_order.py b/tests/dashboard/test_order.pyindex 4415af90af..f9304eeb8c 100644--- a/tests/dashboard/test_order.py+++ b/tests/dashboard/test_order.py@@ -49,7 +49,7 @@ def test_view_cancel_order_line(admin_client, order_with_lines_and_stock):assert Stock.objects.first().quantity_allocated == quantity_allocated_before - line_quantity# check note in the order's historyassert OrderHistoryEntry.objects.get(- order=order_with_lines_and_stock).comment == 'Cancelled item %s' % product+ order=order_with_lines_and_stock).content == 'Cancelled item %s' % producturl = reverse('dashboard:orderline-cancel', kwargs={'order_pk': order_with_lines_and_stock.pk,@@ -103,7 +103,7 @@ def test_view_change_order_line_quantity(admin_client, order_with_lines_and_stocassert order_with_lines_and_stock.groups.count() == 1# a note in the order's history should be createdassert OrderHistoryEntry.objects.get(- order=order_with_lines_and_stock).comment == (+ order=order_with_lines_and_stock).content == ('Changed quantity for product %(product)s from'' %(old_quantity)s to %(new_quantity)s') % {'product': line.product,@@ -223,7 +223,7 @@ def test_view_split_order_line(admin_client, order_with_lines_and_stock):# a note in the order's history should be creatednew_group = DeliveryGroup.objects.last()assert OrderHistoryEntry.objects.get(- order=order_with_lines_and_stock).comment == (+ order=order_with_lines_and_stock).content == ('Moved 2 items %(item)s from ''%(old_group)s to %(new_group)s') % {'item': line,@@ -240,7 +240,7 @@ def test_view_split_order_line(admin_client, order_with_lines_and_stock):url, {'quantity': 2, 'target_group': old_delivery_group.pk})# an other note in the order's history should be createdassert OrderHistoryEntry.objects.filter(- order=order_with_lines_and_stock).last().comment ==(+ order=order_with_lines_and_stock).last().content ==('Moved 2 items %(item)s from removed ''group to %(new_group)s') % {'item': line,@@ -284,7 +284,7 @@ def test_ordered_item_change_quantity(transactional_db, order_with_lines):history = list(order_with_lines.history.all())assert len(history) == 1assert history[0].status == OrderStatus.CLOSED- assert history[0].comment == 'Order cancelled. No items in order'+ assert history[0].content == 'Order cancelled. No items in order'def test_ordered_item_remove_empty_group_with_force(@@ -295,7 +295,7 @@ def test_ordered_item_remove_empty_group_with_force(history = list(order_with_lines.history.all())assert len(history) == 1assert history[0].status == OrderStatus.CLOSED- assert history[0].comment == 'Order cancelled. No items in order'+ assert history[0].content == 'Order cancelled. No items in order'@pytest.mark.integration