Add "attention" flag to products

This commit is contained in:
Raphael Michel
2017-08-25 15:14:54 +02:00
parent f98f25fb6b
commit fd35b5ea72
9 changed files with 69 additions and 6 deletions

View File

@@ -42,7 +42,7 @@ class ItemSerializer(I18nAwareModelSerializer):
'default_price', 'free_price', 'tax_rate', 'tax_rule', 'admission',
'position', 'picture', 'available_from', 'available_until',
'require_voucher', 'hide_without_voucher', 'allow_cancel',
'min_per_order', 'max_per_order', 'has_variations',
'min_per_order', 'max_per_order', 'checkin_attention', 'has_variations',
'variations', 'addons')

File diff suppressed because one or more lines are too long

View File

@@ -159,6 +159,8 @@ class Item(LoggedModel):
:type max_per_order: int
:param min_per_order: Minimum number of times this item needs to be in an order if bought at all. None for unlimited.
:type min_per_order: int
:param checkin_attention: Requires special attention at checkin
:type checkin_attention: bool
"""
event = models.ForeignKey(
@@ -266,6 +268,13 @@ class Item(LoggedModel):
'empty or set it to 0, there is no special limit for this product. The limit for the maximum '
'number of items in the whole order applies regardless.')
)
checkin_attention = models.BooleanField(
verbose_name=_('Requires special attention'),
default=False,
help_text=_('If you set this, the check-in app will show a visible warning that this ticket requires special '
'attention. You can use this for example for student tickets to indicate to the person at '
'check-in that the student ID card still needs to be checked.')
)
# !!! Attention: If you add new fields here, also add them to the copying code in
# pretix/control/views/item.py if applicable.

View File

@@ -194,6 +194,7 @@ class ItemCreateForm(I18nModelForm):
self.instance.allow_cancel = self.cleaned_data['copy_from'].allow_cancel
self.instance.min_per_order = self.cleaned_data['copy_from'].min_per_order
self.instance.max_per_order = self.cleaned_data['copy_from'].max_per_order
self.instance.checkin_attention = self.cleaned_data['copy_from'].checkin_attention
self.instance.position = (self.event.items.aggregate(p=Max('position'))['p'] or 0) + 1
instance = super().save(*args, **kwargs)
@@ -283,6 +284,7 @@ class ItemUpdateForm(I18nModelForm):
'allow_cancel',
'max_per_order',
'min_per_order',
'checkin_attention'
]
widgets = {
'available_from': forms.DateTimeInput(attrs={'class': 'datetimepicker'}),

View File

@@ -31,6 +31,10 @@
{% bootstrap_field form.hide_without_voucher layout="horizontal" %}
{% bootstrap_field form.allow_cancel layout="horizontal" %}
</fieldset>
<fieldset>
<legend>{% trans "Check-in" %}</legend>
{% bootstrap_field form.checkin_attention layout="horizontal" %}
</fieldset>
</div>
<div class="col-xs-12 col-lg-2">
<div class="panel panel-default">

View File

@@ -178,6 +178,7 @@ def serialize_op(op):
'variation': str(op.variation) if op.variation else None,
'variation_id': op.variation_id,
'attendee_name': name,
'attention': op.item.checkin_attention,
'redeemed': bool(op.checkin_cnt),
'paid': op.order.status == Order.STATUS_PAID,
}

View File

@@ -74,6 +74,7 @@ TEST_ITEM_RES = {
"allow_cancel": True,
"min_per_order": None,
"max_per_order": None,
"checkin_attention": False,
"has_variations": False,
"variations": [],
"addons": []