Quota form: Change item selection field per context (#3839)

* Change item checkbox select to multiselect widget

* Make item selection widget dependent on count

* Make item selection widget dependent on variable

* Adjust widget choices

* Fix widget choices

* Fix item variation key errors

* Simplify code

* Fix classname

* Improve argument name

* Fix widget name
This commit is contained in:
Phin Wolkwitz
2024-02-08 09:33:39 +01:00
committed by GitHub
parent 2b72cfdaff
commit 39f9329207
7 changed files with 86 additions and 9 deletions

View File

@@ -77,3 +77,19 @@ class Select2ItemVarQuotaMixin(Select2Mixin):
class Select2ItemVarQuota(Select2ItemVarQuotaMixin, forms.Select):
pass
class Select2ItemVarMulti(Select2Mixin, forms.SelectMultiple):
def options(self, name, value, attrs=None):
# we need this for multi-selection without a queryset for the selection of items and variations
for i, v in enumerate(value):
yield self.create_option(
None,
v,
dict(self.choices)[v],
True,
i,
subindex=None,
attrs=attrs
)
return