mirror of
https://github.com/pretix/pretix.git
synced 2026-05-04 15:04:03 +00:00
Allow quotas to "close" when once full (#1344)
* Model * Some UI * API and logging * Permission check * Add tests * Move option around
This commit is contained in:
@@ -1386,7 +1386,9 @@ TEST_QUOTA_RES = {
|
||||
"size": 200,
|
||||
"items": [],
|
||||
"variations": [],
|
||||
"subevent": None
|
||||
"subevent": None,
|
||||
"close_when_sold_out": False,
|
||||
"closed": False
|
||||
}
|
||||
|
||||
|
||||
@@ -1593,6 +1595,30 @@ def test_quota_update(token_client, organizer, event, quota, item):
|
||||
assert quota.all_logentries().count() == 1
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_quota_update_closed(token_client, organizer, event, quota, item):
|
||||
resp = token_client.patch(
|
||||
'/api/v1/organizers/{}/events/{}/quotas/{}/'.format(organizer.slug, event.slug, quota.pk),
|
||||
{
|
||||
"closed": True,
|
||||
},
|
||||
format='json'
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
with scopes_disabled():
|
||||
quota = Quota.objects.get(pk=resp.data['id'])
|
||||
assert quota.all_logentries().filter(action_type="pretix.event.quota.closed").count() == 1
|
||||
resp = token_client.patch(
|
||||
'/api/v1/organizers/{}/events/{}/quotas/{}/'.format(organizer.slug, event.slug, quota.pk),
|
||||
{
|
||||
"closed": False,
|
||||
},
|
||||
format='json'
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
assert quota.all_logentries().filter(action_type="pretix.event.quota.opened").count() == 1
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_quota_update_unchanged(token_client, organizer, event, quota, item):
|
||||
resp = token_client.patch(
|
||||
|
||||
Reference in New Issue
Block a user