forked from CGM_Public/pretix_original
Change data model to versioned tables
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('tixlbase', '0015_auto_20141006_2205'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='TimeRestriction',
|
||||
fields=[
|
||||
('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)),
|
||||
('timeframe_from', models.DateTimeField(verbose_name='Start of time frame')),
|
||||
('timeframe_to', models.DateTimeField(verbose_name='End of time frame')),
|
||||
('price', models.DecimalField(max_digits=7, verbose_name='Price in time frame', decimal_places=2, null=True, blank=True)),
|
||||
('event', models.ForeignKey(related_name='restrictions_timerestriction_timerestriction', to='tixlbase.Event', verbose_name='Event')),
|
||||
('items', models.ManyToManyField(to='tixlbase.Item', related_name='restrictions_timerestriction_timerestriction')),
|
||||
('variations', models.ManyToManyField(to='tixlbase.ItemVariation', related_name='restrictions_timerestriction_timerestriction')),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
'verbose_name_plural': 'Restrictions',
|
||||
'verbose_name': 'Restriction',
|
||||
},
|
||||
bases=(models.Model,),
|
||||
),
|
||||
]
|
||||
@@ -1,30 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('tixlbase', '0016_event_plugins'),
|
||||
('timerestriction', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='timerestriction',
|
||||
name='items',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='timerestriction',
|
||||
name='i',
|
||||
field=models.ForeignKey(null=True, blank=True, related_name='restrictions_timerestriction_timerestriction', to='tixlbase.Item'),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='timerestriction',
|
||||
name='variations',
|
||||
field=models.ManyToManyField(blank=True, related_name='restrictions_timerestriction_timerestriction', to='tixlbase.ItemVariation'),
|
||||
),
|
||||
]
|
||||
@@ -1,19 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('timerestriction', '0002_auto_20141013_1811'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='timerestriction',
|
||||
old_name='i',
|
||||
new_name='item',
|
||||
),
|
||||
]
|
||||
@@ -1,25 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
import tixlbase.models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('timerestriction', '0003_auto_20141013_1811'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='timerestriction',
|
||||
name='item',
|
||||
field=models.ForeignKey(null=True, blank=True, related_name='restrictions_timerestriction_timerestriction', to='tixlbase.Item', verbose_name='Item'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='timerestriction',
|
||||
name='variations',
|
||||
field=tixlbase.models.VariationsField(related_name='restrictions_timerestriction_timerestriction', to='tixlbase.ItemVariation', blank=True, verbose_name='Variations'),
|
||||
),
|
||||
]
|
||||
@@ -20,7 +20,7 @@ def availability_handler(sender, **kwargs):
|
||||
context = kwargs['context'] # NOQA
|
||||
|
||||
# Fetch all restriction objects applied to this item
|
||||
restrictions = list(TimeRestriction.objects.filter(
|
||||
restrictions = list(TimeRestriction.objects.current.filter(
|
||||
item=item,
|
||||
).prefetch_related('variations'))
|
||||
|
||||
@@ -79,7 +79,7 @@ def availability_handler(sender, **kwargs):
|
||||
|
||||
# Walk through all restriction objects applied to this item
|
||||
for restriction in restrictions:
|
||||
applied_to = list(restriction.variations.all())
|
||||
applied_to = list(restriction.variations.current.all())
|
||||
|
||||
# Only take this restriction into consideration if it either
|
||||
# is directly applied to this variation OR is applied to all
|
||||
|
||||
Reference in New Issue
Block a user