mirror of
https://github.com/pretix/pretix.git
synced 2026-05-06 15:24:02 +00:00
Allow to import orders (#1516)
* Allow to import orders * seats, subevents * Plugin support * Add docs * Warn about lack of quota handling * Control interface test * Test skeleton * First tests for the impotr columns * Add tests for all columns * Fix question validation
This commit is contained in:
53
src/pretix/control/forms/orderimport.py
Normal file
53
src/pretix/control/forms/orderimport.py
Normal file
@@ -0,0 +1,53 @@
|
||||
from django import forms
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from pretix.base.services.orderimport import get_all_columns
|
||||
|
||||
|
||||
class ProcessForm(forms.Form):
|
||||
orders = forms.ChoiceField(
|
||||
label=_('Import mode'),
|
||||
choices=(
|
||||
('many', _('Create a separate order for each line')),
|
||||
('one', _('Create one order with one position per line')),
|
||||
)
|
||||
)
|
||||
status = forms.ChoiceField(
|
||||
label=_('Order status'),
|
||||
choices=(
|
||||
('paid', _('Create orders as fully paid')),
|
||||
('pending', _('Create orders as pending and still require payment')),
|
||||
)
|
||||
)
|
||||
testmode = forms.BooleanField(
|
||||
label=_('Create orders as test mode orders'),
|
||||
required=False
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
headers = kwargs.pop('headers')
|
||||
initital = kwargs.pop('initial', {})
|
||||
self.event = kwargs.pop('event')
|
||||
initital['testmode'] = self.event.testmode
|
||||
kwargs['initial'] = initital
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
header_choices = [
|
||||
('csv:{}'.format(h), _('CSV column: "{name}"').format(name=h)) for h in headers
|
||||
]
|
||||
|
||||
for c in get_all_columns(self.event):
|
||||
choices = []
|
||||
if c.default_value:
|
||||
choices.append((c.default_value, c.default_label))
|
||||
choices += header_choices
|
||||
for k, v in c.static_choices():
|
||||
choices.append(('static:{}'.format(k), v))
|
||||
|
||||
self.fields[c.identifier] = forms.ChoiceField(
|
||||
label=str(c.verbose_name),
|
||||
choices=choices,
|
||||
widget=forms.Select(
|
||||
attrs={'data-static': 'true'}
|
||||
)
|
||||
)
|
||||
Reference in New Issue
Block a user