mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Sendmail: Use multi-select for product selection
This commit is contained in:
@@ -12,11 +12,13 @@ class MailForm(forms.Form):
|
||||
sendto = forms.MultipleChoiceField() # overridden later
|
||||
subject = forms.CharField(label=_("Subject"))
|
||||
message = forms.CharField(label=_("Message"))
|
||||
item = forms.ModelChoiceField(
|
||||
Item.objects.none(),
|
||||
items = forms.ModelMultipleChoiceField(
|
||||
widget=forms.CheckboxSelectMultiple(
|
||||
attrs={'class': 'scrolling-multiple-choice'}
|
||||
),
|
||||
label=_('Only send to people who bought'),
|
||||
required=False,
|
||||
empty_label=_('Any product')
|
||||
required=True,
|
||||
queryset=Item.objects.none()
|
||||
)
|
||||
subevent = forms.ModelChoiceField(
|
||||
SubEvent.objects.none(),
|
||||
@@ -53,10 +55,18 @@ class MailForm(forms.Form):
|
||||
)
|
||||
self.fields['sendto'] = forms.MultipleChoiceField(
|
||||
label=_("Send to customers with order status"),
|
||||
widget=forms.CheckboxSelectMultiple,
|
||||
widget=forms.CheckboxSelectMultiple(
|
||||
attrs={'class': 'scrolling-multiple-choice'}
|
||||
),
|
||||
choices=choices
|
||||
)
|
||||
self.fields['item'].queryset = event.items.all()
|
||||
if not self.initial.get('sendto'):
|
||||
self.initial['sendto'] = ['p', 'n']
|
||||
|
||||
self.fields['items'].queryset = event.items.all()
|
||||
if not self.initial.get('items'):
|
||||
self.initial['items'] = event.items.all()
|
||||
|
||||
if event.has_subevents:
|
||||
self.fields['subevent'].queryset = event.subevents.all()
|
||||
self.fields['subevent'].widget = Select2(
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
{% if form.subevent %}
|
||||
{% bootstrap_field form.subevent layout='horizontal' %}
|
||||
{% endif %}
|
||||
{% bootstrap_field form.item layout='horizontal' %}
|
||||
{% bootstrap_field form.items layout='horizontal' %}
|
||||
{% bootstrap_field form.subject layout='horizontal' %}
|
||||
{% bootstrap_field form.message layout='horizontal' %}
|
||||
{% if request.method == "POST" %}
|
||||
|
||||
@@ -42,6 +42,7 @@ class SenderView(EventPermissionRequiredMixin, FormView):
|
||||
'message': LazyI18nString(logentry.parsed_data['message']),
|
||||
'subject': LazyI18nString(logentry.parsed_data['subject']),
|
||||
'sendto': logentry.parsed_data['sendto'],
|
||||
'items': self.request.event.items.filter(id__in=[a['id'] for a in logentry.parsed_data['items']]),
|
||||
}
|
||||
if logentry.parsed_data.get('subevent'):
|
||||
try:
|
||||
@@ -64,9 +65,8 @@ class SenderView(EventPermissionRequiredMixin, FormView):
|
||||
if 'overdue' in form.cleaned_data['sendto']:
|
||||
statusq |= Q(status=Order.STATUS_PENDING, expires__lt=now())
|
||||
orders = qs.filter(statusq)
|
||||
if form.cleaned_data.get('item'):
|
||||
orders = orders.filter(all_positions__item=form.cleaned_data.get('item'),
|
||||
all_positions__canceled=False)
|
||||
orders = orders.filter(all_positions__item_id__in=[i.pk for i in form.cleaned_data.get('items')],
|
||||
all_positions__canceled=False)
|
||||
if form.cleaned_data.get('subevent'):
|
||||
orders = orders.filter(all_positions__subevent__in=(form.cleaned_data.get('subevent'),),
|
||||
all_positions__canceled=False)
|
||||
|
||||
Reference in New Issue
Block a user