Refs #340 -- Allow order changes for paid orders if they don't change the total

This commit is contained in:
Raphael Michel
2017-02-15 18:42:46 +01:00
parent 0db927407d
commit c4bf73c8d6
7 changed files with 49 additions and 10 deletions

View File

@@ -1,6 +1,7 @@
from django import forms
from django.core.exceptions import ValidationError
from django.db import models
from django.utils.formats import localize
from django.utils.timezone import now
from django.utils.translation import ugettext_lazy as _
@@ -94,9 +95,12 @@ class OrderPositionChangeForm(forms.Form):
variations = list(i.variations.all())
if variations:
for v in variations:
choices.append(('%d-%d' % (i.pk, v.pk), '%s %s' % (pname, v.value)))
choices.append(('%d-%d' % (i.pk, v.pk),
'%s %s (%s %s)' % (pname, v.value, localize(v.price),
instance.order.event.currency)))
else:
choices.append((str(i.pk), pname))
choices.append((str(i.pk), '%s (%s %s)' % (pname, localize(i.default_price),
instance.order.event.currency)))
self.fields['itemvar'].choices = choices
def clean(self):

View File

@@ -144,7 +144,7 @@
<div class="panel panel-default items">
<div class="panel-heading">
<div class="pull-right">
{% if order.status == "n" and request.eventperm.can_change_orders %}
{% if order.changable and request.eventperm.can_change_orders %}
<a href="{% url "control:event.order.change" event=request.event.slug organizer=request.event.organizer.slug code=order.code %}">
<span class="fa fa-edit"></span>
{% trans "Change products" %}

View File

@@ -446,8 +446,8 @@ class OrderChange(OrderView):
template_name = 'pretixcontrol/order/change.html'
def dispatch(self, request, *args, **kwargs):
if self.order.status != Order.STATUS_PENDING:
messages.error(self.request, _('This action is only allowed for pending orders.'))
if self.order.status not in (Order.STATUS_PENDING, Order.STATUS_PAID):
messages.error(self.request, _('This action is only allowed for pending or paid orders.'))
return self._redirect_back()
return super().dispatch(request, *args, **kwargs)