diff --git a/src/pretix/base/migrations/0026_order_comment.py b/src/pretix/base/migrations/0026_order_comment.py new file mode 100644 index 0000000000..b0c45621ce --- /dev/null +++ b/src/pretix/base/migrations/0026_order_comment.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.8 on 2016-08-12 08:21 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('pretixbase', '0025_auto_20160802_2202'), + ] + + operations = [ + migrations.AddField( + model_name='order', + name='comment', + field=models.TextField(blank=True, help_text='The text entered in this field will not be visible to the user and is available for your convenience.', verbose_name='Comment'), + ), + ] diff --git a/src/pretix/base/models/orders.py b/src/pretix/base/models/orders.py index ec32f40e53..2bdf11d8b4 100644 --- a/src/pretix/base/models/orders.py +++ b/src/pretix/base/models/orders.py @@ -74,6 +74,8 @@ class Order(LoggedModel): :type payment_info: str :param total: The total amount of the order, including the payment fee :type total: decimal.Decimal + :param comment: An internal comment that will only be visible to staff, and never displayed to the user + :type comment: str """ STATUS_PENDING = "n" @@ -153,6 +155,11 @@ class Order(LoggedModel): decimal_places=2, max_digits=10, verbose_name=_("Total amount") ) + comment = models.TextField( + blank=True, verbose_name=_("Comment"), + help_text=_("The text entered in this field will not be visible to the user and is available for your " + "convenience.") + ) class Meta: verbose_name = _("Order") diff --git a/src/pretix/base/models/vouchers.py b/src/pretix/base/models/vouchers.py index ca9ce70307..0920718d56 100644 --- a/src/pretix/base/models/vouchers.py +++ b/src/pretix/base/models/vouchers.py @@ -43,6 +43,8 @@ class Voucher(LoggedModel): :type variation: ItemVariation :param quota: If set, the quota to choose an item from :type quota: Quota + :param comment: An internal comment that will only be visible to staff, and never displayed to the user + :type comment: str Various constraints apply: diff --git a/src/pretix/control/forms/orders.py b/src/pretix/control/forms/orders.py index 2b860b55e8..e6e0077c94 100644 --- a/src/pretix/control/forms/orders.py +++ b/src/pretix/control/forms/orders.py @@ -23,3 +23,15 @@ class ExporterForm(forms.Form): data[k] = [m.pk for m in v] return data + + +class CommentForm(I18nModelForm): + class Meta: + model = Order + fields = ['comment'] + widgets = { + 'comment': forms.Textarea(attrs={ + 'rows': 3, + 'class': 'helper-width-100', + }), + } diff --git a/src/pretix/control/logdisplay.py b/src/pretix/control/logdisplay.py index 2addfca5dd..9513929d16 100644 --- a/src/pretix/control/logdisplay.py +++ b/src/pretix/control/logdisplay.py @@ -19,6 +19,7 @@ def pretixcontrol_logentry_display(sender, logentry, **kwargs): 'pretix.event.order.invoice.generated': _('The invoice has been generated.'), 'pretix.event.order.invoice.regenerated': _('The invoice has been regenerated.'), 'pretix.event.order.invoice.reissued': _('The invoice has been reissued.'), + 'pretix.event.order.comment': _('The order\'s internal comment has been updated.'), } if logentry.action_type in plains: return plains[logentry.action_type] diff --git a/src/pretix/control/templates/pretixcontrol/order/index.html b/src/pretix/control/templates/pretixcontrol/order/index.html index 1016cdfa44..1e20a2eed4 100644 --- a/src/pretix/control/templates/pretixcontrol/order/index.html +++ b/src/pretix/control/templates/pretixcontrol/order/index.html @@ -1,5 +1,6 @@ {% extends "pretixcontrol/event/base.html" %} {% load i18n %} +{% load bootstrap3 %} {% load eventurl %} {% block title %} {% blocktrans trimmed with code=order.code %} @@ -279,6 +280,25 @@ {% endif %} +
+
+

+ {% trans "Internal comment" %} +

+
+
+
+ {% csrf_token %} +
+ {% bootstrap_field comment_form.comment layout="horizontal" show_help=True show_label=False horizontal_field_class="col-md-12" %} +
+ +
+
+
diff --git a/src/pretix/control/urls.py b/src/pretix/control/urls.py index a7a1236707..410cc36478 100644 --- a/src/pretix/control/urls.py +++ b/src/pretix/control/urls.py @@ -77,6 +77,8 @@ urlpatterns = [ name='event.order.reissueinvoice'), url(r'^orders/(?P[0-9A-Z]+)/extend$', orders.OrderExtend.as_view(), name='event.order.extend'), + url(r'^orders/(?P[0-9A-Z]+)/comment$', orders.OrderComment.as_view(), + name='event.order.comment'), url(r'^orders/(?P[0-9A-Z]+)/$', orders.OrderDetail.as_view(), name='event.order'), url(r'^orders/(?P[0-9A-Z]+)/download/(?P[^/]+)$', orders.OrderDownload.as_view(), name='event.order.download'), diff --git a/src/pretix/control/views/orders.py b/src/pretix/control/views/orders.py index 5d41258f98..c4a1c55f8a 100644 --- a/src/pretix/control/views/orders.py +++ b/src/pretix/control/views/orders.py @@ -28,7 +28,7 @@ from pretix.base.signals import ( register_data_exporters, register_payment_providers, register_ticket_outputs, ) -from pretix.control.forms.orders import ExporterForm, ExtendForm +from pretix.control.forms.orders import CommentForm, ExporterForm, ExtendForm from pretix.control.permissions import EventPermissionRequiredMixin from pretix.multidomain.urlreverse import build_absolute_uri @@ -132,6 +132,7 @@ class OrderDetail(OrderView): ) ctx['payment'] = self.payment_provider.order_control_render(self.request, self.object) ctx['invoices'] = list(self.order.invoices.all().select_related('event')) + ctx['comment_form'] = CommentForm(initial={'comment': self.order.comment}) return ctx def get_items(self): @@ -172,6 +173,21 @@ class OrderDetail(OrderView): } +class OrderComment(OrderView): + permission = 'can_change_orders' + + def post(self, *args, **kwargs): + form = CommentForm(self.request.POST) + if form.is_valid(): + self.order.comment = form.cleaned_data.get('comment') + self.order.save() + self.order.log_action('pretix.event.order.comment', user=self.request.user) + messages.success(self.request, _('The comment has been updated.')) + else: + messages.error(self.request, _('Could not update the comment.')) + return redirect(self.get_order_url()) + + class OrderTransition(OrderView): permission = 'can_change_orders' diff --git a/src/static/pretixcontrol/scss/main.scss b/src/static/pretixcontrol/scss/main.scss index 5b4fefb55e..71d955e806 100644 --- a/src/static/pretixcontrol/scss/main.scss +++ b/src/static/pretixcontrol/scss/main.scss @@ -95,6 +95,9 @@ h1 .btn-sm { .helper-width-auto { width: auto; } +.helper-width-100 { + width: 100%; +} .helper-space-below { margin-bottom: 10px; }