Add Item.allow_waitinglist

This commit is contained in:
Raphael Michel
2019-07-29 16:27:27 +02:00
parent c60d1c8a5d
commit ad8f109e77
9 changed files with 44 additions and 4 deletions

View File

@@ -119,7 +119,7 @@ class ItemSerializer(I18nAwareModelSerializer):
'require_voucher', 'hide_without_voucher', 'allow_cancel', 'require_bundling',
'min_per_order', 'max_per_order', 'checkin_attention', 'has_variations', 'variations',
'addons', 'bundles', 'original_price', 'require_approval', 'generate_tickets',
'show_quota_left', 'hidden_if_available')
'show_quota_left', 'hidden_if_available', 'allow_waitinglist')
read_only_fields = ('has_variations', 'picture')
def get_serializer_context(self):

View File

@@ -0,0 +1,21 @@
# Generated by Django 2.2.1 on 2019-07-29 14:22
import django.db.models.deletion
from django.db import migrations, models
import pretix.base.models.fields
class Migration(migrations.Migration):
dependencies = [
('pretixbase', '0130_auto_20190729_1311'),
]
operations = [
migrations.AddField(
model_name='item',
name='allow_waitinglist',
field=models.BooleanField(default=True),
),
]

View File

@@ -311,6 +311,11 @@ class Item(LoggedModel):
verbose_name=_("Generate tickets"),
blank=True, null=True,
)
allow_waitinglist = models.BooleanField(
verbose_name=_("Show a waiting list for this ticket"),
help_text=_("This will only work of waiting lists are enabled for this event."),
default=True
)
show_quota_left = models.NullBooleanField(
verbose_name=_("Show number of tickets left"),
help_text=_("Publicly show how many tickets are still available."),

View File

@@ -437,6 +437,7 @@ class ItemUpdateForm(I18nModelForm):
'require_approval',
'hide_without_voucher',
'allow_cancel',
'allow_waitinglist',
'max_per_order',
'min_per_order',
'checkin_attention',

View File

@@ -40,6 +40,7 @@
{% bootstrap_field form.hide_without_voucher layout="control" %}
{% bootstrap_field form.require_bundling layout="control" %}
{% bootstrap_field form.allow_cancel layout="control" %}
{% bootstrap_field form.allow_waitinglist layout="control" %}
</fieldset>
{% for v in formsets.values %}
<fieldset>

View File

@@ -3,7 +3,7 @@
{% if avail <= 10 %}
<div class="col-md-2 col-xs-6 availability-box gone">
<strong>{% trans "SOLD OUT" %}</strong>
{% if event.settings.waiting_list_enabled %}
{% if event.settings.waiting_list_enabled and item.allow_waitinglist %}
<br/>
<a href="{% eventurl event "presale:event.waitinglist" cart_namespace=cart_namespace|default_if_none:"" %}?item={{ item.pk }}{% if var %}&var={{ var.pk }}{% endif %}{% if subevent %}&subevent={{ subevent.pk }}{% endif %}">
<span class="fa fa-plus-circle"></span>
@@ -17,7 +17,7 @@
<span class="fa fa-info-circle" data-toggle="tooltip"
title="{% trans "All remaining products are reserved but might become available again." %}"></span>
</strong>
{% if event.settings.waiting_list_enabled %}
{% if event.settings.waiting_list_enabled and item.allow_waitinglist %}
<br/>
<a href="{% eventurl event "presale:event.waitinglist" cart_namespace=cart_namespace|default_if_none:"" %}?item={{ item.pk }}{% if var %}&var={{ var.pk }}{% endif %}{% if subevent %}&subevent={{ subevent.pk }}{% endif %}">
<span class="fa fa-plus-circle"></span>

View File

@@ -81,6 +81,10 @@ class WaitingView(EventViewMixin, FormView):
messages.error(request, _("We could not identify the product you selected."))
return redirect(self.get_index_url())
if not self.item_and_variation[0].allow_waitinglist:
messages.error(request, _("The waiting list is disabled for this product."))
return redirect(self.get_index_url())
self.subevent = None
if request.event.has_subevents:
if 'subevent' in request.GET: