Skip to content
This repository has been archived by the owner on Sep 5, 2019. It is now read-only.

Commit

Permalink
Fixes expats not displayed for temporary results
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Sommerhalder committed May 7, 2019
1 parent 3c6f3cf commit c3018c3
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 30 deletions.
4 changes: 4 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Changelog
---------

- Fixes expats not displayed for temporary results.
[msom]

3.13.4 (2019-04-30)
~~~~~~~~~~~~~~~~~~~

Expand Down
7 changes: 5 additions & 2 deletions onegov/election_day/formats/election/internal_majorz.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,12 @@ def import_election_internal_majorz(election, principal, file, mimetype):
return errors

# Add the missing entities
remaining = entities.keys() - results.keys()
remaining = set(entities.keys())
if election.expats:
remaining.add(0)
remaining -= set(results.keys())
for entity_id in remaining:
entity = entities[entity_id]
entity = entities.get(entity_id, {})
district = entity.get('district', '')
if election.domain == 'region':
if not election.distinct:
Expand Down
7 changes: 5 additions & 2 deletions onegov/election_day/formats/election/internal_proporz.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,12 @@ def import_election_internal_proporz(election, principal, file, mimetype):
return errors

# Add the missing entities
remaining = entities.keys() - results.keys()
remaining = set(entities.keys())
if election.expats:
remaining.add(0)
remaining -= set(results.keys())
for entity_id in remaining:
entity = entities[entity_id]
entity = entities.get(entity_id, {})
district = entity.get('district', '')
if election.domain == 'region':
if not election.distinct:
Expand Down
7 changes: 5 additions & 2 deletions onegov/election_day/formats/election/wabsti_majorz.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,12 @@ def import_election_wabsti_majorz(
return errors

# Add the missing entities
remaining = entities.keys() - results.keys()
remaining = set(entities.keys())
if election.expats:
remaining.add(0)
remaining -= set(results.keys())
for entity_id in remaining:
entity = entities[entity_id]
entity = entities.get(entity_id, {})
district = entity.get('district', '')
if election.domain == 'region':
if not election.distinct:
Expand Down
7 changes: 5 additions & 2 deletions onegov/election_day/formats/election/wabsti_proporz.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,12 @@ def import_election_wabsti_proporz(
return errors

# Add the missing entities
remaining = entities.keys() - results.keys()
remaining = set(entities.keys())
if election.expats:
remaining.add(0)
remaining -= set(results.keys())
for entity_id in remaining:
entity = entities[entity_id]
entity = entities.get(entity_id, {})
district = entity.get('district', '')
if election.domain == 'region':
if not election.distinct:
Expand Down
7 changes: 5 additions & 2 deletions onegov/election_day/formats/election/wabstic_majorz.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,12 @@ def import_election_wabstic_majorz(

# Add the missing entities
result_inserts = []
remaining = entities.keys() - added_results.keys()
remaining = set(entities.keys())
if election.expats:
remaining.add(0)
remaining -= set(added_results.keys())
for entity_id in remaining:
entity = entities[entity_id]
entity = entities.get(entity_id, {})
district = entity.get('district', '')
if election.domain == 'region':
if not election.distinct:
Expand Down
7 changes: 5 additions & 2 deletions onegov/election_day/formats/election/wabstic_proporz.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,9 +632,12 @@ def import_election_wabstic_proporz(

# Add the missing entities
result_inserts = []
remaining = entities.keys() - added_results.keys()
remaining = set(entities.keys())
if election.expats:
remaining.add(0)
remaining -= set(added_results.keys())
for entity_id in remaining:
entity = entities[entity_id]
entity = entities.get(entity_id, {})
district = entity.get('district', '')
if election.domain == 'region':
if not election.distinct:
Expand Down
8 changes: 6 additions & 2 deletions onegov/election_day/formats/vote/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,12 @@ def skip_line(line):

if not errors:
# Add the missing entities as uncounted results
for entity_id in (entities.keys() - added_entity_ids):
entity = entities[entity_id]
remaining = set(entities.keys())
if vote.expats:
remaining.add(0)
remaining -= added_entity_ids
for entity_id in remaining:
entity = entities.get(entity_id, {})
ballot_results.append(
BallotResult(
name=entity.get('name', ''),
Expand Down
7 changes: 5 additions & 2 deletions onegov/election_day/formats/vote/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,12 @@ def import_vote_internal(vote, principal, file, mimetype):

# Add the missing entities
for ballot_type in ballot_types:
remaining = (entities.keys() - added_entity_ids[ballot_type])
remaining = set(entities.keys())
if vote.expats:
remaining.add(0)
remaining -= added_entity_ids[ballot_type]
for entity_id in remaining:
entity = entities[entity_id]
entity = entities.get(entity_id, {})
ballot_results[ballot_type].append(
dict(
name=entity.get('name', ''),
Expand Down
9 changes: 5 additions & 4 deletions onegov/election_day/formats/vote/wabsti.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,12 @@ def import_vote_wabsti(vote, principal, vote_number, file, mimetype):
vote.clear_results()

for ballot_type in used_ballot_types:
remaining = (
entities.keys() - added_entity_ids
)
remaining = set(entities.keys())
if vote.expats:
remaining.add(0)
remaining -= added_entity_ids
for entity_id in remaining:
entity = entities[entity_id]
entity = entities.get(entity_id, {})
ballot_results[ballot_type].append(
BallotResult(
name=entity.get('name', ''),
Expand Down
11 changes: 5 additions & 6 deletions onegov/election_day/formats/vote/wabstic.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,12 @@ def import_vote_wabstic(vote, principal, number, district,

# Add the missing entities
for ballot_type in used_ballot_types:
remaining = (
entities.keys() - set(
result['entity_id'] for result in ballot_results[ballot_type]
)
)
remaining = set(entities.keys())
if vote.expats:
remaining.add(0)
remaining -= set(r['entity_id'] for r in ballot_results[ballot_type])
for entity_id in remaining:
entity = entities[entity_id]
entity = entities.get(entity_id, {})
ballot_results[ballot_type].append(
dict(
entity_id=entity_id,
Expand Down
9 changes: 5 additions & 4 deletions onegov/election_day/formats/vote/wabstim.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,12 @@ def import_vote_wabstim(vote, principal, file, mimetype):
vote.clear_results()

for ballot_type in used_ballot_types:
remaining = (
entities.keys() - added_entity_ids
)
remaining = set(entities.keys())
if vote.expats:
remaining.add(0)
remaining -= added_entity_ids
for id in remaining:
entity = entities[id]
entity = entities.get(entity_id, {})
ballot_results[ballot_type].append(
BallotResult(
name=entity.get('name', ''),
Expand Down

0 comments on commit c3018c3

Please sign in to comment.