addons-server/migrations/566-add-tiers.py

21 строка
542 B
Python
Исходник Обычный вид История

2013-04-19 22:21:18 +04:00
from decimal import Decimal
2013-04-22 21:41:16 +04:00
from django.db import transaction
2013-04-19 22:21:18 +04:00
from market.models import Price
2013-04-22 21:41:16 +04:00
@transaction.commit_on_success
2013-04-19 22:21:18 +04:00
def run():
print 'Adding in new tiers'
for tier in ['0.10', '0.25', '0.50', '12.49']:
2013-04-22 20:32:25 +04:00
exists = Price.uncached.filter(price=Decimal(tier)).exists()
2013-04-19 22:21:18 +04:00
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)