forked from CGM_Public/pretix_original
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,10 +1,12 @@
|
||||
from django.contrib import messages
|
||||
from django.shortcuts import redirect
|
||||
from django.shortcuts import get_object_or_404, redirect
|
||||
from django.utils import translation
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import pgettext_lazy, ugettext_lazy as _
|
||||
from django.views.generic import FormView
|
||||
|
||||
from pretix.base.models.event import SubEvent
|
||||
|
||||
from ...base.models import Item, ItemVariation, WaitingListEntry
|
||||
from ...multidomain.urlreverse import eventreverse
|
||||
from ..forms.waitinglist import WaitingListForm
|
||||
@@ -19,13 +21,15 @@ class WaitingView(FormView):
|
||||
kwargs['event'] = self.request.event
|
||||
kwargs['instance'] = WaitingListEntry(
|
||||
item=self.item_and_variation[0], variation=self.item_and_variation[1],
|
||||
event=self.request.event, locale=translation.get_language()
|
||||
event=self.request.event, locale=translation.get_language(),
|
||||
subevent=self.subevent
|
||||
)
|
||||
return kwargs
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
ctx = super().get_context_data()
|
||||
ctx['event'] = self.request.event
|
||||
ctx['subevent'] = self.subevent
|
||||
ctx['item'], ctx['variation'] = self.item_and_variation
|
||||
return ctx
|
||||
|
||||
@@ -54,13 +58,22 @@ class WaitingView(FormView):
|
||||
messages.error(request, _("We could not identify the product you selected."))
|
||||
return redirect(eventreverse(self.request.event, 'presale:event.index'))
|
||||
|
||||
self.subevent = None
|
||||
if request.event.has_subevents:
|
||||
if 'subevent' in request.GET:
|
||||
self.subevent = get_object_or_404(SubEvent, event=request.event, pk=request.GET['subevent'],
|
||||
active=True)
|
||||
else:
|
||||
messages.error(request, pgettext_lazy('subevent', "You need to select a date."))
|
||||
return redirect(eventreverse(self.request.event, 'presale:event.index'))
|
||||
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
def form_valid(self, form):
|
||||
availability = (
|
||||
self.item_and_variation[1].check_quotas(count_waitinglist=False)
|
||||
self.item_and_variation[1].check_quotas(count_waitinglist=False, subevent=self.subevent)
|
||||
if self.item_and_variation[1]
|
||||
else self.item_and_variation[0].check_quotas(count_waitinglist=False)
|
||||
else self.item_and_variation[0].check_quotas(count_waitinglist=False, subevent=self.subevent)
|
||||
)
|
||||
if availability[0] == 100:
|
||||
messages.error(self.request, _("You cannot add yourself to the waiting list as this product is currently "
|
||||
|
||||
Reference in New Issue
Block a user