mirror of
https://github.com/pretix/pretix.git
synced 2026-05-09 15:54:03 +00:00
Add sales channels (#1103)
- [x] Data model - [x] Enforce constraint - [x] Filter order list - [x] Set channel on created order - [x] Products API - [x] Order API - [x] Tests - [x] Filter reports - [x] Resellers - [ ] deploy plugins - [ ] posbackend - [ ] resellers - [ ] reports - [x] Ticketlayouts - [x] Support in pretixPOS
This commit is contained in:
@@ -382,7 +382,7 @@ class CartAdd(EventViewMixin, CartActionMixin, AsyncAction, View):
|
||||
items = self._items_from_post_data()
|
||||
if items:
|
||||
return self.do(self.request.event.id, items, cart_id, translation.get_language(),
|
||||
self.invoice_address.pk, widget_data)
|
||||
self.invoice_address.pk, widget_data, self.request.sales_channel)
|
||||
else:
|
||||
if 'ajax' in self.request.GET or 'ajax' in self.request.POST:
|
||||
return JsonResponse({
|
||||
@@ -405,7 +405,7 @@ class RedeemView(NoSearchIndexViewMixin, EventViewMixin, TemplateView):
|
||||
|
||||
# Fetch all items
|
||||
items, display_add_to_cart = get_grouped_items(self.request.event, self.subevent,
|
||||
voucher=self.voucher)
|
||||
voucher=self.voucher, channel=self.request.sales_channel)
|
||||
|
||||
# Calculate how many options the user still has. If there is only one option, we can
|
||||
# check the box right away ;)
|
||||
|
||||
@@ -47,12 +47,13 @@ def item_group_by_category(items):
|
||||
)
|
||||
|
||||
|
||||
def get_grouped_items(event, subevent=None, voucher=None):
|
||||
def get_grouped_items(event, subevent=None, voucher=None, channel='web'):
|
||||
items = event.items.all().filter(
|
||||
Q(active=True)
|
||||
& Q(Q(available_from__isnull=True) | Q(available_from__lte=now()))
|
||||
& Q(Q(available_until__isnull=True) | Q(available_until__gte=now()))
|
||||
& Q(Q(category__isnull=True) | Q(category__is_addon=False))
|
||||
& Q(sales_channels__contains=channel)
|
||||
)
|
||||
|
||||
vouchq = Q(hide_without_voucher=False)
|
||||
@@ -249,7 +250,8 @@ class EventIndex(EventViewMixin, CartMixin, TemplateView):
|
||||
context = super().get_context_data(**kwargs)
|
||||
if not self.request.event.has_subevents or self.subevent:
|
||||
# Fetch all items
|
||||
items, display_add_to_cart = get_grouped_items(self.request.event, self.subevent)
|
||||
items, display_add_to_cart = get_grouped_items(self.request.event, self.subevent,
|
||||
channel=self.request.sales_channel)
|
||||
context['itemnum'] = len(items)
|
||||
|
||||
# Regroup those by category
|
||||
|
||||
@@ -155,7 +155,7 @@ class WidgetAPIProductList(View):
|
||||
|
||||
def _get_items(self):
|
||||
items, display_add_to_cart = get_grouped_items(
|
||||
self.request.event, subevent=self.subevent, voucher=self.voucher
|
||||
self.request.event, subevent=self.subevent, voucher=self.voucher, channel='web'
|
||||
)
|
||||
grps = []
|
||||
for cat, g in item_group_by_category(items):
|
||||
|
||||
Reference in New Issue
Block a user