Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
update tiers (bug 863491)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy McKay committed Apr 19, 2013
1 parent c47caf1 commit bc86379
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions migrations/566-add-tiers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from decimal import Decimal

from market.models import Price


def run():
print 'Adding in new tiers'
for tier in ['0.10', '0.25', '0.50', '12.49']:
exists = Price.objects.filter(price=Decimal(tier)).exists()
if exists:
print 'Tier already exists, skipping: %s' % tier
continue

print 'Created tier: %s' % tier
Price.objects.create(name='Tier 0', price=Decimal(tier),
active=True)

print 'Removing old tiers'
for tier in ['5.99', '7.99', '8.99', '10.99', '11.99', '12.99', '13.99',
'15.99', '16.99', '17.99', '18.99', '20.99', '21.99', '22.99',
'23.99', '34.99', '44.99']:
try:
Price.objects.get(price=Decimal(tier)).update(active=False)
print 'Deactivating tier: %s' % tier
except Price.DoesNotExist:
print 'Tier does not exist, skipping: %s' % tier

print 'Renaming tiers'
for k, tier in enumerate(Price.objects.filter(active=True)
.order_by('price')):
new = 'Tier %s' % k
print 'Renaming %s to %s' % (tier.name, new)
tier.name = new
tier.save()

0 comments on commit bc86379

Please sign in to comment.