add management command

pull/1/head
eric 2016-03-25 23:44:18 -04:00
parent a8ab510c61
commit ab0c8814b4
1 changed files with 14 additions and 0 deletions

View File

@ -0,0 +1,14 @@
from django.core.management.base import BaseCommand
from regluit.core.models import Campaign
class Command(BaseCommand):
help = "set campaign edition for every campaign"
def handle(self, **options):
fixed = 0
for campaign in Campaign.objects.all():
if not campaign.edition:
campaign.edition = campaign.work.editions.all()[0]
campaign.save()
fixed +=1
print "{} campaign editions set".format(fixed)