mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Sendmail plugin: Allow to filter users by product
This commit is contained in:
@@ -3,14 +3,19 @@ from django.utils.translation import pgettext_lazy, ugettext_lazy as _
|
||||
from i18nfield.forms import I18nFormField, I18nTextarea, I18nTextInput
|
||||
|
||||
from pretix.base.forms import PlaceholderValidator
|
||||
from pretix.base.models import Order
|
||||
from pretix.base.models.event import SubEvent
|
||||
from pretix.base.models import Item, Order, SubEvent
|
||||
|
||||
|
||||
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(),
|
||||
label=_('Only send to people who bought'),
|
||||
required=False,
|
||||
empty_label=_('Any product')
|
||||
)
|
||||
subevent = forms.ModelChoiceField(
|
||||
SubEvent.objects.none(),
|
||||
label=_('Only send to customers of'),
|
||||
@@ -47,6 +52,7 @@ class MailForm(forms.Form):
|
||||
widget=forms.CheckboxSelectMultiple,
|
||||
choices=choices
|
||||
)
|
||||
self.fields['item'].queryset = event.items.all()
|
||||
if event.has_subevents:
|
||||
self.fields['subevent'].queryset = event.subevents.all()
|
||||
else:
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
{% if form.subevent %}
|
||||
{% bootstrap_field form.subevent layout='horizontal' %}
|
||||
{% endif %}
|
||||
{% bootstrap_field form.item layout='horizontal' %}
|
||||
{% bootstrap_field form.subject layout='horizontal' %}
|
||||
{% bootstrap_field form.message layout='horizontal' %}
|
||||
{% if request.method == "POST" %}
|
||||
|
||||
@@ -65,8 +65,11 @@ 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(positions__item=form.cleaned_data.get('item'))
|
||||
if form.cleaned_data.get('subevent'):
|
||||
orders = orders.filter(positions__subevent__in=(form.cleaned_data.get('subevent'),)).distinct()
|
||||
orders = orders.filter(positions__subevent__in=(form.cleaned_data.get('subevent'),))
|
||||
orders = orders.distinct()
|
||||
|
||||
tz = pytz.timezone(self.request.event.settings.timezone)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user