second patch on eboutic

This commit is contained in:
Thomas Girod
2022-11-16 20:41:24 +01:00
parent 96510b270d
commit 60eff1000f
6 changed files with 106 additions and 81 deletions

View File

@ -0,0 +1,18 @@
# Generated by Django 3.2.15 on 2022-11-16 18:35
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("counter", "0017_studentcard"),
]
operations = [
migrations.AddField(
model_name="producttype",
name="priority",
field=models.PositiveIntegerField(default=0),
),
]

View File

@ -133,8 +133,13 @@ class ProductType(models.Model):
comment = models.TextField(_("comment"), null=True, blank=True)
icon = models.ImageField(upload_to="products", null=True, blank=True)
# priority holds no real backend logic but helps to handle the order in which
# the items are to be shown to the user
priority = models.PositiveIntegerField(default=0)
class Meta:
verbose_name = _("product type")
ordering = ["-priority", "name"]
def is_owned_by(self, user):
"""

View File

@ -954,7 +954,7 @@ class ProductTypeCreateView(CounterAdminTabsMixin, CounterAdminMixin, CreateView
"""
model = ProductType
fields = ["name", "description", "comment", "icon"]
fields = ["name", "description", "comment", "icon", "priority"]
template_name = "core/create.jinja"
current_tab = "products"
@ -966,7 +966,7 @@ class ProductTypeEditView(CounterAdminTabsMixin, CounterAdminMixin, UpdateView):
model = ProductType
template_name = "core/edit.jinja"
fields = ["name", "description", "comment", "icon"]
fields = ["name", "description", "comment", "icon", "priority"]
pk_url_kwarg = "type_id"
current_tab = "products"