mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-10 03:49:24 +00:00
second patch on eboutic
This commit is contained in:
18
counter/migrations/0018_producttype_priority.py
Normal file
18
counter/migrations/0018_producttype_priority.py
Normal 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),
|
||||
),
|
||||
]
|
@ -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):
|
||||
"""
|
||||
|
@ -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"
|
||||
|
||||
|
Reference in New Issue
Block a user