diff --git a/src/ekklesia_portal/lib/vvvote/election_config.py b/src/ekklesia_portal/lib/vvvote/election_config.py index 3a223f84..c250724d 100644 --- a/src/ekklesia_portal/lib/vvvote/election_config.py +++ b/src/ekklesia_portal/lib/vvvote/election_config.py @@ -1,3 +1,5 @@ +from datetime import datetime + import random from uuid import uuid4 @@ -49,8 +51,8 @@ def ballot_to_vvvote_question(ballot): def get_ballot_sort_key(ballot): props = list(ballot.propositions) - props.sort(key=lambda prop: prop.qualified_at) - return props[0].qualified_at + props.sort(key=lambda prop: prop.qualified_at or datetime.now()) + return props[0].qualified_at or datetime.now() def voting_phase_to_vvvote_election_config(module_config, phase) -> vvvote_schema.ElectionConfig: diff --git a/tests/create_test_db.py b/tests/create_test_db.py index bfea84b7..ff3cc8b7 100644 --- a/tests/create_test_db.py +++ b/tests/create_test_db.py @@ -13,7 +13,6 @@ from typer import Option, confirm, Exit import ekklesia_common.logging -from ekklesia_common.ekklesia_auth import OAuthToken DOCUMENT_WP = '''# Wahlprogramm @@ -115,7 +114,7 @@ def main( # local import because we have to set up the database stuff before that from ekklesia_portal.datamodel import ( Argument, ArgumentRelation, ArgumentVote, Ballot, CustomizableText, Department, DepartmentMember, Document, - Group, Policy, Proposition, PropositionType, SubjectArea, Supporter, Tag, User, UserPassword, UserProfile, + Group, OAuthToken, Policy, Proposition, PropositionType, SubjectArea, Supporter, Tag, User, UserPassword, UserProfile, VotingPhase, VotingPhaseType ) diff --git a/tests/lib/vvvote/test_election_config.py b/tests/lib/vvvote/test_election_config.py index a163aae9..75760097 100644 --- a/tests/lib/vvvote/test_election_config.py +++ b/tests/lib/vvvote/test_election_config.py @@ -6,7 +6,7 @@ def test_ballot_to_vvvote_question(db_session, ballot, proposition_factory): proposition = proposition_factory(ballot=ballot) question = ballot_to_vvvote_question(ballot) - assert question.questionID == 1 + assert question.questionID == ballot.id assert question.options[0].optionTitle == proposition.title assert question.options[0].optionDesc == proposition.content assert question.options[0].reasons == proposition.motivation