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

@@ -1,5 +1,7 @@
{% load i18n %}
{% if availability.0 == 10 %}
{% if closed %}
<span class="label label-danger">{% trans "Closed" %}</span>
{% elif availability.0 == 10 %}
<span class="label label-warning">{% trans "Sold out (pending orders)" %}</span>
{% elif availability.0 == 100 %}
{% if availability.1 != None %}

View File

@@ -20,6 +20,27 @@
<span class="fa fa-calendar"></span> {{ quota.subevent.name }} {{ quota.subevent.get_date_range_display }}
</p>
{% endif %}
<form action="" method="post">
{% csrf_token %}
{% if quota.closed %}
{% if closed_and_sold_out %}
<div class="alert alert-info">
<button type="submit" class="btn btn-default pull-right" name="disable" value="true">
{% trans "Open quota and disable closing" %}
</button>
{% trans "This quota is sold out and closed. Even if tickets become available e.g. through cancellations, they will not become available again unless you manually re-open the quota on this page." %}
<div class="clearfix"></div>
</div>
{% else %}
<div class="alert alert-warning">
<button type="submit" class="btn btn-primary pull-right" name="reopen" value="true">{% trans "Open quota" %}</button>
{% trans "This quota is closed since it has been sold out before. Tickets are theoretically available, but will not be sold unless you manually re-open the quota." %}
<div class="clearfix"></div>
</div>
{% endif %}
{% endif %}
</form>
<div class="row" id="quota-stats">
<div class="col-md-5 col-xs-12">
<legend>{% trans "Usage overview" %}</legend>
@@ -30,7 +51,6 @@
</div>
<div class="col-md-5 col-xs-12">
<legend>{% trans "Availability calculation" %}</legend>
<div class="row">
<div class="col-xs-9">{% trans "Total quota" %}</div>
<div class="col-xs-3 text-right">

View File

@@ -24,6 +24,8 @@
{% if form.subevent %}
{% bootstrap_field form.subevent layout="control" %}
{% endif %}
</fieldset>
<fieldset>
<legend>{% trans "Items" %}</legend>
<p>
{% blocktrans trimmed %}
@@ -35,6 +37,10 @@
</p>
{% bootstrap_field form.itemvars layout="control" %}
</fieldset>
<fieldset>
<legend>{% trans "Advanced options" %}</legend>
{% bootstrap_field form.close_when_sold_out layout="control" %}
</fieldset>
<div class="form-group submit-group">
<button type="submit" class="btn btn-primary btn-save">
{% trans "Save" %}

View File

@@ -74,7 +74,7 @@
<td>{{ q.subevent.name }} {{ q.subevent.get_date_range_display }}</td>
{% endif %}
<td>{% if q.size == None %}Unlimited{% else %}{{ q.size }}{% endif %}</td>
<td>{% include "pretixcontrol/items/fragment_quota_availability.html" with availability=q.availability %}</td>
<td>{% include "pretixcontrol/items/fragment_quota_availability.html" with availability=q.availability closed=q.closed %}</td>
<td class="text-right">
<a href="{% url "control:event.items.quotas.edit" organizer=request.event.organizer.slug event=request.event.slug quota=q.id %}" class="btn btn-default btn-sm"><i class="fa fa-edit"></i></a>
<a href="{% url "control:event.items.quotas.delete" organizer=request.event.organizer.slug event=request.event.slug quota=q.id %}" class="btn btn-danger btn-sm"><i class="fa fa-trash"></i></a>