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:
Raphael Michel
2019-07-16 14:02:27 +02:00
committed by GitHub
parent c1e2fb36ba
commit a02ea45dba
16 changed files with 219 additions and 12 deletions

View File

@@ -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(