migration, show category type in ui

This commit is contained in:
Mira Weller
2024-05-28 19:50:28 +02:00
parent a0d865cf4f
commit 97925e2d77
3 changed files with 41 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
# Generated by Django 4.2.11 on 2024-05-27 13:19
from django.db import migrations, models
import pretix.base.models.orders
class Migration(migrations.Migration):
dependencies = [
("pretixbase", "0264_order_internal_secret"),
]
operations = [
migrations.AddField(
model_name="itemcategory",
name="cross_selling_condition",
field=models.CharField(null=True),
),
migrations.AddField(
model_name="itemcategory",
name="cross_selling_mode",
field=models.CharField(null=True),
),
migrations.AddField(
model_name="itemcategory",
name="cross_selling_match_products",
field=models.ManyToManyField(
related_name="matched_by_cross_selling_categories", to="pretixbase.item"
),
),
]

View File

@@ -158,6 +158,8 @@ class ItemCategory(LoggedModel):
name = self.internal_name or self.name
if self.is_addon:
return _('{category} (Add-On products)').format(category=str(name))
if self.cross_selling_mode is not None:
return _('{category} ({category_type})').format(category=str(name), category_type=self.get_cross_selling_mode_display())
return str(name)
def get_category_type_display(self):

View File

@@ -31,6 +31,7 @@
<thead>
<tr>
<th>{% trans "Product categories" %}</th>
<th>{% trans "Category type" %}</th>
<th class="action-col-2"></th>
</tr>
</thead>
@@ -40,6 +41,13 @@
<td>
<strong><a href="{% url "control:event.items.categories.edit" organizer=request.event.organizer.slug event=request.event.slug category=c.id %}">{{ c.internal_name|default:c.name }}</a></strong>
</td>
<td>
{% if c.is_addon %}{% trans "Add-on product category" %}
{% elif c.cross_selling_mode is None %}{% trans "Normal category" %}
{% elif c.cross_selling_mode == 'both' %}{% trans "Combined category" %}
{% elif c.cross_selling_mode == 'only' %}{% trans "Cross-selling category" %}
{% endif %}
</td>
<td class="text-right flip">
<button title="{% trans "Move up" %}" formaction="{% url "control:event.items.categories.up" organizer=request.event.organizer.slug event=request.event.slug category=c.id %}" class="btn btn-default btn-sm sortable-up"{% if forloop.counter0 == 0 and not page_obj.has_previous %} disabled{% endif %}><i class="fa fa-arrow-up"></i></button>
<button title="{% trans "Move down" %}" formaction="{% url "control:event.items.categories.down" organizer=request.event.organizer.slug event=request.event.slug category=c.id %}" class="btn btn-default btn-sm sortable-down"{% if forloop.revcounter0 == 0 and not page_obj.has_next %} disabled{% endif %}><i class="fa fa-arrow-down"></i></button>