mirror of
https://github.com/pretix/pretix.git
synced 2026-05-04 15:04:03 +00:00
- [x] attendee names - [x] Invoice address names - [x] Data migration - [x] API serializers - [x] orderposition - [x] cartposition - [x] invoiceaddress - [x] checkinlistposition - [x] position API search - [x] invoice API search - [x] business/individual required toggle - [x] Split columns in CSV exports - [x] ticket editor - [x] shredder - [x] ticket/invoice sample data - [x] order search - [x] Handle changed naming scheme - [x] tests - [x] make use in: - [x] Boabee - [x] Certificate download order - [x] Badge download order - [x] Ticket download order - [x] Document new MySQL requirement - [x] Plugins
This commit is contained in:
@@ -1,28 +1,80 @@
|
||||
from collections import OrderedDict
|
||||
from io import BytesIO
|
||||
|
||||
from django import forms
|
||||
from django.conf import settings
|
||||
from django.core.files.base import ContentFile
|
||||
from django.db.models.functions import Coalesce
|
||||
from django.utils.translation import ugettext as _
|
||||
from jsonfallback.functions import JSONExtract
|
||||
from PyPDF2.merger import PdfFileMerger
|
||||
|
||||
from pretix.base.exporter import BaseExporter
|
||||
from pretix.base.i18n import language
|
||||
from pretix.base.models import Order, OrderPosition
|
||||
from pretix.base.settings import PERSON_NAME_SCHEMES
|
||||
|
||||
from .ticketoutput import PdfTicketOutput
|
||||
|
||||
|
||||
class AllTicketsPDF(BaseExporter):
|
||||
name = "alltickets"
|
||||
verbose_name = _("All paid PDF tickets in one file")
|
||||
verbose_name = _("All PDF tickets in one file")
|
||||
identifier = "pdfoutput_all_tickets"
|
||||
|
||||
@property
|
||||
def export_form_fields(self):
|
||||
name_scheme = PERSON_NAME_SCHEMES[self.event.settings.name_scheme]
|
||||
d = OrderedDict(
|
||||
[
|
||||
('include_pending',
|
||||
forms.BooleanField(
|
||||
label=_('Include pending orders'),
|
||||
required=False
|
||||
)),
|
||||
('order_by',
|
||||
forms.ChoiceField(
|
||||
label=_('Sort by'),
|
||||
choices=[
|
||||
('name', _('Attendee name')),
|
||||
('code', _('Order code')),
|
||||
] + ([
|
||||
('name:{}'.format(k), _('Attendee name: {part}').format(part=label))
|
||||
for k, label, w in name_scheme['fields']
|
||||
] if settings.JSON_FIELD_AVAILABLE and len(name_scheme['fields']) > 1 else []),
|
||||
)),
|
||||
]
|
||||
)
|
||||
return d
|
||||
|
||||
def render(self, form_data):
|
||||
merger = PdfFileMerger()
|
||||
|
||||
o = PdfTicketOutput(self.event)
|
||||
qs = OrderPosition.objects.filter(order__event=self.event, order__status=Order.STATUS_PAID).select_related(
|
||||
'order', 'item', 'variation'
|
||||
)
|
||||
qs = OrderPosition.objects.filter(
|
||||
order__event=self.event
|
||||
).prefetch_related(
|
||||
'answers', 'answers__question'
|
||||
).select_related('order', 'item', 'variation', 'addon_to')
|
||||
|
||||
if form_data.get('include_pending'):
|
||||
qs = qs.filter(order__status__in=[Order.STATUS_PAID, Order.STATUS_PENDING])
|
||||
else:
|
||||
qs = qs.filter(order__status__in=[Order.STATUS_PAID])
|
||||
|
||||
if form_data.get('order_by') == 'name':
|
||||
qs = qs.order_by('attendee_name_cached', 'order__code')
|
||||
elif form_data.get('order_by') == 'code':
|
||||
qs = qs.order_by('order__code')
|
||||
elif form_data.get('order_by', '').startswith('name:'):
|
||||
part = form_data['order_by'][5:]
|
||||
qs = qs.annotate(
|
||||
resolved_name=Coalesce('attendee_name_parts', 'addon_to__attendee_name_parts', 'order__invoice_address__name_parts')
|
||||
).annotate(
|
||||
resolved_name_part=JSONExtract('resolved_name', part)
|
||||
).order_by(
|
||||
'resolved_name_part'
|
||||
)
|
||||
|
||||
for op in qs:
|
||||
if op.addon_to_id and not self.event.settings.ticket_download_addons:
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 2.1 on 2018-10-17 00:24
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('ticketoutputpdf', '0005_merge_20180805_1436'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='ticketlayout',
|
||||
name='layout',
|
||||
field=models.TextField(default='[{"italic": false, "bottom": "274.60", "align": "left", "fontfamily": "Open Sans", "width": "175.00", "left": "17.50", "text": "Sample event name", "content": "event_name", "fontsize": "16.0", "bold": false, "color": [0, 0, 0, 1], "type": "textarea"}, {"italic": false, "bottom": "262.90", "align": "left", "fontfamily": "Open Sans", "width": "110.00", "left": "17.50", "text": "Sample product \\u2013 sample variation", "content": "itemvar", "fontsize": "13.0", "bold": false, "color": [0, 0, 0, 1], "type": "textarea"}, {"italic": false, "bottom": "252.50", "align": "left", "fontfamily": "Open Sans", "width": "110.00", "left": "17.50", "text": "John Doe", "content": "attendee_name", "fontsize": "13.0", "bold": false, "color": [0, 0, 0, 1], "type": "textarea"}, {"italic": false, "bottom": "242.10", "align": "left", "fontfamily": "Open Sans", "width": "110.00", "left": "17.50", "text": "May 31st, 2017", "content": "event_date_range", "fontsize": "13.0", "bold": false, "color": [0, 0, 0, 1], "type": "textarea"}, {"italic": false, "bottom": "204.80", "align": "left", "fontfamily": "Open Sans", "width": "110.00", "left": "17.50", "text": "Random City", "content": "event_location", "fontsize": "13.0", "bold": false, "color": [0, 0, 0, 1], "type": "textarea"}, {"italic": false, "bottom": "194.50", "align": "left", "fontfamily": "Open Sans", "width": "30.00", "left": "17.50", "text": "A1B2C", "content": "order", "fontsize": "13.0", "bold": false, "color": [0, 0, 0, 1], "type": "textarea"}, {"italic": false, "bottom": "194.50", "align": "right", "fontfamily": "Open Sans", "width": "45.00", "left": "52.50", "text": "123.45 EUR", "content": "price", "fontsize": "13.0", "bold": false, "color": [0, 0, 0, 1], "type": "textarea"}, {"italic": false, "bottom": "194.50", "align": "left", "fontfamily": "Open Sans", "width": "90.00", "left": "102.50", "text": "tdmruoekvkpbv1o2mv8xccvqcikvr58u", "content": "secret", "fontsize": "13.0", "bold": false, "color": [0, 0, 0, 1], "type": "textarea"}, {"left": "130.40", "bottom": "204.50", "type": "barcodearea", "size": "64.00"},{"type":"poweredby","left":"88.72","bottom":"10.00","size":"20.00","content":"dark"}]'),
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user