forked from CGM_Public/pretix_original
Refactor cancelling positions and orders in the data model (#1088)
- [x] Data model - [x] display in order view in backend - [x] review all usages of OrderPositions.objects - [x] review all usages of order.positions - [x] review all other model usages - [x] review plugins - [x] plugins backwards-compatible API? - [x] decide on way forward for REST API - [x] need to cancel fees - [x] tests - [ ] plugins - [ ] gdpr - [ ] reports - [x] docs
This commit is contained in:
@@ -50,9 +50,6 @@ def _handle_transaction(trans: BankTransaction, code: str, event: Event=None, or
|
||||
|
||||
if trans.order.status == Order.STATUS_PAID and trans.order.pending_sum <= Decimal('0.00'):
|
||||
trans.state = BankTransaction.STATE_DUPLICATE
|
||||
elif trans.order.status == Order.STATUS_REFUNDED:
|
||||
trans.state = BankTransaction.STATE_ERROR
|
||||
trans.message = ugettext_noop('The order has already been refunded.')
|
||||
elif trans.order.status == Order.STATUS_CANCELED:
|
||||
trans.state = BankTransaction.STATE_ERROR
|
||||
trans.message = ugettext_noop('The order has already been canceled.')
|
||||
|
||||
@@ -54,11 +54,6 @@ class ActionView(View):
|
||||
'status': 'error',
|
||||
'message': _('The order is already marked as paid.')
|
||||
})
|
||||
elif trans.order.status == Order.STATUS_REFUNDED:
|
||||
return JsonResponse({
|
||||
'status': 'error',
|
||||
'message': _('The order has already been refunded.')
|
||||
})
|
||||
elif trans.order.status == Order.STATUS_CANCELED:
|
||||
return JsonResponse({
|
||||
'status': 'error',
|
||||
@@ -170,8 +165,8 @@ class ActionView(View):
|
||||
qs = self.order_qs().order_by('pk').annotate(inr=Concat('invoices__prefix', 'invoices__invoice_no')).filter(
|
||||
code
|
||||
| Q(email__icontains=u)
|
||||
| Q(positions__attendee_name_cached__icontains=u)
|
||||
| Q(positions__attendee_email__icontains=u)
|
||||
| Q(all_positions__attendee_name_cached__icontains=u)
|
||||
| Q(all_positions__attendee_email__icontains=u)
|
||||
| Q(invoice_address__name_cached__icontains=u)
|
||||
| Q(invoice_address__company__icontains=u)
|
||||
| Q(invoices__invoice_no=u)
|
||||
|
||||
@@ -157,7 +157,7 @@ class OverviewReport(Report):
|
||||
headlinestyle.fontSize = 15
|
||||
headlinestyle.fontName = 'OpenSansBd'
|
||||
colwidths = [
|
||||
a * doc.width for a in (.25, 0.05, .075, 0.05, .075, 0.05, .075, 0.05, .075, 0.05, .075, 0.05, .075)
|
||||
a * doc.width for a in (.33, 0.05, .075, 0.05, .075, 0.05, .075, 0.05, .075, 0.05, .075)
|
||||
]
|
||||
tstyledata = [
|
||||
('SPAN', (1, 0), (2, 0)),
|
||||
@@ -188,7 +188,7 @@ class OverviewReport(Report):
|
||||
story.append(Spacer(1, 5 * mm))
|
||||
tdata = [
|
||||
[
|
||||
_('Product'), _('Canceled'), '', _('Refunded'), '', _('Expired'), '', _('Purchased'),
|
||||
_('Product'), _('Canceled'), '', _('Expired'), '', _('Purchased'),
|
||||
'', '', '', '', ''
|
||||
],
|
||||
[
|
||||
@@ -209,7 +209,6 @@ class OverviewReport(Report):
|
||||
places = settings.CURRENCY_PLACES.get(self.event.currency, 2)
|
||||
states = (
|
||||
('canceled', Order.STATUS_CANCELED),
|
||||
('refunded', Order.STATUS_REFUNDED),
|
||||
('expired', Order.STATUS_EXPIRED),
|
||||
('pending', Order.STATUS_PENDING),
|
||||
('paid', Order.STATUS_PAID),
|
||||
|
||||
@@ -65,9 +65,11 @@ class SenderView(EventPermissionRequiredMixin, FormView):
|
||||
statusq |= Q(status=Order.STATUS_PENDING, expires__lt=now())
|
||||
orders = qs.filter(statusq)
|
||||
if form.cleaned_data.get('item'):
|
||||
orders = orders.filter(positions__item=form.cleaned_data.get('item'))
|
||||
orders = orders.filter(all_positions__item=form.cleaned_data.get('item'),
|
||||
all_positions__canceled=False)
|
||||
if form.cleaned_data.get('subevent'):
|
||||
orders = orders.filter(positions__subevent__in=(form.cleaned_data.get('subevent'),))
|
||||
orders = orders.filter(all_positions__subevent__in=(form.cleaned_data.get('subevent'),),
|
||||
all_positions__canceled=False)
|
||||
orders = orders.distinct()
|
||||
|
||||
self.output = {}
|
||||
|
||||
@@ -61,7 +61,7 @@ class IndexView(EventPermissionRequiredMixin, ChartContainingView, TemplateView)
|
||||
if not ctx['obd_data']:
|
||||
oqs = Order.objects.annotate(payment_date=Subquery(p_date, output_field=DateTimeField()))
|
||||
if subevent:
|
||||
oqs = oqs.filter(positions__subevent_id=subevent).distinct()
|
||||
oqs = oqs.filter(positions__subevent_id=subevent, positions__canceled=False).distinct()
|
||||
|
||||
ordered_by_day = {}
|
||||
for o in oqs.filter(event=self.request.event).values('datetime'):
|
||||
|
||||
@@ -45,5 +45,5 @@ class TicketLayoutItemForm(forms.ModelForm):
|
||||
order_position__item_id=self.instance.item, provider='pdf'
|
||||
).delete()
|
||||
CachedCombinedTicket.objects.filter(
|
||||
order__positions__item=self.instance.item
|
||||
order__all_positions__item=self.instance.item
|
||||
).delete()
|
||||
|
||||
Reference in New Issue
Block a user