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(

View File

@@ -90,7 +90,7 @@
<span class="label label-warning">{% trans "unpaid" %}</span>
{% endif %}
</td>
<td>{{ e.item.name }}{% if e.variation %} {{ e.variation }}{% endif %}</td>
<td>{{ e.item }}{% if e.variation %} {{ e.variation }}{% endif %}</td>
<td>{{ e.order.email }}</td>
<td>
{% if e.addon_to %}

View File

@@ -42,7 +42,7 @@
<ul class="nav nav-second-level">
<li>
<a href="{% url 'control:event.items' organizer=request.event.organizer.slug event=request.event.slug %}"
{% if "event.items" == url_name or "event.item." in url_name or url_name == "event.item" %}class="active"{% endif %}>
{% if "event.items" == url_name or "event.item." in url_name or "event.items.add" == url_name or url_name == "event.item" %}class="active"{% endif %}>
{% trans "Products" %}</a>
</li>
<li>

View File

@@ -10,6 +10,9 @@
<fieldset>
<legend>{% trans "General information" %}</legend>
{% bootstrap_field form.name layout="control" %}
<div class="internal-name-wrapper">
{% bootstrap_field form.internal_name layout="control" %}
</div>
{% bootstrap_field form.copy_from layout="control" %}
{% bootstrap_field form.has_variations layout="control" %}
{% bootstrap_field form.category layout="control" %}

View File

@@ -9,6 +9,9 @@
<fieldset>
<legend>{% trans "General information" %}</legend>
{% bootstrap_field form.name layout="control" %}
<div class="internal-name-wrapper">
{% bootstrap_field form.internal_name layout="control" %}
</div>
{% bootstrap_field form.active layout="control" %}
{% bootstrap_field form.category layout="control" %}
{% bootstrap_field form.admission layout="control" %}

View File

@@ -12,6 +12,9 @@
<fieldset>
<legend>{% trans "General information" %}</legend>
{% bootstrap_field form.name layout="control" %}
<div class="internal-name-wrapper">
{% bootstrap_field form.internal_name layout="control" %}
</div>
{% bootstrap_field form.description layout="control" %}
{% bootstrap_field form.is_addon layout="control" %}
</fieldset>

View File

@@ -48,7 +48,7 @@
<td><strong>
{% if not i.active %}<strike>{% endif %}
<a href="
{% url "control:event.item" organizer=request.event.organizer.slug event=request.event.slug item=i.id %}">{{ i.name }}</a>
{% url "control:event.item" organizer=request.event.organizer.slug event=request.event.slug item=i.id %}">{{ i }}</a>
{% if not i.active %}</strike>{% endif %}
</strong>
</td>

View File

@@ -53,7 +53,7 @@
<td>
<ul>
{% for item in q.items.all %}
<li><a href="{% url "control:event.item" organizer=request.event.organizer.slug event=request.event.slug item=item.id %}">{{ item.name }}</a></li>
<li><a href="{% url "control:event.item" organizer=request.event.organizer.slug event=request.event.slug item=item.id %}">{{ item }}</a></li>
{% endfor %}
</ul>
</td>

View File

@@ -60,7 +60,7 @@
<td>
<ul>
{% for item in q.items.all %}
<li><a href="{% url "control:event.item" organizer=request.event.organizer.slug event=request.event.slug item=item.id %}">{{ item.name }}</a></li>
<li><a href="{% url "control:event.item" organizer=request.event.organizer.slug event=request.event.slug item=item.id %}">{{ item }}</a></li>
{% endfor %}
</ul>
</td>

View File

@@ -57,7 +57,7 @@
<div class="panel-heading">
<h3 class="panel-title">
#{{ position.positionid }}
<strong>{{ position.item.name }}</strong>
<strong>{{ position.item }}</strong>
{% if position.variation %}
{{ position.variation }}
{% endif %}

View File

@@ -39,7 +39,7 @@
<details class="panel panel-default" open>
<summary class="panel-heading">
<h4 class="panel-title">
<strong>{{ pos.item.name }}{% if pos.variation %}
<strong>{{ pos.item }}{% if pos.variation %}
{{ pos.variation }}
{% endif %}</strong>
<i class="fa fa-angle-down collapse-indicator"></i>

View File

@@ -189,7 +189,7 @@
{% else %}
#{{ line.positionid }}
{% endif %}
<strong>{{ line.item.name }}</strong>
<strong>{{ line.item }}</strong>
{% if line.variation %}
{{ line.variation }}
{% endif %}

View File

@@ -49,7 +49,7 @@
{% for tup in items_by_category %}
{% if tup.0 %}
<tr class="category">
<th>{{ tup.0.name }}</th>
<th>{{ tup.0 }}</th>
<th>{{ tup.0.num_canceled|togglesum:request.event.currency }}</th>
<th>{{ tup.0.num_refunded|togglesum:request.event.currency }}</th>
<th>{{ tup.0.num_expired|togglesum:request.event.currency }}</th>
@@ -60,7 +60,7 @@
{% endif %}
{% for item in tup.1 %}
<tr class="item {% if tup.0 %}categorized{% endif %}">
<td>{{ item.name }}</td>
<td>{{ item }}</td>
<td>
<a href="{{ listurl }}?item={{ item.id }}&amp;status=c&amp;provider={{ item.provider }}">
{{ item.num_canceled|togglesum:request.event.currency }}

View File

@@ -90,7 +90,7 @@
{% for item in items %}
<option value="{{ item.id }}"
{% if request.GET.item|add:0 == item.id %}selected="selected"{% endif %}>
{{ item.name }}
{{ item }}
</option>
{% endfor %}
</select>

View File

@@ -197,12 +197,16 @@ def itemvarquota_select2(request, **kwargs):
dt_end = make_aware(datetime.combine(dt.date(), time(hour=23, minute=59, second=59)), tz)
quotaf |= Q(subevent__date_from__gte=dt_start) & Q(subevent__date_from__lte=dt_end)
itemqs = request.event.items.prefetch_related('variations').filter(name__icontains=i18ncomp(query))
itemqs = request.event.items.prefetch_related('variations').filter(
Q(name__icontains=i18ncomp(query)) | Q(internal_name__icontains=query)
)
quotaqs = request.event.quotas.filter(quotaf).select_related('subevent')
more = False
else:
if page == 1:
itemqs = request.event.items.prefetch_related('variations').filter(name__icontains=i18ncomp(query))
itemqs = request.event.items.prefetch_related('variations').filter(
Q(name__icontains=i18ncomp(query)) | Q(internal_name__icontains=query)
)
else:
itemqs = request.event.items.none()
quotaqs = request.event.quotas.filter(name__icontains=query).select_related('subevent')
@@ -215,11 +219,11 @@ def itemvarquota_select2(request, **kwargs):
for i in itemqs:
variations = list(i.variations.all())
if variations:
choices.append((str(i.pk), _('{product} Any variation').format(product=i.name), ''))
choices.append((str(i.pk), _('{product} Any variation').format(product=i), ''))
for v in variations:
choices.append(('%d-%d' % (i.pk, v.pk), '%s %s' % (i.name, v.value), ''))
choices.append(('%d-%d' % (i.pk, v.pk), '%s %s' % (i, v.value), ''))
else:
choices.append((str(i.pk), i.name, ''))
choices.append((str(i.pk), str(i), ''))
for q in quotaqs:
if request.event.has_subevents:
choices.append(('q-%d' % q.pk,