mirror of
https://github.com/pretix/pretix.git
synced 2026-09-30 19:04:43 +00:00
first step
This commit is contained in:
committed by
Raphael Michel
parent
b3e0892d76
commit
0545fda71d
@@ -913,8 +913,6 @@ class Item(LoggedModel):
|
||||
:raises ValueError: if you call this on an item which has variations associated with it.
|
||||
Please use the method on the ItemVariation object you are interested in.
|
||||
"""
|
||||
if not trust_parameters and not subevent and self.event.has_subevents:
|
||||
raise TypeError('You need to supply a subevent.')
|
||||
check_quotas = self._get_quotas(ignored_quotas=ignored_quotas, subevent=subevent)
|
||||
quotacounter = Counter()
|
||||
res = Quota.AVAILABILITY_OK, None
|
||||
|
||||
@@ -793,9 +793,7 @@ class CartManager:
|
||||
operations = []
|
||||
|
||||
for i in items:
|
||||
if self.event.has_subevents:
|
||||
if not i.get('subevent') or int(i.get('subevent')) not in self._subevents_cache:
|
||||
raise CartError(error_messages['subevent_required'])
|
||||
if self.event.has_subevents and i.get('subevents'):
|
||||
subevent = self._subevents_cache[int(i.get('subevent'))]
|
||||
else:
|
||||
subevent = None
|
||||
|
||||
@@ -58,9 +58,9 @@ class CrossSellingService:
|
||||
result = (
|
||||
(DummyCategory(category, subevent),
|
||||
self._prepare_items(subevent, items_qs, discount_info),
|
||||
f'subevent_{subevent.pk}_')
|
||||
f'subevent_{subevent.pk}_' if subevent else '')
|
||||
for subevent in subevents
|
||||
for (category, items_qs, discount_info) in self._applicable_categories(subevent.pk)
|
||||
for (category, items_qs, discount_info) in self._applicable_categories(subevent.pk if subevent else 0)
|
||||
)
|
||||
else:
|
||||
result = (
|
||||
|
||||
@@ -342,7 +342,6 @@ class QuotaForm(I18nModelForm):
|
||||
}
|
||||
)
|
||||
self.fields['subevent'].widget.choices = self.fields['subevent'].choices
|
||||
self.fields['subevent'].required = True
|
||||
else:
|
||||
del self.fields['subevent']
|
||||
|
||||
|
||||
@@ -185,69 +185,68 @@
|
||||
</div>
|
||||
{% eventsignal event "pretix.presale.signals.front_page_top" request=request subevent=subevent %}
|
||||
{% endif %}
|
||||
|
||||
{% if ev.presale_is_running or event.settings.show_items_outside_presale_period %}
|
||||
<form method="post" data-asynctask
|
||||
data-asynctask-headline="{% trans "We're now trying to reserve this for you!" %}"
|
||||
data-asynctask-text="{% blocktrans with time=event.settings.reservation_time %}Once the items are in your cart, you will have {{ time }} minutes to complete your purchase.{% endblocktrans %}"
|
||||
action="{% eventurl request.event "presale:event.cart.add" cart_namespace=cart_namespace %}?next={{ cart_redirect|urlencode }}&next_error={{ request.path|urlencode }}">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="subevent" value="{{ subevent.id|default_if_none:"" }}" />
|
||||
{% if ev.seating_plan_id and event.settings.seating_choice %}
|
||||
{% if event.has_subevents %}
|
||||
{% eventsignal event "pretix.presale.signals.render_seating_plan" request=request subevent=subevent %}
|
||||
{% else %}
|
||||
{% eventsignal event "pretix.presale.signals.render_seating_plan" request=request %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if ev.presale_is_running or event.settings.show_items_outside_presale_period %}
|
||||
<form method="post" data-asynctask
|
||||
data-asynctask-headline="{% trans "We're now trying to reserve this for you!" %}"
|
||||
data-asynctask-text="{% blocktrans with time=event.settings.reservation_time %}Once the items are in your cart, you will have {{ time }} minutes to complete your purchase.{% endblocktrans %}"
|
||||
action="{% eventurl request.event "presale:event.cart.add" cart_namespace=cart_namespace %}?next={{ cart_redirect|urlencode }}&next_error={{ request.path|urlencode }}">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="subevent" value="{{ subevent.id|default_if_none:"" }}" />
|
||||
{% if ev.seating_plan_id and event.settings.seating_choice %}
|
||||
{% if event.has_subevents %}
|
||||
{% eventsignal event "pretix.presale.signals.render_seating_plan" request=request subevent=subevent %}
|
||||
{% else %}
|
||||
{% eventsignal event "pretix.presale.signals.render_seating_plan" request=request %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if waitinglist_seated %}
|
||||
<aside class="front-page" aria-labelledby="waiting-list">
|
||||
<h3 id="waiting-list" class="sr-only">{% trans "Waiting list" %}</h3>
|
||||
<div class="row">
|
||||
<div class="col-md-8 col-sm-6 col-xs-12">
|
||||
<p>
|
||||
{% blocktrans trimmed %}
|
||||
Some of the categories in the seating plan above are currently sold out. If you want, you can add yourself to the
|
||||
waiting list. We will then notify if seats are available again.
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-md-4 col-sm-6 col-xs-12">
|
||||
<a href="{% eventurl event "presale:event.waitinglist" cart_namespace=cart_namespace|default_if_none:"" %}{% if subevent %}?subevent={{ subevent.pk }}{% endif %}" class="btn btn-default btn-block">
|
||||
<span class="fa fa-plus-circle" aria-hidden="true"></span>
|
||||
{% trans "Join waiting list" %}
|
||||
</a>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
{% if waitinglist_seated %}
|
||||
<aside class="front-page" aria-labelledby="waiting-list">
|
||||
<h3 id="waiting-list" class="sr-only">{% trans "Waiting list" %}</h3>
|
||||
<div class="row">
|
||||
<div class="col-md-8 col-sm-6 col-xs-12">
|
||||
<p>
|
||||
{% blocktrans trimmed %}
|
||||
Some of the categories in the seating plan above are currently sold out. If you want, you can add yourself to the
|
||||
waiting list. We will then notify if seats are available again.
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
</div>
|
||||
</aside>
|
||||
{% endif %}
|
||||
|
||||
<h2 class="sr-only">{% trans "Products" %}</h2>
|
||||
{% include "pretixpresale/event/fragment_product_list.html" %}
|
||||
{% if ev.presale_is_running and display_add_to_cart %}
|
||||
<div class="front-page">
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-md-offset-8 col-xs-12">
|
||||
<button class="btn btn-block btn-primary btn-lg" type="submit" id="btn-add-to-cart">
|
||||
{% if request.event.settings.redirect_to_checkout_directly %}
|
||||
{% if allfree %}
|
||||
<i class="fa fa-check" aria-hidden="true"></i> {% trans "Register" context "free_tickets" %}
|
||||
{% else %}
|
||||
<i class="fa fa-shopping-cart" aria-hidden="true"></i> {% trans "Proceed with checkout" %}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<i class="fa fa-shopping-cart" aria-hidden="true"></i> {% trans "Add to cart" %}
|
||||
{% endif %}
|
||||
</button>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
<div class="col-md-4 col-sm-6 col-xs-12">
|
||||
<a href="{% eventurl event "presale:event.waitinglist" cart_namespace=cart_namespace|default_if_none:"" %}{% if subevent %}?subevent={{ subevent.pk }}{% endif %}" class="btn btn-default btn-block">
|
||||
<span class="fa fa-plus-circle" aria-hidden="true"></span>
|
||||
{% trans "Join waiting list" %}
|
||||
</a>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</form>
|
||||
{% endif %}
|
||||
</aside>
|
||||
{% endif %}
|
||||
|
||||
<h2 class="sr-only">{% trans "Products" %}</h2>
|
||||
{% include "pretixpresale/event/fragment_product_list.html" %}
|
||||
{% if ev.presale_is_running and display_add_to_cart %}
|
||||
<div class="front-page">
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-md-offset-8 col-xs-12">
|
||||
<button class="btn btn-block btn-primary btn-lg" type="submit" id="btn-add-to-cart">
|
||||
{% if request.event.settings.redirect_to_checkout_directly %}
|
||||
{% if allfree %}
|
||||
<i class="fa fa-check" aria-hidden="true"></i> {% trans "Register" context "free_tickets" %}
|
||||
{% else %}
|
||||
<i class="fa fa-shopping-cart" aria-hidden="true"></i> {% trans "Proceed with checkout" %}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<i class="fa fa-shopping-cart" aria-hidden="true"></i> {% trans "Add to cart" %}
|
||||
{% endif %}
|
||||
</button>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</form>
|
||||
{% endif %}
|
||||
{% if show_vouchers %}
|
||||
<aside class="front-page" aria-labelledby="redeem-a-voucher">
|
||||
|
||||
@@ -194,55 +194,54 @@ class EventIndex(EventViewMixin, EventListMixin, CartMixin, TemplateView):
|
||||
|
||||
context['allow_waitinglist'] = context['ev'].waiting_list_active and context['ev'].presale_is_running
|
||||
|
||||
if not self.request.event.has_subevents or self.subevent:
|
||||
# Fetch all items
|
||||
items, display_add_to_cart = prepare_item_list_for_shop(
|
||||
self.request.event,
|
||||
subevent=self.subevent,
|
||||
filter_items=self.request.GET.getlist('item'),
|
||||
filter_categories=self.request.GET.getlist('category'),
|
||||
require_seat=None,
|
||||
channel=self.request.sales_channel,
|
||||
memberships=(
|
||||
self.request.customer.usable_memberships(
|
||||
for_event=self.subevent or self.request.event,
|
||||
testmode=self.request.event.testmode
|
||||
) if getattr(self.request, 'customer', None) else None
|
||||
),
|
||||
)
|
||||
# Fetch all items
|
||||
items, display_add_to_cart = prepare_item_list_for_shop(
|
||||
self.request.event,
|
||||
subevent=self.subevent,
|
||||
filter_items=self.request.GET.getlist('item'),
|
||||
filter_categories=self.request.GET.getlist('category'),
|
||||
require_seat=None,
|
||||
channel=self.request.sales_channel,
|
||||
memberships=(
|
||||
self.request.customer.usable_memberships(
|
||||
for_event=self.subevent or self.request.event,
|
||||
testmode=self.request.event.testmode
|
||||
) if getattr(self.request, 'customer', None) else None
|
||||
),
|
||||
)
|
||||
|
||||
context['waitinglist_seated'] = False
|
||||
if context['allow_waitinglist']:
|
||||
for i in items:
|
||||
if not i.allow_waitinglist or not i.requires_seat:
|
||||
continue
|
||||
context['waitinglist_seated'] = False
|
||||
if context['allow_waitinglist']:
|
||||
for i in items:
|
||||
if not i.allow_waitinglist or not i.requires_seat:
|
||||
continue
|
||||
|
||||
if i.has_variations:
|
||||
for v in i.available_variations:
|
||||
if v.cached_availability[0] != Quota.AVAILABILITY_OK:
|
||||
context['waitinglist_seated'] = True
|
||||
break
|
||||
else:
|
||||
if i.cached_availability[0] != Quota.AVAILABILITY_OK:
|
||||
if i.has_variations:
|
||||
for v in i.available_variations:
|
||||
if v.cached_availability[0] != Quota.AVAILABILITY_OK:
|
||||
context['waitinglist_seated'] = True
|
||||
break
|
||||
else:
|
||||
if i.cached_availability[0] != Quota.AVAILABILITY_OK:
|
||||
context['waitinglist_seated'] = True
|
||||
break
|
||||
|
||||
items = [i for i in items if not i.requires_seat]
|
||||
context['itemnum'] = len(items)
|
||||
context['allfree'] = all(
|
||||
item.display_price.gross == Decimal('0.00') and not item.mandatory_priced_addons
|
||||
for item in items if not item.has_variations
|
||||
) and all(
|
||||
all(
|
||||
var.display_price.gross == Decimal('0.00')
|
||||
for var in item.available_variations
|
||||
) and not item.mandatory_priced_addons
|
||||
for item in items if item.has_variations
|
||||
)
|
||||
items = [i for i in items if not i.requires_seat]
|
||||
context['itemnum'] = len(items)
|
||||
context['allfree'] = all(
|
||||
item.display_price.gross == Decimal('0.00') and not item.mandatory_priced_addons
|
||||
for item in items if not item.has_variations
|
||||
) and all(
|
||||
all(
|
||||
var.display_price.gross == Decimal('0.00')
|
||||
for var in item.available_variations
|
||||
) and not item.mandatory_priced_addons
|
||||
for item in items if item.has_variations
|
||||
)
|
||||
|
||||
# Regroup those by category
|
||||
context['items_by_category'] = item_group_by_category(items)
|
||||
context['display_add_to_cart'] = display_add_to_cart
|
||||
# Regroup those by category
|
||||
context['items_by_category'] = item_group_by_category(items)
|
||||
context['display_add_to_cart'] = display_add_to_cart
|
||||
|
||||
context['cart'] = self.get_cart()
|
||||
context['has_addon_choices'] = any(cp.has_addon_choices for cp in get_cart(self.request))
|
||||
|
||||
Reference in New Issue
Block a user