def test_get_member_for_person_at_date(self): person = Person.find_by_fullname('Diederik Samsom') members_all = ParliamentMember.objects.filter(person=person) self.assertEqual(members_all.count(), 4) members = ParliamentMember.find_at_date(person, datetime.date(year=2016, month=6, day=1)) self.assertEqual(members[0].joined, datetime.date(year=2012, month=9, day=20)) self.assertEqual(members.count(), 1) self.assertEqual(members[0].person, person) members = ParliamentMember.find_at_date(person, datetime.date(year=2004, month=6, day=1)) self.assertEqual(members[0].joined, datetime.date(year=2003, month=1, day=30)) self.assertEqual(members.count(), 1) self.assertEqual(members[0].person, person)
def test_get_member_for_person_at_date(self): person = Person.find_by_fullname('Diederik Samsom') members_all = ParliamentMember.objects.filter(person=person) self.assertEqual(members_all.count(), 4) members = ParliamentMember.find_at_date(person, datetime.date(year=2016, month=6, day=1)) self.assertEqual(members[0].joined, datetime.date(year=2012, month=9, day=20)) self.assertEqual(members.count(), 1) self.assertEqual(members[0].person, person) members = ParliamentMember.find_at_date(person, datetime.date(year=2004, month=6, day=1)) self.assertEqual(members[0].joined, datetime.date(year=2003, month=1, day=30)) self.assertEqual(members.count(), 1) self.assertEqual(members[0].person, person)
def save(self, *args, **kwargs): party_members = PartyMember.get_at_date(self.person, self.date) self.party = party_members[0].party if party_members else None parliament_members = ParliamentMember.find_at_date( self.person, self.date) self.parliament_member = parliament_members[ 0] if parliament_members else None super().save(*args, **kwargs)
def save(self, *args, **kwargs): party_members = PartyMember.get_at_date(self.person, self.date) self.party = party_members[0].party if party_members else None parliament_members = ParliamentMember.find_at_date(self.person, self.date) self.parliament_member = parliament_members[0] if parliament_members else None super().save(*args, **kwargs)