diff --git a/vote/models.py b/vote/models.py index e1e00924ee09e7f48f64e57935d0e966e7014836..eb34cde60bb28f28b8c01e4c2d333b2ad9948924 100644 --- a/vote/models.py +++ b/vote/models.py @@ -97,7 +97,7 @@ class Election(models.Model): end_date = models.DateTimeField(blank=True, null=True) max_votes_yes = models.IntegerField(blank=True, null=True) session = models.ForeignKey(Session, related_name='elections', on_delete=CASCADE) - result_published = models.BooleanField(null=False, default=False) + result_published = models.BooleanField(null=False, default=True) enable_abstention = models.BooleanField(default=True) voters_self_apply = models.BooleanField(default=False) send_emails_on_start = models.BooleanField(default=False) diff --git a/vote/templates/vote/index.html b/vote/templates/vote/index.html index 30bd8a6ecebea75dceef6c3a72bb0b14119c6e6c..efbf25ec87c627ef2c0ac2d80265f204e8c195e8 100644 --- a/vote/templates/vote/index.html +++ b/vote/templates/vote/index.html @@ -9,7 +9,7 @@ <div class="card-body"> <h4 class="text-center d-inline">{{ title }}</h4> {% if meeting_link %} - <div><small>Meeting at <a href="{{ meeting_link }}">{{ meeting_link }}</a></small></div> + <div><small>Meeting at <a href="{{ meeting_link }}">{{ meeting_link }}</a></small></div> {% endif %} </div> </div> @@ -25,7 +25,7 @@ </div> <div class="card-body"> {% for election, can_vote, edit in open_elections %} - {% include 'vote/index_election_item.html' %} + {% include 'vote/index_election_item.html' %} {% endfor %} </div> </div> @@ -37,7 +37,7 @@ </div> <div class="card-body"> {% for election, can_vote, edit in upcoming_elections %} - {% include 'vote/index_election_item.html' %} + {% include 'vote/index_election_item.html' %} {% endfor %} </div> </div> @@ -49,7 +49,7 @@ </div> <div class="card-body"> {% for election, can_vote, edit in published_elections %} - {% include 'vote/index_election_item.html' %} + {% include 'vote/index_election_item.html' %} {% endfor %} </div> </div> @@ -61,7 +61,7 @@ </div> <div class="card-body"> {% for election, can_vote, edit in closed_elections %} - {% include 'vote/index_election_item.html' %} + {% include 'vote/index_election_item.html' %} {% endfor %} </div> </div> diff --git a/vote/templates/vote/spectator.html b/vote/templates/vote/spectator.html index 2c8accf3749f3e0e1dd12e332f5753b1583d3896..d026cfaf81d55688310d2cb328239f6ce9a7e327 100644 --- a/vote/templates/vote/spectator.html +++ b/vote/templates/vote/spectator.html @@ -10,7 +10,7 @@ <div class="card-body"> <h4 class="text-center d-inline">{{ title }} - Spectator View</h4> {% if meeting_link %} - <div><small>Meeting at <a href="{{ meeting_link }}">{{ meeting_link }}</a></small></div> + <div><small>Meeting at <a href="{{ meeting_link }}">{{ meeting_link }}</a></small></div> {% endif %} </div> </div> @@ -26,7 +26,7 @@ </div> <div class="card-body"> {% for election in open_elections %} - {% include 'vote/spectator_election_item.html' %} + {% include 'vote/spectator_election_item.html' %} {% endfor %} </div> </div> @@ -38,7 +38,7 @@ </div> <div class="card-body"> {% for election in upcoming_elections %} - {% include 'vote/spectator_election_item.html' %} + {% include 'vote/spectator_election_item.html' %} {% endfor %} </div> </div> @@ -50,7 +50,7 @@ </div> <div class="card-body"> {% for election in published_elections %} - {% include 'vote/spectator_election_item.html' %} + {% include 'vote/spectator_election_item.html' %} {% endfor %} </div> </div> @@ -62,7 +62,7 @@ </div> <div class="card-body"> {% for election in closed_elections %} - {% include 'vote/spectator_election_item.html' %} + {% include 'vote/spectator_election_item.html' %} {% endfor %} </div> </div> diff --git a/vote/tests.py b/vote/tests.py index 48d990e09635903acd70012f403e262b0ddeaa7d..c4e3e24f4721399b332ce01b6fd0c0e4720d71b9 100644 --- a/vote/tests.py +++ b/vote/tests.py @@ -28,7 +28,8 @@ class VoterTestCase(TestCase): class ElectionSelectorsTest(TestCase): def test_election_selectors(self) -> None: - now = datetime(year=2021, month=4, day=1, tzinfo=timezone.get_fixed_timezone(5)) + now = datetime(year=2021, month=4, day=1, + tzinfo=timezone.get_fixed_timezone(5)) before = now - timedelta(seconds=5) bbefore = now - timedelta(seconds=10) after = now + timedelta(seconds=5) @@ -37,12 +38,16 @@ class ElectionSelectorsTest(TestCase): session = Session.objects.create(title="TEST") # upcoming elections all_upcoming = set() - all_upcoming.add(Election.objects.create(session=session)) - all_upcoming.add(Election.objects.create(session=session, start_date=after)) + all_upcoming.add(Election.objects.create( + session=session, result_published=False)) + all_upcoming.add(Election.objects.create( + session=session, start_date=after, result_published=False)) # open elections all_opened = set() - all_opened.add(Election.objects.create(session=session, start_date=now)) - all_opened.add(Election.objects.create(session=session, start_date=before, end_date=after)) + all_opened.add(Election.objects.create(session=session, + start_date=now, result_published=False)) + all_opened.add(Election.objects.create( + session=session, start_date=before, end_date=after, result_published=False)) # published elections all_published = set() all_published.add(Election.objects.create(session=session, start_date=bbefore, end_date=before, @@ -51,8 +56,10 @@ class ElectionSelectorsTest(TestCase): result_published=True)) # closed (not published) elections all_closed = set() - all_closed.add(Election.objects.create(session=session, start_date=bbefore, end_date=before)) - all_closed.add(Election.objects.create(session=session, start_date=before, end_date=now)) + all_closed.add(Election.objects.create( + session=session, start_date=bbefore, end_date=before, result_published=False)) + all_closed.add(Election.objects.create( + session=session, start_date=before, end_date=now, result_published=False)) # test upcoming upcoming = upcoming_elections(session) @@ -70,13 +77,15 @@ class ElectionSelectorsTest(TestCase): published = published_elections(session) self.assertEqual(all_published, set(published)) for e in published: - self.assertTrue(e.started and e.closed and not e.is_open and e.result_published) + self.assertTrue( + e.started and e.closed and not e.is_open and e.result_published) # test closed closed = closed_elections(session) self.assertEqual(all_closed, set(closed)) for e in closed: - self.assertTrue(e.started and e.closed and not e.is_open and not e.result_published) + self.assertTrue( + e.started and e.closed and not e.is_open and not e.result_published) def gen_data():