Last active
August 29, 2015 14:22
-
-
Save Hippocrates/16db9eb2ee6de40d1c2b to your computer and use it in GitHub Desktop.
This was supposed to be in a datamigration at some point
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tracker.models import *; | |
def run(): | |
tickets = list(PrizeTicket.objects.all()) | |
for ticket in tickets: | |
if( PrizeTicket.objects.filter(pk=ticket.pk).exists() ): | |
equivalents = list(filter(lambda x: x != ticket, PrizeTicket.objects.filter(donation=ticket.donation,prize=ticket.prize))) | |
if len(equivalents) > 0: | |
for x in equivalents: | |
ticket.amount += x.amount; | |
x.delete() | |
ticket.save() | |
bids = list(DonationBid.objects.all()) | |
for donationbid in bids: | |
if( DonationBid.objects.filter(pk=donationbid.pk).exists() ): | |
equivalents = list(filter(lambda x: x != donationbid, DonationBid.objects.filter(donation=donationbid.donation,bid=donationbid.bid))) | |
if len(equivalents) > 0: | |
for x in equivalents: | |
donationbid.amount += x.amount; | |
x.delete() | |
donationbid.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment