This repository has been archived by the owner on Feb 13, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Squashed merge of promotions-scheduler
- Loading branch information
Andrew Kos
committed
Jan 22, 2015
1 parent
c2061e0
commit ec8de06
Showing
21 changed files
with
1,503 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.3.16" | ||
__version__ = "0.3.17" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from rest_framework import routers | ||
|
||
from .views import PZoneViewSet | ||
|
||
|
||
api_v1_router = routers.DefaultRouter() | ||
api_v1_router.register(r"pzone", PZoneViewSet, base_name="pzone") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from django.utils.dateparse import parse_datetime | ||
|
||
|
||
class PromotionMiddleware(object): | ||
|
||
def process_template_response(self, request, response): | ||
when = None | ||
if request.method == "GET" and "pzone_preview" in request.GET: | ||
when = parse_datetime(request.GET["pzone_preview"]) | ||
|
||
if when: | ||
response.context_data["pzone_preview"] = when | ||
|
||
return response |
147 changes: 147 additions & 0 deletions
147
bulbs/promotion/migrations/0002_content_list_to_pzone.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import models, migrations | ||
import json_field.fields | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('contenttypes', '0001_initial'), | ||
('content', '0001_initial'), | ||
('promotion', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
|
||
# cleanup old models | ||
migrations.DeleteModel( | ||
name='LockOperation', | ||
), | ||
migrations.DeleteModel( | ||
name='UnlockOperation', | ||
), | ||
migrations.DeleteModel( | ||
name='InsertOperation' | ||
), | ||
migrations.DeleteModel( | ||
name='ReplaceOperation' | ||
), | ||
migrations.DeleteModel( | ||
name='ContentListOperation' | ||
), | ||
migrations.DeleteModel( | ||
name='ContentListHistory', | ||
), | ||
|
||
# fix up content list which is now pzone | ||
migrations.RenameModel( | ||
old_name='ContentList', | ||
new_name='PZone', | ||
), | ||
migrations.RenameField( | ||
model_name='pzone', | ||
old_name='length', | ||
new_name='zone_length', | ||
), | ||
|
||
# pzone operation modifications | ||
migrations.CreateModel( | ||
name='PZoneOperation', | ||
fields=[ | ||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | ||
('when', models.DateTimeField()), | ||
('applied', models.BooleanField(default=False)), | ||
], | ||
options={ | ||
'ordering': ['-when', 'id'], | ||
}, | ||
bases=(models.Model,), | ||
), | ||
migrations.AddField( | ||
model_name='pzoneoperation', | ||
name='content', | ||
field=models.ForeignKey(related_name='+', to='content.Content'), | ||
preserve_default=True, | ||
), | ||
migrations.AddField( | ||
model_name='pzoneoperation', | ||
name='polymorphic_ctype', | ||
field=models.ForeignKey(related_name='polymorphic_promotion.pzoneoperation_set', editable=False, to='contenttypes.ContentType', null=True), | ||
preserve_default=True, | ||
), | ||
migrations.AddField( | ||
model_name='pzoneoperation', | ||
name='pzone', | ||
field=models.ForeignKey(related_name='operations', to='promotion.PZone'), | ||
preserve_default=True, | ||
), | ||
|
||
# delete operation modifications | ||
migrations.CreateModel( | ||
name='DeleteOperation', | ||
fields=[ | ||
('pzoneoperation_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='promotion.PZoneOperation')), | ||
], | ||
options={ | ||
'abstract': False, | ||
}, | ||
bases=('promotion.pzoneoperation',), | ||
), | ||
|
||
# insert operation modifications | ||
migrations.CreateModel( | ||
name='InsertOperation', | ||
fields=[ | ||
('pzoneoperation_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='promotion.PZoneOperation')), | ||
], | ||
options={ | ||
'abstract': False, | ||
}, | ||
bases=('promotion.pzoneoperation',), | ||
), | ||
migrations.AddField( | ||
model_name='insertoperation', | ||
name='index', | ||
field=models.IntegerField(default=0), | ||
preserve_default=True, | ||
), | ||
|
||
# replace operation modifications | ||
migrations.CreateModel( | ||
name='ReplaceOperation', | ||
fields=[ | ||
('pzoneoperation_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='promotion.PZoneOperation')), | ||
], | ||
options={ | ||
'abstract': False, | ||
}, | ||
bases=('promotion.pzoneoperation',), | ||
), | ||
migrations.AddField( | ||
model_name='replaceoperation', | ||
name='index', | ||
field=models.IntegerField(default=0), | ||
preserve_default=True, | ||
), | ||
|
||
# pzone history modifications | ||
migrations.CreateModel( | ||
name='PZoneHistory', | ||
fields=[ | ||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | ||
('data', json_field.fields.JSONField(default=[], help_text='Enter a valid JSON object')), | ||
('date', models.DateTimeField(auto_now_add=True)), | ||
], | ||
options={ | ||
}, | ||
bases=(models.Model,), | ||
), | ||
migrations.AddField( | ||
model_name='pzonehistory', | ||
name='pzone', | ||
field=models.ForeignKey(related_name='history', to='promotion.PZone'), | ||
preserve_default=True, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import models, migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('promotion', '0002_content_list_to_pzone'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterModelOptions( | ||
name='pzone', | ||
options={'ordering': ['name']}, | ||
), | ||
migrations.AlterModelOptions( | ||
name='pzonehistory', | ||
options={'ordering': ['-date']}, | ||
), | ||
migrations.AlterModelOptions( | ||
name='pzoneoperation', | ||
options={'ordering': ['when', 'id']}, | ||
), | ||
] |
Oops, something went wrong.