Allow check-in lists to include unpaid orders

This commit is contained in:
Raphael Michel
2018-02-21 16:08:53 +01:00
parent 36585395f1
commit 3fbccf3f64
15 changed files with 220 additions and 38 deletions

View File

@@ -111,6 +111,7 @@ TEST_LIST_RES = {
"limit_products": [],
"position_count": 0,
"checkin_count": 0,
"include_pending": False,
"subevent": None
}

View File

@@ -1116,6 +1116,9 @@ class CheckinListTestCase(TestCase):
cls.cl_all = cls.event.checkin_lists.create(
name='All', all_products=True
)
cls.cl_all_pending = cls.event.checkin_lists.create(
name='Z Pending', all_products=True, include_pending=True
)
cls.cl_both = cls.event.checkin_lists.create(
name='Both', all_products=False
)
@@ -1152,9 +1155,23 @@ class CheckinListTestCase(TestCase):
op2.checkins.create(list=cls.cl_tickets)
op3.checkins.create(list=cls.cl_both)
o = Order.objects.create(
code='FOO', event=cls.event, email='dummy@dummy.test',
status=Order.STATUS_PENDING,
datetime=now(), expires=now() + timedelta(days=10),
total=Decimal("30"), payment_provider='banktransfer', locale='en'
)
op4 = OrderPosition.objects.create(
order=o,
item=cls.item2,
variation=None,
price=Decimal("6"),
)
op4.checkins.create(list=cls.cl_all_pending)
def test_annotated(self):
lists = list(CheckinList.annotate_with_numbers(self.event.checkin_lists.order_by('name'), self.event))
assert lists == [self.cl_all, self.cl_both, self.cl_tickets]
assert lists == [self.cl_all, self.cl_both, self.cl_tickets, self.cl_all_pending]
assert lists[0].checkin_count == 0
assert lists[0].position_count == 3
assert lists[0].percent == 0
@@ -1164,6 +1181,9 @@ class CheckinListTestCase(TestCase):
assert lists[2].checkin_count == 1
assert lists[2].position_count == 2
assert lists[2].percent == 50
assert lists[3].checkin_count == 1
assert lists[3].position_count == 4
assert lists[3].percent == 25
@pytest.mark.django_db

View File

@@ -172,6 +172,29 @@ def test_require_paid(client, env):
jdata = json.loads(resp.content.decode("utf-8"))
assert jdata['status'] == 'error'
assert jdata['reason'] == 'unpaid'
assert jdata['data']['checkin_allowed'] is False
@pytest.mark.django_db
def test_check_in_pending(client, env):
AppConfiguration.objects.create(event=env[0], key='abcdefg', list=env[5])
env[2].status = Order.STATUS_PENDING
env[2].save()
env[5].include_pending = True
env[5].save()
resp = client.post('/pretixdroid/api/%s/%s/redeem/?key=%s' % (env[0].organizer.slug, env[0].slug, 'abcdefg'),
data={'secret': '1234'})
jdata = json.loads(resp.content.decode("utf-8"))
assert jdata['status'] == 'error'
assert jdata['reason'] == 'unpaid'
assert jdata['data']['checkin_allowed'] is True
resp = client.post('/pretixdroid/api/%s/%s/redeem/?key=%s' % (env[0].organizer.slug, env[0].slug, 'abcdefg'),
data={'secret': '1234', 'ignore_unpaid': 'true'})
jdata = json.loads(resp.content.decode("utf-8"))
assert jdata['status'] == 'ok'
@pytest.mark.django_db