Commit 2af7195a authored by Rafal's avatar Rafal

Add data and number to promotion

parent e3f3ddf8
from App.loyaltyMe.models import Promotion from App.loyaltyMe.models import Promotion
from datetime import datetime
__author__ = 'Rafal' __author__ = 'Rafal'
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
...@@ -9,12 +10,12 @@ class Command(BaseCommand): ...@@ -9,12 +10,12 @@ class Command(BaseCommand):
def handle(self, *args, **options): def handle(self, *args, **options):
promotions = [ promotions = [
#[name, description, code, img, status] #[name, description, code, img, status]
['10%', 'Zniżka 10%', '5ac5','/static/img/photo_1.jpg' , 'New'], ['10%', 'Zniżka 10%', '5ac5','/static/img/photo_1.jpg' , 'New', '200', None, None],
['20%', 'Zniżka 20%', '5ac6','/static/img/photo_1.jpg' , 'New'], ['20%', 'Zniżka 20%', '5ac6','/static/img/photo_1.jpg' , 'New', None, None, None],
['50%', 'Zniżka 50%', '5ac7','/static/img/photo_1.jpg' , 'New'], ['50%', 'Zniżka 50%', '5ac7','/static/img/photo_1.jpg' , 'New', '0', datetime(2016, 5, 22, 11, 30, 59), datetime(2017, 12, 22, 11, 30, 59)],
] ]
print("Creating Promotions") print("Creating Promotions")
for promotion in promotions: for promotion in promotions:
print('Create {0}'.format(promotion[0])) print('Create {0}'.format(promotion[0]))
new_promotion = Promotion.objects.create(name=promotion[0], description=promotion[1], code=promotion[2], img=promotion[3], status=promotion[4]) new_promotion = Promotion.objects.create(name=promotion[0], description=promotion[1], code=promotion[2], img=promotion[3], status=promotion[4], left_number=promotion[5], start_date=promotion[6], end_date=promotion[7])
new_promotion.save() new_promotion.save()
\ No newline at end of file
...@@ -22,6 +22,10 @@ class Promotion(models.Model): ...@@ -22,6 +22,10 @@ class Promotion(models.Model):
code = models.CharField(max_length=50) code = models.CharField(max_length=50)
img = models.ImageField() img = models.ImageField()
status = models.CharField(max_length=50) status = models.CharField(max_length=50)
left_number = models.IntegerField(null=True)
start_date = models.DateField(null=True)
end_date = models.DateField(null=True)
class PromotionSet(models.Model): class PromotionSet(models.Model):
name = models.CharField(max_length=50) name = models.CharField(max_length=50)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment