it/itf/tmp/utils.py
2011-12-13 18:01:47 +05:30

21 lines
556 B
Python

from festival.models import *
def clean_participants():
unique_participants = []
participants = Participant.objects.all()
for p in participants:
if not p.name in unique_participants:
unique_participants.append(p.name)
for u in unique_participants:
dupes = participants.filter(name=u)
to_keep = dupes[0]
meeting_ids = []
for d in dupes:
to_keep.meetings.add(d.meeting.id)
to_keep.save()
for d in dupes[1:]:
d.delete()
print u