Skip to content

Commit 4190ad6

Browse files
authored
ElectionDay: Adds support for eCH-0252 V2 and views for municipality results
TYPE: Feature LINK: ogc-3103
1 parent 70aaa8d commit 4190ad6

83 files changed

Lines changed: 632845 additions & 588 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,5 @@ dump.rdb
108108
.codebuddy/
109109

110110
.aider*
111+
112+
.DS_Store

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ install_requires =
174174
xlrd
175175
xlsxwriter!=3.2.4
176176
xsdata!=23.5
177-
xsdata-ech<0.4.0
177+
xsdata-ech
178178
yubico-client
179179
zope.sqlalchemy
180180

src/onegov/election_day/cli.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
from onegov.core.cli import pass_group_context
1010
from onegov.core.sms_processor import SmsQueueProcessor
1111
from onegov.election_day.collections import ArchivedResultCollection
12+
from onegov.election_day.collections import ElectionCollection
13+
from onegov.election_day.collections import ElectionCompoundCollection
14+
from onegov.election_day.collections import VoteCollection
1215
from onegov.election_day.models import ArchivedResult
1316
from onegov.election_day.models import Subscriber
1417
from onegov.election_day.utils import add_local_results
@@ -250,3 +253,41 @@ def migrate(request: ElectionDayRequest, app: ElectionDayApp) -> None:
250253
click.echo(f'Migrated {count} subscribers')
251254

252255
return migrate
256+
257+
258+
@cli.command('delete-elections-and-votes')
259+
@click.option('--confirm', is_flag=True, default=False,
260+
help='Required to actually delete.')
261+
def delete_elections_and_votes(confirm: bool) -> Processor:
262+
r""" Deletes all elections, election compounds, votes and archived results.
263+
264+
.. code-block:: bash
265+
266+
onegov-election-day --select '/onegov_election_day/sg' \
267+
delete-elections-and-votes --confirm
268+
269+
"""
270+
271+
def delete(request: ElectionDayRequest, app: ElectionDayApp) -> None:
272+
if not confirm:
273+
click.secho(
274+
'Dry run — pass --confirm to actually delete.', fg='yellow'
275+
)
276+
return
277+
278+
session = request.app.session()
279+
click.secho(f'Deleting elections/votes for {app.schema}', fg='yellow')
280+
281+
for election in ElectionCollection(session).query():
282+
session.delete(election)
283+
for compound in ElectionCompoundCollection(session).query():
284+
session.delete(compound)
285+
for vote in VoteCollection(session).query():
286+
session.delete(vote)
287+
session.query(ArchivedResult).filter_by(
288+
schema=session.info['schema']
289+
).delete()
290+
291+
click.secho('Done.', fg='green')
292+
293+
return delete

src/onegov/election_day/collections/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
from onegov.election_day.collections.archived_results import \
44
ArchivedResultCollection
5+
from onegov.election_day.collections.archived_results import \
6+
AllMunicipalArchivedResultCollection
7+
from onegov.election_day.collections.archived_results import \
8+
MunicipalArchivedResultCollection
9+
from onegov.election_day.collections.archived_results import \
10+
MunicipalityArchivedResultCollection
11+
from onegov.election_day.collections.archived_results import \
12+
MunicipalityYearArchivedResultCollection
513
from onegov.election_day.collections.archived_results import \
614
SearchableArchivedResultCollection
715
from onegov.election_day.collections.ballots import BallotCollection
@@ -34,6 +42,10 @@
3442
'ElectionCompoundCollection',
3543
'EmailSubscriberCollection',
3644
'ListCollection',
45+
'AllMunicipalArchivedResultCollection',
46+
'MunicipalArchivedResultCollection',
47+
'MunicipalityArchivedResultCollection',
48+
'MunicipalityYearArchivedResultCollection',
3749
'NotificationCollection',
3850
'ScreenCollection',
3951
'SearchableArchivedResultCollection',

0 commit comments

Comments
 (0)