Allow sale of blocked seats on specific channels (#1518)

* Allow sale of blocked seats on specific channels

* Add docs
This commit is contained in:
Raphael Michel
2019-12-11 15:56:20 +01:00
committed by GitHub
parent 6d3ccc0182
commit 352942b7d6
10 changed files with 87 additions and 19 deletions

View File

@@ -4,12 +4,15 @@ from decimal import Decimal
from unittest import mock
import pytest
from django.dispatch import receiver
from django.utils.timezone import now
from django_scopes import scopes_disabled
from pytz import UTC
from pretix.base.channels import SalesChannel
from pretix.base.models import Question, SeatingPlan
from pretix.base.models.orders import CartPosition
from pretix.base.signals import register_sales_channels
@pytest.fixture
@@ -49,6 +52,21 @@ def quota(event, item):
return q
class FoobarSalesChannel(SalesChannel):
identifier = "bar"
verbose_name = "Foobar"
icon = "home"
testmode_supported = False
unlimited_items_per_order = True
@receiver(register_sales_channels, dispatch_uid="test_cart_register_sales_channels")
def base_sales_channels(sender, **kwargs):
return (
FoobarSalesChannel(),
)
TEST_CARTPOSITION_RES = {
'id': 1,
'cart_id': 'aaa@api',
@@ -163,6 +181,7 @@ CARTPOS_CREATE_PAYLOAD = {
'subevent': None,
'expires': '2018-06-11T10:00:00Z',
'includes_tax': True,
'sales_channel': 'web',
'answers': []
}
@@ -667,6 +686,23 @@ def test_cartpos_create_with_blocked_seat(token_client, organizer, event, item,
assert resp.data == ['The selected seat "A1" is not available.']
@pytest.mark.django_db
def test_cartpos_create_with_blocked_seat_allowed(token_client, organizer, event, item, quota, seat, question):
seat.blocked = True
seat.save()
res = copy.deepcopy(CARTPOS_CREATE_PAYLOAD)
res['item'] = item.pk
res['seat'] = seat.seat_guid
res['sales_channel'] = 'bar'
event.settings.seating_allow_blocked_seats_for_channel = ['bar']
resp = token_client.post(
'/api/v1/organizers/{}/events/{}/cartpositions/'.format(
organizer.slug, event.slug
), format='json', data=res
)
assert resp.status_code == 201
@pytest.mark.django_db
def test_cartpos_create_with_used_seat(token_client, organizer, event, item, quota, seat, question):
CartPosition.objects.create(

View File

@@ -2741,6 +2741,24 @@ def test_order_create_with_seat(token_client, organizer, event, item, quota, sea
assert p.seat == seat
@pytest.mark.django_db
def test_order_create_with_blocked_seat_allowed(token_client, organizer, event, item, quota, seat, question):
seat.blocked = True
seat.save()
res = copy.deepcopy(ORDER_CREATE_PAYLOAD)
res['positions'][0]['item'] = item.pk
res['positions'][0]['seat'] = seat.seat_guid
res['positions'][0]['answers'][0]['question'] = question.pk
res['sales_channel'] = 'bar'
event.settings.seating_allow_blocked_seats_for_channel = ['bar']
resp = token_client.post(
'/api/v1/organizers/{}/events/{}/orders/'.format(
organizer.slug, event.slug
), format='json', data=res
)
assert resp.status_code == 201
@pytest.mark.django_db
def test_order_create_with_blocked_seat(token_client, organizer, event, item, quota, seat, question):
seat.blocked = True