Rename flavors to variations

Add new event permissions
This commit is contained in:
Raphael Michel
2014-09-27 12:23:35 +02:00
parent a64f69ad24
commit 49efb881ce
5 changed files with 105 additions and 20 deletions

View File

@@ -5,7 +5,7 @@ from django import forms
from tixlbase.models import (
User, Organizer, OrganizerPermission, Event, EventPermission,
Property, PropertyValue, Item, ItemFlavor
Property, PropertyValue, Item, ItemVariation
)
@@ -105,16 +105,16 @@ class PropertyAdmin(admin.ModelAdmin):
search_fields = ('name', 'event')
class ItemFlavorInline(admin.TabularInline):
class ItemVariationInline(admin.TabularInline):
model = ItemFlavor
model = ItemVariation
extra = 4
class ItemAdmin(admin.ModelAdmin):
model = Item
inlines = [ItemFlavorInline]
inlines = [ItemVariationInline]
list_display = ('name', 'event', 'category')
search_fields = ('name', 'event', 'category', 'short_description')

View File

@@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('tixlbase', '0009_auto_20140916_2120'),
]
operations = [
migrations.RemoveField(
model_name='itemflavor',
name='prop',
),
migrations.AddField(
model_name='eventpermission',
name='can_change_items',
field=models.BooleanField(verbose_name='Can change item settings', default=True),
preserve_default=True,
),
migrations.AddField(
model_name='itemflavor',
name='values',
field=models.ManyToManyField(to='tixlbase.PropertyValue', related_name='flavors'),
preserve_default=True,
),
]

View File

@@ -0,0 +1,49 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('tixlbase', '0010_auto_20140927_1006'),
]
operations = [
migrations.CreateModel(
name='ItemVariation',
fields=[
('id', models.AutoField(serialize=False, primary_key=True, verbose_name='ID', auto_created=True)),
('active', models.BooleanField(default=True)),
('default_price', models.DecimalField(max_digits=7, decimal_places=2, blank=True, null=True, verbose_name='Default price')),
('item', models.ForeignKey(related_name='variations', to='tixlbase.Item')),
('values', models.ManyToManyField(related_name='variations', to='tixlbase.PropertyValue')),
],
options={
},
bases=(models.Model,),
),
migrations.RemoveField(
model_name='itemflavor',
name='item',
),
migrations.RemoveField(
model_name='itemflavor',
name='values',
),
migrations.DeleteModel(
name='ItemFlavor',
),
migrations.AlterField(
model_name='item',
name='category',
field=models.ForeignKey(null=True, blank=True, on_delete=django.db.models.deletion.PROTECT, related_name='items', to='tixlbase.ItemCategory'),
),
migrations.AlterField(
model_name='item',
name='event',
field=models.ForeignKey(to='tixlbase.Event', on_delete=django.db.models.deletion.PROTECT, related_name='items'),
),
]

View File

@@ -309,6 +309,10 @@ class EventPermission(models.Model):
default=True,
verbose_name=_("Can change event settings")
)
can_change_items = models.BooleanField(
default=True,
verbose_name=_("Can change item settings")
)
def __str__(self):
return _("%(name)s on %(object)s") % {
@@ -400,11 +404,13 @@ class Item(models.Model):
"""
event = models.ForeignKey(
Event,
on_delete=models.PROTECT
on_delete=models.PROTECT,
related_name="items",
)
category = models.ForeignKey(
ItemCategory,
on_delete=models.PROTECT,
related_name="items",
blank=True, null=True
)
name = models.CharField(
@@ -450,32 +456,32 @@ class Item(models.Model):
verbose_name_plural = _("Items")
class ItemFlavor(models.Model):
class ItemVariation(models.Model):
"""
A flavor is an item combined with values for all properties
A variation is an item combined with values for all properties
associated with the item. For example, if your item is 'T-Shirt'
and your properties are 'Size' and 'Color', then an example for a
flavor would be 'T-Shirt XL read'.
variation would be 'T-Shirt XL read'.
Attention: _ALL_ combinations of PropertyValues _ALWAYS_ exist,
even if there is no ItemFlavor object for them! ItemFlavor objects
even if there is no ItemVariation object for them! ItemVariation objects
do NOT prove existance, they are only available to make it possible
to override default values (like the price) for certain combinations
of property values.
They also allow to explicitly EXCLUDE certain combinations of property
values by creating an ItemFlavor object for them with active set to
values by creating an ItemVariation object for them with active set to
False.
Restrictions can be not only set to items but also directly to flavors.
Restrictions can be not only set to items but also directly to variation.
"""
item = models.ForeignKey(
Item,
related_name='flavors'
related_name='variations'
)
values = models.ManyToManyField(
PropertyValue,
related_name='flavors',
related_name='variations',
)
active = models.BooleanField(
default=True,