示例#1
0
 def test_find_member_surname_prefix(self):
     surname = 'Weyenberg van'
     forename = 'Steven'
     initials = 'S.P.R.A.'
     member = ParliamentMember.find(surname=surname, initials=initials)
     self.assertEqual(member.person.forename, forename)
     surname = 'van Weyenberg'
     member = ParliamentMember.find(surname=surname, initials=initials)
     self.assertEqual(member.person.forename, forename)
示例#2
0
 def test_find_member_non_ascii(self):
     surname = 'Koser Kaya'
     forename = 'Fatma'
     initials = 'F.'
     member = ParliamentMember.find(surname=surname, initials=initials)
     self.assertEqual(member.person.forename, forename)
     surname = 'Koşer Kaya'
     member = ParliamentMember.find(surname=surname, initials=initials)
     self.assertEqual(member.person.forename, forename)
示例#3
0
 def test_find_members(self):
     person = Person.find_by_fullname('Diederik Samsom')
     member = ParliamentMember.find('Samsom', initials='D.M.')
     self.assertEqual(member.person, person)
     member = ParliamentMember.find('Samsom', initials='D.M.', date=datetime.date(year=2004, month=6, day=1))
     self.assertEqual(member.person, person)
     self.assertEqual(member.joined, datetime.date(year=2003, month=1, day=30))
     member = ParliamentMember.find('Samsom', initials='D.M.', date=datetime.date(year=2016, month=6, day=1))
     self.assertEqual(member.person, person)
     self.assertEqual(member.joined, datetime.date(year=2012, month=9, day=20))
示例#4
0
 def test_find_members(self):
     person = Person.find_by_fullname('Diederik Samsom')
     member = ParliamentMember.find('Samsom', initials='D.M.')
     self.assertEqual(member.person, person)
     member = ParliamentMember.find('Samsom', initials='D.M.', date=datetime.date(year=2004, month=6, day=1))
     self.assertEqual(member.person, person)
     self.assertEqual(member.joined, datetime.date(year=2003, month=1, day=30))
     member = ParliamentMember.find('Samsom', initials='D.M.', date=datetime.date(year=2016, month=6, day=1))
     self.assertEqual(member.person, person)
     self.assertEqual(member.joined, datetime.date(year=2012, month=9, day=20))
示例#5
0
    def create_votes_individual(self, voting, stemmingen):
        logger.info('BEGIN')
        for stemming in stemmingen:
            persoon = stemming.persoon

            if persoon:
                initials = persoon.initialen
                surname = persoon.achternaam
                forname = persoon.roepnaam
            else:
                logger.error('Persoon not found for stemming: ' + stemming.id)
                surname_initials = stemming.json['AnnotatieActorNaam']
                forname = ''
                initials, surname, surname_prefix = parse_name_surname_initials(surname_initials)

            parliament_member = ParliamentMember.find(surname=surname, initials=initials)
            if not parliament_member:
                logger.error('parliament member not found for vote: ' + str(stemming.id))
                logger.error('creating vote with empty parliament member')

            person_name = ' '.join([forname, surname, initials]).strip()
            VoteIndividual.objects.create(
                voting=voting,
                person_name=person_name,
                parliament_member=parliament_member,
                number_of_seats=1,
                decision=self.get_decision(stemming.soort),
                details='',
                is_mistake=stemming.vergissing if stemming.vergissing is not None else False
            )
        logger.info('END')
