Fix #473 -- Internal name for categories and products (#900)

* Fix #473 -- Internal name for categories and products

* fix pdf renderer
This commit is contained in:
Raphael Michel
2018-05-11 12:53:25 +02:00
committed by GitHub
parent e678b52a7e
commit edeaa1333b
30 changed files with 152 additions and 55 deletions

View File

@@ -27,6 +27,7 @@ class CategoryForm(I18nModelForm):
localized_fields = '__all__'
fields = [
'name',
'internal_name',
'description',
'is_addon'
]
@@ -90,9 +91,9 @@ class QuotaForm(I18nModelForm):
for item in items:
if len(item.variations.all()) > 0:
for v in item.variations.all():
choices.append(('{}-{}'.format(item.pk, v.pk), '{} {}'.format(item.name, v.value)))
choices.append(('{}-{}'.format(item.pk, v.pk), '{} {}'.format(item, v.value)))
else:
choices.append(('{}'.format(item.pk), item.name))
choices.append(('{}'.format(item.pk), str(item)))
self.fields['itemvars'] = forms.MultipleChoiceField(
label=_('Products'),
@@ -282,6 +283,7 @@ class ItemCreateForm(I18nModelForm):
localized_fields = '__all__'
fields = [
'name',
'internal_name',
'category',
'admission',
'default_price',
@@ -308,6 +310,7 @@ class ItemUpdateForm(I18nModelForm):
fields = [
'category',
'name',
'internal_name',
'active',
'admission',
'description',

View File

@@ -144,7 +144,7 @@ class OrderPositionAddForm(forms.Form):
choices = []
for i in order.event.items.prefetch_related('variations').all():
pname = str(i.name)
pname = str(i)
if not i.is_available():
pname += ' ({})'.format(_('inactive'))
variations = list(i.variations.all())
@@ -243,7 +243,7 @@ class OrderPositionChangeForm(forms.Form):
choices = []
for i in instance.order.event.items.prefetch_related('variations').all():
pname = str(i.name)
pname = str(i)
if not i.is_available():
pname += ' ({})'.format(_('inactive'))
variations = list(i.variations.all())

View File

@@ -102,7 +102,7 @@ class SubEventItemForm(SubEventItemOrVariationFormMixin, forms.ModelForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['price'].widget.attrs['placeholder'] = money_filter(self.item.default_price, self.item.event.currency, hide_currency=True)
self.fields['price'].label = str(self.item.name)
self.fields['price'].label = str(self.item)
class Meta:
model = SubEventItem
@@ -116,7 +116,7 @@ class SubEventItemVariationForm(SubEventItemOrVariationFormMixin, forms.ModelFor
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['price'].widget.attrs['placeholder'] = money_filter(self.variation.price, self.item.event.currency, hide_currency=True)
self.fields['price'].label = '{} {}'.format(str(self.item.name), self.variation.value)
self.fields['price'].label = '{} {}'.format(str(self.item), self.variation.value)
class Meta:
model = SubEventItem

View File

@@ -86,13 +86,13 @@ class VoucherForm(I18nModelForm):
itemid, varid = iv.split('-')
i = self.instance.event.items.get(pk=itemid)
v = i.variations.get(pk=varid)
choices.append(('%d-%d' % (i.pk, v.pk), '%s %s' % (i.name, v.value)))
choices.append(('%d-%d' % (i.pk, v.pk), '%s %s' % (str(i), v.value)))
elif iv:
i = self.instance.event.items.get(pk=iv)
if i.variations.exists():
choices.append((str(i.pk), _('{product} Any variation').format(product=i.name)))
choices.append((str(i.pk), _('{product} Any variation').format(product=i)))
else:
choices.append((str(i.pk), str(i.name)))
choices.append((str(i.pk), str(i)))
self.fields['itemvar'].choices = choices
self.fields['itemvar'].widget = Select2ItemVarQuota(