Enforce start and end time of presale (#15)

This commit is contained in:
Raphael Michel
2015-04-16 17:40:08 +02:00
parent 1532b3f1ee
commit 14c582d11e
9 changed files with 209 additions and 90 deletions

View File

@@ -4,8 +4,10 @@ from django.contrib.auth.views import redirect_to_login
from django.core.urlresolvers import reverse
from django.db.models import Q
from django.http import HttpResponseBadRequest, HttpResponseForbidden
from django.utils.functional import cached_property
from django.utils.timezone import now
from django.utils.translation import ugettext_lazy as _
from pretix.base.models import CartPosition
from pretix.base.signals import register_payment_providers

View File

@@ -99,6 +99,13 @@ class CartAdd(EventViewMixin, CartActionMixin, View):
self.msg_some_unavailable = False
def post(self, request, *args, **kwargs):
if request.event.presale_start and now() < request.event.presale_start:
messages.error(request, _('The presale period not yet started.'))
return redirect(self.get_failure_url())
if request.event.presale_end and now() > request.event.presale_end:
messages.error(request, _('The presale period has ended.'))
return redirect(self.get_failure_url())
self.items = self._items_from_post_data()
# We do not use EventLoginRequiredMixin here, as we want to store stuff into the

View File

@@ -355,10 +355,11 @@ class OrderConfirm(EventViewMixin, CartDisplayMixin, EventLoginRequiredMixin, Ch
quota_ok = False
break
if quota_ok:
cp = cp.clone()
cartpos[i] = cp
cp.expires = now() + timedelta(minutes=self.request.event.settings.get('reservation_time', as_type=int))
cp.save()
if not self.request.event.presale_end or now() < self.request.event.presale_end:
cp = cp.clone()
cartpos[i] = cp
cp.expires = now() + timedelta(minutes=self.request.event.settings.get('reservation_time', as_type=int))
cp.save()
else:
cp.delete() # Sorry!
if not self.msg_some_unavailable: # Everything went well