2012-12-19 16:00:33 +00:00
|
|
|
"""
|
|
|
|
one-time command to ensure transaction.ack_name for OLA returns something sensible
|
|
|
|
see https://github.com/Gluejar/regluit/pull/97#discussion_r2436193
|
|
|
|
"""
|
|
|
|
|
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
from regluit.core.models import Campaign
|
|
|
|
from regluit.payment.models import Transaction
|
|
|
|
|
|
|
|
class Command(BaseCommand):
|
|
|
|
help = "make sure transaction.ack_name returns something sensible for OLA transactions"
|
|
|
|
|
|
|
|
def handle(self, **options):
|
|
|
|
ola_campaign = Campaign.objects.filter(work__id=81834)
|
|
|
|
assert ola_campaign.count() == 1
|
|
|
|
ola_campaign = ola_campaign[0]
|
|
|
|
ola_transactions = Transaction.objects.filter(campaign=ola_campaign)
|
|
|
|
for t in ola_transactions:
|
|
|
|
if t.anonymous:
|
2013-08-18 19:21:55 +00:00
|
|
|
t.extra.update({"ack_name": ''})
|
2012-12-19 16:00:33 +00:00
|
|
|
else:
|
2013-08-18 19:21:55 +00:00
|
|
|
ack_name=t.extra.get("ack_name",'')
|
|
|
|
if not ack_name:
|
|
|
|
t.extra.update({"ack_name": t.user.username})
|
|
|
|
t.extra.update({"ack_dedication": ''})
|
2012-12-19 16:00:33 +00:00
|
|
|
t.save()
|