forked from CGM_Public/pretix_original
Merge pull request #178 from rixx/order_fixes
Add comment field to Orders
This commit is contained in:
20
src/pretix/base/migrations/0026_order_comment.py
Normal file
20
src/pretix/base/migrations/0026_order_comment.py
Normal file
@@ -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'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -74,6 +74,8 @@ class Order(LoggedModel):
|
|||||||
:type payment_info: str
|
:type payment_info: str
|
||||||
:param total: The total amount of the order, including the payment fee
|
:param total: The total amount of the order, including the payment fee
|
||||||
:type total: decimal.Decimal
|
: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"
|
STATUS_PENDING = "n"
|
||||||
@@ -153,6 +155,11 @@ class Order(LoggedModel):
|
|||||||
decimal_places=2, max_digits=10,
|
decimal_places=2, max_digits=10,
|
||||||
verbose_name=_("Total amount")
|
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:
|
class Meta:
|
||||||
verbose_name = _("Order")
|
verbose_name = _("Order")
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ class Voucher(LoggedModel):
|
|||||||
:type variation: ItemVariation
|
:type variation: ItemVariation
|
||||||
:param quota: If set, the quota to choose an item from
|
:param quota: If set, the quota to choose an item from
|
||||||
:type quota: Quota
|
: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:
|
Various constraints apply:
|
||||||
|
|
||||||
|
|||||||
@@ -23,3 +23,15 @@ class ExporterForm(forms.Form):
|
|||||||
data[k] = [m.pk for m in v]
|
data[k] = [m.pk for m in v]
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
class CommentForm(I18nModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = Order
|
||||||
|
fields = ['comment']
|
||||||
|
widgets = {
|
||||||
|
'comment': forms.Textarea(attrs={
|
||||||
|
'rows': 3,
|
||||||
|
'class': 'helper-width-100',
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
|||||||
@@ -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.generated': _('The invoice has been generated.'),
|
||||||
'pretix.event.order.invoice.regenerated': _('The invoice has been regenerated.'),
|
'pretix.event.order.invoice.regenerated': _('The invoice has been regenerated.'),
|
||||||
'pretix.event.order.invoice.reissued': _('The invoice has been reissued.'),
|
'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:
|
if logentry.action_type in plains:
|
||||||
return plains[logentry.action_type]
|
return plains[logentry.action_type]
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{% extends "pretixcontrol/event/base.html" %}
|
{% extends "pretixcontrol/event/base.html" %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
{% load bootstrap3 %}
|
||||||
{% load eventurl %}
|
{% load eventurl %}
|
||||||
{% block title %}
|
{% block title %}
|
||||||
{% blocktrans trimmed with code=order.code %}
|
{% blocktrans trimmed with code=order.code %}
|
||||||
@@ -279,6 +280,25 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="panel panel-default items">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<h3 class="panel-title">
|
||||||
|
{% trans "Internal comment" %}
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<form class="form" method="post"
|
||||||
|
action="{% url "control:event.order.comment" event=request.event.slug organizer=request.event.organizer.slug code=order.code %}">
|
||||||
|
{% csrf_token %}
|
||||||
|
<div class="row">
|
||||||
|
{% bootstrap_field comment_form.comment layout="horizontal" show_help=True show_label=False horizontal_field_class="col-md-12" %}
|
||||||
|
</div>
|
||||||
|
<button class="btn btn-default">
|
||||||
|
{% trans "Update comment" %}
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-xs-12 col-lg-2">
|
<div class="col-xs-12 col-lg-2">
|
||||||
|
|||||||
@@ -77,6 +77,8 @@ urlpatterns = [
|
|||||||
name='event.order.reissueinvoice'),
|
name='event.order.reissueinvoice'),
|
||||||
url(r'^orders/(?P<code>[0-9A-Z]+)/extend$', orders.OrderExtend.as_view(),
|
url(r'^orders/(?P<code>[0-9A-Z]+)/extend$', orders.OrderExtend.as_view(),
|
||||||
name='event.order.extend'),
|
name='event.order.extend'),
|
||||||
|
url(r'^orders/(?P<code>[0-9A-Z]+)/comment$', orders.OrderComment.as_view(),
|
||||||
|
name='event.order.comment'),
|
||||||
url(r'^orders/(?P<code>[0-9A-Z]+)/$', orders.OrderDetail.as_view(), name='event.order'),
|
url(r'^orders/(?P<code>[0-9A-Z]+)/$', orders.OrderDetail.as_view(), name='event.order'),
|
||||||
url(r'^orders/(?P<code>[0-9A-Z]+)/download/(?P<output>[^/]+)$', orders.OrderDownload.as_view(),
|
url(r'^orders/(?P<code>[0-9A-Z]+)/download/(?P<output>[^/]+)$', orders.OrderDownload.as_view(),
|
||||||
name='event.order.download'),
|
name='event.order.download'),
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ from pretix.base.signals import (
|
|||||||
register_data_exporters, register_payment_providers,
|
register_data_exporters, register_payment_providers,
|
||||||
register_ticket_outputs,
|
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.control.permissions import EventPermissionRequiredMixin
|
||||||
from pretix.multidomain.urlreverse import build_absolute_uri
|
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['payment'] = self.payment_provider.order_control_render(self.request, self.object)
|
||||||
ctx['invoices'] = list(self.order.invoices.all().select_related('event'))
|
ctx['invoices'] = list(self.order.invoices.all().select_related('event'))
|
||||||
|
ctx['comment_form'] = CommentForm(initial={'comment': self.order.comment})
|
||||||
return ctx
|
return ctx
|
||||||
|
|
||||||
def get_items(self):
|
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):
|
class OrderTransition(OrderView):
|
||||||
permission = 'can_change_orders'
|
permission = 'can_change_orders'
|
||||||
|
|
||||||
|
|||||||
@@ -95,6 +95,9 @@ h1 .btn-sm {
|
|||||||
.helper-width-auto {
|
.helper-width-auto {
|
||||||
width: auto;
|
width: auto;
|
||||||
}
|
}
|
||||||
|
.helper-width-100 {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
.helper-space-below {
|
.helper-space-below {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user