Exemplo n.º 1
0
    def get_per_office_progress(self):
        data = []
        tally_id = self.kwargs['tally_id']

        intaken = p.IntakenProgressReport(tally_id)
        not_intaken = p.NotRecievedProgressReport(tally_id)
        archived = p.ArchivedProgressReport(tally_id)
        valid_votes = p.ValidVotesProgressReport(tally_id)

        for office in Office.objects.filter(
                tally__id=tally_id).order_by('number'):
            intaken_results = intaken.for_center_office(office)
            not_intaken_results = not_intaken.for_center_office(office)
            archived_result = archived.for_center_office(office)
            total_valid_votes = valid_votes.for_center_office(
                office=office,
                query_valid_votes=True)
            office_candidates_id_array =\
                get_office_candidates_ids(
                    office_id=office.id, tally_id=tally_id)
            data.append({
                'office': office.name,
                'office_id': office.id,
                'number': office.number,
                'intaken': intaken_results,
                'not_intaken': not_intaken_results,
                'archived': archived_result,
                'valid_votes': total_valid_votes,
                'candidate_count': len(office_candidates_id_array)
            })

        return data
Exemplo n.º 2
0
 def test_archived_progress_report(self):
     """
     Test that archived progress report returns correct figures
     """
     report = progress.ArchivedProgressReport(self.tally.id)
     self.assertEqual(report.number, 1)
     self.assertEqual(report.total, 10)
     self.assertEqual(report.percentage, 10)
Exemplo n.º 3
0
def getOverviews(tally_id):
    overviews = [
            p.ExpectedProgressReport(tally_id),
            p.IntakeProgressReport(tally_id),
            p.DataEntry1ProgressReport(tally_id),
            p.DataEntry2ProgressReport(tally_id),
            p.CorrectionProgressReport(tally_id),
            p.QualityControlProgressReport(tally_id),
            p.ArchivedProgressReport(tally_id),
            p.ClearanceProgressReport(tally_id),
            p.AuditProgressReport(tally_id),
            p.NotRecievedProgressReport(tally_id)
    ]

    return overviews
Exemplo n.º 4
0
    def get_per_office_progress(self):
        data = []

        for office in Office.objects.all().order_by('number'):
            intaken = p.IntakenProgressReport().for_center_office(office)
            not_intaken = p.NotRecievedProgressReport().for_center_office(
                office)
            archived = p.ArchivedProgressReport().for_center_office(office)
            data.append({
                'office': office,
                'number': office.number,
                'intaken': intaken.number,
                'not_intaken': not_intaken.number,
                'archived': archived.number,
            })

        return data
Exemplo n.º 5
0
    def get(self, *args, **kwargs):
        overviews = [
            p.ExpectedProgressReport(),
            p.IntakenProgressReport(),
            p.DataEntry1ProgressReport(),
            p.DataEntry2ProgressReport(),
            p.CorrectionProgressReport(),
            p.QualityControlProgressReport(),
            p.ArchivingProgressReport(),
            p.ArchivedProgressReport(),
            p.ClearanceProgressReport(),
            p.AuditProgressReport(),
            p.NotRecievedProgressReport()
        ]

        return self.render_to_response(
            self.get_context_data(overviews=overviews,
                                  per_office=self.get_per_office_progress()))
Exemplo n.º 6
0
    def get_per_ballot_progress(self):
        data = []

        for ballot in valid_ballots():
            archived = p.ArchivedProgressReport().for_ballot(ballot)
            sc = ballot.sub_constituency

            if sc:
                data.append({
                    'ballot': ballot.number,
                    'district': sc.code,
                    'race_type': ballot.race_type_name,
                    'expected': archived.denominator,
                    'complete': archived.number,
                    'percentage': archived.percentage,
                })

        return data
Exemplo n.º 7
0
    def get_per_ballot_progress(self):
        data = []
        tally_id = self.kwargs.get('tally_id')

        archived = p.ArchivedProgressReport(tally_id)
        sc_cache = SubConstituency.objects.all()
        sc_cache = dict(zip(map(lambda x: x.id, sc_cache), sc_cache))
        for d in valid_ballots(tally_id).values('id', 'active', 'race_type',
                                                'sc_component', 'sc_general',
                                                'sc_women', 'number',
                                                'document'):
            archived_result = archived.for_ballot(
                form_ballot_numbers=form_ballot_numbers(d['number']))
            sc = sub_constituency(sc_cache.get(d['sc_component']),
                                  sc_cache.get(d['sc_women']),
                                  sc_cache.get(d['sc_general']))

            if sc:
                data.append({
                    'ballot':
                    d['number'],
                    'district':
                    sc.code,
                    'race_type':
                    race_type_name(d['race_type'],
                                   sc_cache.get(d['sc_general'])),
                    'document':
                    d['document'],
                    'document_name':
                    document_name(d['document']),
                    'expected':
                    archived_result['denominator'],
                    'complete':
                    archived_result['number'],
                    'percentage':
                    archived_result['percentage'],
                    'id':
                    d['id'],
                    'active':
                    d['active']
                })

        return data
Exemplo n.º 8
0
    def get_per_office_progress(self):
        data = []
        tally_id = self.kwargs['tally_id']

        intaken = p.IntakenProgressReport(tally_id)
        not_intaken = p.NotRecievedProgressReport(tally_id)
        archived = p.ArchivedProgressReport(tally_id)

        for office in Office.objects.filter(
                tally__id=tally_id).order_by('number'):
            intaken_results = intaken.for_center_office(office)
            not_intaken_results = not_intaken.for_center_office(office)
            archived_result = archived.for_center_office(office)
            data.append({
                'office': office.name,
                'number': office.number,
                'intaken': intaken_results,
                'not_intaken': not_intaken_results,
                'archived': archived_result,
            })

        return data
Exemplo n.º 9
0
    def get_per_ballot_progress(self):
        data = []
        tally_id = self.kwargs.get('tally_id')

        archived = p.ArchivedProgressReport(tally_id)
        for ballot in valid_ballots(tally_id):
            archived_result = archived.for_ballot(ballot)
            sc = ballot.sub_constituency

            if sc:
                data.append({
                    'ballot': ballot.number,
                    'district': sc.code,
                    'race_type': ballot.race_type_name,
                    'expected': archived_result['denominator'],
                    'complete': archived_result['number'],
                    'percentage': archived_result['percentage'],
                    'id': ballot.id,
                    'active': ballot.active
                })

        return data
Exemplo n.º 10
0
 def test_archived_progress_report(self):
     report = progress.ArchivedProgressReport()
     self.assertEqual(report.number, 1)
     self.assertEqual(report.total, 11)
     self.assertEqual(report.percentage, 9.090909090909092)