Allow to adjust the order of products (closes #60)

This commit is contained in:
Raphael Michel
2015-06-03 00:48:35 +02:00
parent f68132f006
commit 3114e2d959
6 changed files with 105 additions and 9 deletions

View File

@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import django.core.validators
class Migration(migrations.Migration):
dependencies = [
('pretixbase', '0002_auto_20150524_1148'),
]
operations = [
migrations.AlterModelOptions(
name='item',
options={'verbose_name_plural': 'Products', 'ordering': ('category__position', 'category', 'position'), 'verbose_name': 'Product'},
),
migrations.AddField(
model_name='item',
name='position',
field=models.IntegerField(default=0),
),
migrations.AlterField(
model_name='organizer',
name='slug',
field=models.SlugField(help_text='Should be short, only contain lowercase letters and numbers, and must be unique among your events. This is being used in addresses and bank transfer references.', validators=[django.core.validators.RegexValidator(message='The slug may only contain letters, numbers, dots and dashes.', regex='^[a-zA-Z0-9.-]+$')], verbose_name='Slug'),
),
]

View File

@@ -860,10 +860,14 @@ class Item(Versionable):
),
default=False
)
position = models.IntegerField(
default=0
)
class Meta:
verbose_name = _("Product")
verbose_name_plural = _("Products")
ordering = ("category__position", "category", "position")
def __str__(self):
return str(self.name)