From 0bd93b2cea129716993792fb45dcf3223755efc1 Mon Sep 17 00:00:00 2001 From: Sanj Date: Tue, 13 Dec 2011 18:01:47 +0530 Subject: [PATCH] utils for participants --- itf/tmp/__init__.py | 0 itf/tmp/utils.py | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 itf/tmp/__init__.py create mode 100644 itf/tmp/utils.py diff --git a/itf/tmp/__init__.py b/itf/tmp/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/itf/tmp/utils.py b/itf/tmp/utils.py new file mode 100644 index 0000000..dca54f9 --- /dev/null +++ b/itf/tmp/utils.py @@ -0,0 +1,20 @@ +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 + +