mirror of
https://github.com/pretix/pretix.git
synced 2026-05-04 15:04:03 +00:00
Add sub-events and relative date settings (#503)
* Data model * little crud * SubEventItemForm etc * Drop SubEventItem.active, quota editor * Fix failing tests * First frontend stuff * Addons form stuff * Quota calculation * net price display on EventIndex * Add tests, solve some bugs * Correct quota selection in more places, consolidate pricing logic * Fix failing quota tests * Fix TypeError * Add tests for checkout * Fixed a bug in QuotaForm * Prevent immutable cart if a quota was removed from an item * Add tests for pricing * Handle waiting list * Filter in check-in list * Fixed import lost in rebase * Fix waiting list widget * Voucher management * Voucher redemption * Fix broken tests * Add subevents to OrderChangeManager * Create a subevent during event creation * Fix bulk voucher creation * Introduce subevent.active * Copy from for subevents * Show active in list * ICal download for subevents * Check start and end of presale * Failing tests / show cart logic * Test * Rebase migrations * REST API integration of sub-events * Integrate quota calculation into the traditional quota form * Make subevent argument to add_position optional * Log-display foo * pretixdroid and subevents * Filter by subevent * Add more tests * Some mor tests * Rebase fixes * More tests * Relative dates * Restrict selection in relative datetime widgets * Filter subevent list * Re-label has_subevents * Rebase fixes, subevents in calendar view * Performance and caching issues * Refactor calendar templates * Permission tests * Calendar fixes and month selection * subevent selection * Rename subevents to dates * Add tests for calendar views
This commit is contained in:
@@ -1,15 +1,22 @@
|
||||
from django import forms
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
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
|
||||
|
||||
|
||||
class MailForm(forms.Form):
|
||||
sendto = forms.MultipleChoiceField() # overridden later
|
||||
subject = forms.CharField(label=_("Subject"))
|
||||
message = forms.CharField(label=_("Message"))
|
||||
subevent = forms.ModelChoiceField(
|
||||
SubEvent.objects.none(),
|
||||
label=_('Only send to customers of'),
|
||||
required=False,
|
||||
empty_label=pgettext_lazy('subevent', 'All dates')
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
event = kwargs.pop('event')
|
||||
@@ -35,3 +42,7 @@ class MailForm(forms.Form):
|
||||
label=_("Send to"), widget=forms.CheckboxSelectMultiple,
|
||||
choices=choices
|
||||
)
|
||||
if event.has_subevents:
|
||||
self.fields['subevent'].queryset = event.subevents.all()
|
||||
else:
|
||||
del self.fields['subevent']
|
||||
|
||||
@@ -9,17 +9,20 @@
|
||||
{% for log in logs %}
|
||||
<li class="list-group-item logentry">
|
||||
<p class="meta">
|
||||
<span class="fa fa-clock-o"></span> {{ log.datetime|date:"SHORT_DATETIME_FORMAT" }}
|
||||
<span class="fa fa-clock-o fa-fw"></span> {{ log.datetime|date:"SHORT_DATETIME_FORMAT" }}
|
||||
{% if log.user %}
|
||||
<br/><span class="fa fa-user"></span> {{ log.user.get_full_name }}
|
||||
<br/><span class="fa fa-user fa-fw"></span> {{ log.user.get_full_name }}
|
||||
{% endif %}
|
||||
{% if log.display %}
|
||||
<br/><span class="fa fa-comment-o"></span> {{ log.display }}
|
||||
<br/><span class="fa fa-comment-o fa-fw"></span> {{ log.display }}
|
||||
{% endif %}
|
||||
<br/><span class="fa fa-shopping-cart"></span> {% trans "Sent to orders:" %}
|
||||
<br/><span class="fa fa-shopping-cart fa-fw"></span> {% trans "Sent to orders:" %}
|
||||
{% for status in log.parsed_data.sendto %}
|
||||
{{ status }}{% if forloop.revcounter > 1 %},{% endif %}
|
||||
{% endfor %}
|
||||
{% if log.pdata.subevent_obj %}
|
||||
<br/><span class="fa fa-calendar fa-fw"></span> {{ log.pdata.subevent_obj }}
|
||||
{% endif %}
|
||||
</p>
|
||||
<p>
|
||||
{% for locale, value in log.pdata.locales.items %}
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
<form class="form-horizontal" method="post" action="">
|
||||
{% csrf_token %}
|
||||
{% bootstrap_field form.sendto layout='horizontal' %}
|
||||
{% if form.subevent %}
|
||||
{% bootstrap_field form.subevent layout='horizontal' %}
|
||||
{% endif %}
|
||||
{% bootstrap_field form.subject layout='horizontal' %}
|
||||
{% bootstrap_field form.message layout='horizontal' %}
|
||||
{% if request.method == "POST" %}
|
||||
|
||||
@@ -13,6 +13,7 @@ from django.views.generic import FormView, ListView
|
||||
|
||||
from pretix.base.i18n import LazyI18nString, language
|
||||
from pretix.base.models import InvoiceAddress, LogEntry, Order
|
||||
from pretix.base.models.event import SubEvent
|
||||
from pretix.base.services.mail import SendMailException, mail
|
||||
from pretix.control.permissions import EventPermissionRequiredMixin
|
||||
from pretix.multidomain.urlreverse import build_absolute_uri
|
||||
@@ -43,6 +44,13 @@ class SenderView(EventPermissionRequiredMixin, FormView):
|
||||
'subject': LazyI18nString(logentry.parsed_data['subject']),
|
||||
'sendto': logentry.parsed_data['sendto'],
|
||||
}
|
||||
if logentry.parsed_data.get('subevent'):
|
||||
try:
|
||||
kwargs['initial']['subevent'] = self.request.event.subevents.get(
|
||||
pk=logentry.parsed_data['subevent']['id']
|
||||
)
|
||||
except SubEvent.DoesNotExist:
|
||||
pass
|
||||
except LogEntry.DoesNotExist:
|
||||
raise Http404(_('You supplied an invalid log entry ID'))
|
||||
return kwargs
|
||||
@@ -57,6 +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('subevent'):
|
||||
orders = orders.filter(positions__subevent__in=(form.cleaned_data.get('subevent'),)).distinct()
|
||||
|
||||
tz = pytz.timezone(self.request.event.settings.timezone)
|
||||
|
||||
@@ -119,7 +129,7 @@ class SenderView(EventPermissionRequiredMixin, FormView):
|
||||
data={
|
||||
'subject': form.cleaned_data['subject'],
|
||||
'message': form.cleaned_data['message'],
|
||||
'recipient': o.email
|
||||
'recipient': o.email,
|
||||
}
|
||||
)
|
||||
except SendMailException:
|
||||
@@ -175,5 +185,10 @@ class EmailHistoryView(EventPermissionRequiredMixin, ListView):
|
||||
log.pdata['sendto'] = [
|
||||
status[s] for s in log.pdata['sendto']
|
||||
]
|
||||
if log.pdata.get('subevent'):
|
||||
try:
|
||||
log.pdata['subevent_obj'] = self.request.event.subevents.get(pk=log.pdata['subevent']['id'])
|
||||
except SubEvent.DoesNotExist:
|
||||
pass
|
||||
|
||||
return ctx
|
||||
|
||||
Reference in New Issue
Block a user