Add event selection endpoint (#1827)

* Add event selection endpoint

* Minor fixes

* Add filter by gate
This commit is contained in:
Raphael Michel
2020-10-24 19:20:07 +02:00
committed by GitHub
parent 3865063b12
commit 987597b298
12 changed files with 515 additions and 7 deletions

View File

@@ -44,6 +44,11 @@ class CheckinListForm(forms.ModelForm):
widget=forms.CheckboxSelectMultiple
)
if not self.event.organizer.gates.exists():
del self.fields['gates']
else:
self.fields['gates'].queryset = self.event.organizer.gates.all()
if self.event.has_subevents:
self.fields['subevent'].queryset = self.event.subevents.all()
self.fields['subevent'].widget = Select2(
@@ -73,17 +78,22 @@ class CheckinListForm(forms.ModelForm):
'allow_multiple_entries',
'allow_entry_after_exit',
'rules',
'gates',
'exit_all_at',
]
widgets = {
'limit_products': forms.CheckboxSelectMultiple(attrs={
'data-inverse-dependency': '<[name$=all_products]'
}),
'gates': forms.CheckboxSelectMultiple(attrs={
'class': 'scrolling-multiple-choice'
}),
'auto_checkin_sales_channels': forms.CheckboxSelectMultiple(),
'exit_all_at': forms.TimeInput(attrs={'class': 'timepickerfield'}),
}
field_classes = {
'limit_products': SafeModelMultipleChoiceField,
'gates': SafeModelMultipleChoiceField,
'subevent': SafeModelChoiceField,
'exit_all_at': NextTimeField,
}
@@ -96,6 +106,11 @@ class SimpleCheckinListForm(forms.ModelForm):
super().__init__(**kwargs)
self.fields['limit_products'].queryset = self.event.items.all()
if not self.event.organizer.gates.exists():
del self.fields['gates']
else:
self.fields['gates'].queryset = self.event.organizer.gates.all()
class Meta:
model = CheckinList
localized_fields = '__all__'
@@ -105,13 +120,18 @@ class SimpleCheckinListForm(forms.ModelForm):
'limit_products',
'include_pending',
'allow_entry_after_exit',
'gates',
]
widgets = {
'limit_products': forms.CheckboxSelectMultiple(attrs={
'data-inverse-dependency': '<[name$=all_products]'
}),
'gates': forms.CheckboxSelectMultiple(attrs={
'class': 'scrolling-multiple-choice'
}),
}
field_classes = {
'limit_products': SafeModelMultipleChoiceField,
'subevent': SafeModelChoiceField,
'gates': SafeModelMultipleChoiceField,
}

View File

@@ -60,6 +60,9 @@
{% bootstrap_field form.allow_entry_after_exit layout="control" %}
{% bootstrap_field form.exit_all_at layout="control" %}
{% bootstrap_field form.auto_checkin_sales_channels layout="control" %}
{% if form.gates %}
{% bootstrap_field form.gates layout="control" %}
{% endif %}
<h3>{% trans "Custom check-in rule" %}</h3>
<div id="rules-editor" class="form-inline">

View File

@@ -509,6 +509,9 @@
{% bootstrap_field form.all_products layout="control" %}
{% bootstrap_field form.limit_products layout="control" %}
{% bootstrap_field form.allow_entry_after_exit layout="control" %}
{% if form.gates %}
{% bootstrap_field form.gates layout="control" %}
{% endif %}
</div>
</div>
{% endfor %}
@@ -538,6 +541,9 @@
{% bootstrap_field cl_formset.empty_form.all_products layout="control" %}
{% bootstrap_field cl_formset.empty_form.limit_products layout="control" %}
{% bootstrap_field cl_formset.empty_form.allow_entry_after_exit layout="control" %}
{% if cl_formset.empty_form.gates %}
{% bootstrap_field cl_formset.empty_form.gates layout="control" %}
{% endif %}
</div>
</div>
{% endescapescript %}

View File

@@ -193,6 +193,9 @@
{% bootstrap_field form.all_products layout="control" %}
{% bootstrap_field form.limit_products layout="control" %}
{% bootstrap_field form.allow_entry_after_exit layout="control" %}
{% if form.gates %}
{% bootstrap_field form.gates layout="control" %}
{% endif %}
</div>
</div>
{% endfor %}
@@ -222,6 +225,9 @@
{% bootstrap_field cl_formset.empty_form.all_products layout="control" %}
{% bootstrap_field cl_formset.empty_form.limit_products layout="control" %}
{% bootstrap_field cl_formset.empty_form.allow_entry_after_exit layout="control" %}
{% if cl_formset.empty_form.gates %}
{% bootstrap_field cl_formset.empty_form.gates layout="control" %}
{% endif %}
</div>
</div>
{% endescapescript %}