Allow to explicitly disable products for certain subevents

This commit is contained in:
Raphael Michel
2020-06-20 19:10:44 +02:00
parent 0aebde62eb
commit 481e29c3b2
15 changed files with 301 additions and 16 deletions

View File

@@ -99,7 +99,7 @@ class SubEventItemForm(SubEventItemOrVariationFormMixin, forms.ModelForm):
class Meta:
model = SubEventItem
fields = ['price']
fields = ['price', 'disabled']
widgets = {
'price': forms.TextInput
}
@@ -113,7 +113,7 @@ class SubEventItemVariationForm(SubEventItemOrVariationFormMixin, forms.ModelFor
class Meta:
model = SubEventItem
fields = ['price']
fields = ['price', 'disabled']
widgets = {
'price': forms.TextInput
}

View File

@@ -461,7 +461,19 @@
<fieldset>
<legend>{% trans "Item prices" %}</legend>
{% for f in itemvar_forms %}
{% bootstrap_field f.price addon_after=request.event.currency layout="control" %}
<div class="form-group">
<label class="col-md-3 control-label" for="id_{{ f.prefix }}-price">
{% if f.variation %}{{ f.item }} {{ f.variation }}{% else %}{{ f.item }}{% endif %}
<br>
<span class="optional">{% trans "Optional" %}</span>
</label>
<div class="col-md-6">
{% bootstrap_field f.price addon_after=request.event.currency form_group_class="" layout="inline" %}
</div>
<div class="col-md-3">
{% bootstrap_field f.disabled layout="inline" form_group_class="" %}
</div>
</div>
{% endfor %}
</fieldset>
<fieldset>

View File

@@ -145,7 +145,19 @@
<fieldset>
<legend>{% trans "Item prices" %}</legend>
{% for f in itemvar_forms %}
{% bootstrap_field f.price addon_after=request.event.currency layout="control" %}
<div class="form-group">
<label class="col-md-3 control-label" for="id_{{ f.prefix }}-price">
{% if f.variation %}{{ f.item }} {{ f.variation }}{% else %}{{ f.item }}{% endif %}
<br>
<span class="optional">{% trans "Optional" %}</span>
</label>
<div class="col-md-6">
{% bootstrap_field f.price addon_after=request.event.currency form_group_class="" layout="inline" %}
</div>
<div class="col-md-3">
{% bootstrap_field f.disabled layout="inline" form_group_class="" %}
</div>
</div>
{% endfor %}
</fieldset>
<fieldset>

View File

@@ -338,11 +338,11 @@ class SubEventEditorMixin(MetaDataEditorMixin):
if self.copy_from:
se_item_instances = {
sei.item_id: SubEventItem(item=sei.item, price=sei.price)
sei.item_id: SubEventItem(item=sei.item, price=sei.price, disabled=sei.disabled)
for sei in SubEventItem.objects.filter(subevent=self.copy_from).select_related('item')
}
se_var_instances = {
sei.variation_id: SubEventItemVariation(variation=sei.variation, price=sei.price)
sei.variation_id: SubEventItemVariation(variation=sei.variation, price=sei.price, disabled=sei.disabled)
for sei in SubEventItemVariation.objects.filter(subevent=self.copy_from).select_related('variation')
}