Commit b4353328 authored by lizonr1's avatar lizonr1

Add user_promotions

parent a7a55a9f
...@@ -16,3 +16,4 @@ class Command(BaseCommand): ...@@ -16,3 +16,4 @@ class Command(BaseCommand):
call_command('init_promotionsets') call_command('init_promotionsets')
call_command('init_localizations') call_command('init_localizations')
call_command('init_places') call_command('init_places')
call_command('init_userpromotions')
from django.contrib.auth.models import User
from App.loyaltyMe.models import Place, Promotion
from App.user.models import UserPromotion
from django.core.management.base import BaseCommand
class Command(BaseCommand):
help = 'Closes the specified poll for voting'
def handle(self, *args, **options):
user_promotions = [
# user = models.ForeignKey(User, related_name='user_promotion',
# blank=False, null=False, default=None)
# place = models.ForeignKey(Place)
# promotion = models.ForeignKey(Promotion)
# status = models.CharField(max_length=30)
# code = models.CharField(max_length=20)
['Klaudia', 'Kocia Kawiarnia', '10%', 'used', 'abcd'],
['Klaudia', 'Kafcia u Olczaka', '20%', 'in_progress', None],
['Antek', 'Kafcia u Olczaka', '50%', 'in_progress', None],
['admin', 'Kafcia u Olczaka', '10%', 'in_progress', None],
]
print("Creating Awards")
for user_promotion in user_promotions:
print('Create {0}'.format(user_promotion[0]))
user = User.objects.filter(username=user_promotion[0])[0]
place = Place.objects.filter(name=user_promotion[1])[0]
promotion = Promotion.objects.filter(name=user_promotion[2])[0]
new_user_promotion = UserPromotion.objects.create(user=user, place=place, promotion=promotion
, status=user_promotion[3], code=user_promotion[4])
new_user_promotion.save()
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