示例#6
0
def create_votes_individual(voting, votes):
    logger.info('BEGIN')
    for vote in votes:
        initials, surname, surname_prefix = parse_name_surname_initials(
            vote.parliament_member)
        parliament_member = ParliamentMember.find(surname=surname,
                                                  initials=initials)
        if not parliament_member:
            logger.error('parliament member not found for vote: ' + str(vote))
            logger.error('creating vote with empty parliament member')
            if voting.kamerstuk:
                logger.error('on kamerstuk: ' + str(voting.kamerstuk) +
                             ', in dossier: ' +
                             str(voting.kamerstuk.document.dossier) +
                             ', for name: ' + surname + ' ' + initials)
            else:
                logger.error('voting.kamerstuk does not exist')
        VoteIndividual.objects.create(voting=voting,
                                      person_name=vote.parliament_member,
                                      parliament_member=parliament_member,
                                      number_of_seats=vote.number_of_seats,
                                      decision=get_decision(vote.decision),
                                      details=vote.details,
                                      is_mistake=vote.is_mistake)
    logger.info('END')
示例#7
0
 def set_derived(self):
     initials, surname, surname_prefix = parse_name_surname_initials(
         self.person_name)
     self.parliament_member = ParliamentMember.find(surname=surname,
                                                    initials=initials,
                                                    date=self.voting.date)
     self.save()
示例#8
0
 def test_delete_parliament_member(self):
     member = ParliamentMember.find('Dijkstra', initials='P.A.')
     vote = VoteIndividual.objects.create(voting=self.voting,
                                          person_name='Dijkstra, P.A.',
                                          number_of_seats=1)
     vote.set_derived()
     self.assertEqual(member, vote.parliament_member)
     ParliamentMember.objects.all().delete()
     vote = VoteIndividual.objects.filter(id=vote.id)
     self.assertEqual(vote, vote)
示例#9
0
 def test_delete_parliament_member(self):
     member = ParliamentMember.find('Dijkstra', initials='P.A.')
     vote = VoteIndividual.objects.create(
         voting=self.voting,
         person_name='Dijkstra, P.A.',
         number_of_seats=1
     )
     vote.set_derived()
     self.assertEqual(member, vote.parliament_member)
     ParliamentMember.objects.all().delete()
     vote = VoteIndividual.objects.filter(id=vote.id)
     self.assertEqual(vote, vote)
示例#10
0
    def create_votes_individual(self, voting, stemmingen):
        logger.info('BEGIN')
        for stemming in stemmingen:
            persoon = stemming.persoon
            parliament_member = None

            persons = Person.objects.filter(tk_id=persoon.id)
            if persons:
                person = persons[0]
                members = ParliamentMember.objects.filter(person=person).order_by('-joined')
                parliament_member = members[0] if members.exists() else None
                person_name = ' '.join([person.forename, person.surname, person.initials]).strip()

            # TODO BR: this is a fallback, remove or extract function and log
            if parliament_member is None:
                if persoon:
                    initials = persoon.initialen
                    surname = persoon.achternaam
                    forname = persoon.roepnaam
                else:
                    logger.error('Persoon not found for stemming: {}'.format(stemming.id))
                    surname_initials = stemming.json['AnnotatieActorNaam']
                    forname = ''
                    initials, surname, surname_prefix = parse_name_surname_initials(surname_initials)

                parliament_member = ParliamentMember.find(surname=surname, initials=initials)
                if not parliament_member:
                    logger.error('parliament member not found for vote: {}'.format(stemming.id))
                    logger.error('creating vote with empty parliament member')
                person_name = ' '.join([forname, surname, initials]).strip()

            VoteIndividual.objects.create(
                voting=voting,
                person_name=person_name,
                person_tk_id=persoon.id,
                parliament_member=parliament_member,
                number_of_seats=1,
                decision=self.get_decision(stemming.soort),
                details='',
                is_mistake=stemming.vergissing if stemming.vergissing is not None else False
            )
        logger.info('END')
示例#11
0
 def test_find_member(self):
     surname = 'Zijlstra'
     forename = 'Halbe'
     initials = 'H.'
     member = ParliamentMember.find(surname=surname, initials=initials)
     self.assertEqual(member.person.forename, forename)
示例#12
0
 def set_derived(self):
     initials, surname, surname_prefix = parse_name_surname_initials(self.person_name)
     self.parliament_member = ParliamentMember.find(surname=surname, initials=initials, date=self.voting.date)
     self.save()