@@ -0,0 +1,1398 @@
+from core.models import *%0A%0Afrom django.core.management.base import NoArgsCommand, CommandError%0A%0Aclass Command(NoArgsCommand):%0A%0A    help = %22Go through people who are MP aspirants, and check that they're associated with a 2013 constituency%22%0A%0A    def handle_noargs(self, **options):%0A        next_session = ParliamentarySession.objects.get(slug=%22na2013%22)%0A        for person in Person.objects.all():%0A            if not person.is_aspirant():%0A                continue%0A            aspirant_mp_positions = %5Bap for ap in person.aspirant_positions() if ap.title.slug == 'aspirant-mp'%5D%0A            if not aspirant_mp_positions:%0A                continue%0A            print person%0A            if len(aspirant_mp_positions) %3E 1:%0A                print %22  Warning: more than one Aspirant MP position:%22%0A                for amp in aspirant_mp_positions:%0A                    print %22    %22, amp%0A                continue%0A            amp = aspirant_mp_positions%5B0%5D%0A            if amp.place.parliamentary_session != next_session:%0A                print %22%22%22  Warning: the place associated with this Aspirant MP position%0A  %25s - %25s%0A  is for the wrong parliamentary session.  It should be a%0A  place associated with the parliamentary session: %25s%22%22%22 %25 (amp.place,%0A                                                            amp.place.parliamentary_session,%0A                                                            next_session)%0A

Add a script to check the aspirant MPs