diff --git a/helios/election_urls.py b/helios/election_urls.py index 323c2b0d14f9958e37e1be4b98b2bbb6637d26df..459e131ef5ba83469abc46a5f63c0595f9f1d94b 100644 --- a/helios/election_urls.py +++ b/helios/election_urls.py @@ -9,7 +9,11 @@ from django.conf.urls.defaults import * from helios.views import * urlpatterns = patterns('', + # election data that is cryptographically verified (r'^$', one_election), + + # metadata that need not be verified + (r'^/meta$', one_election_meta), # edit election params (r'^/edit$', one_election_edit), diff --git a/helios/fixtures/legacy-election-metadata-expected.json b/helios/fixtures/legacy-election-metadata-expected.json new file mode 100644 index 0000000000000000000000000000000000000000..5356f38987e403654ab734e89d8e67d2c62c45cf --- /dev/null +++ b/helios/fixtures/legacy-election-metadata-expected.json @@ -0,0 +1 @@ +{"help_email": "help@heliosvoting.org", "use_advanced_audit_features": true} \ No newline at end of file diff --git a/helios/models.py b/helios/models.py index 284d1a2de80e6c011520cc3ebae8310c85cfe0e7..1d8f1315d3ef28d7eff6900fa604113a811b1618 100644 --- a/helios/models.py +++ b/helios/models.py @@ -133,6 +133,14 @@ class Election(HeliosModel): # help email help_email = models.EmailField(null=True) + # metadata for the election + @property + def metadata(self): + return { + 'help_email': self.help_email or 'help@heliosvoting.org', + 'use_advanced_audit_features': self.use_advanced_audit_features + } + @property def pretty_type(self): return dict(self.ELECTION_TYPES)[self.election_type] diff --git a/helios/tests.py b/helios/tests.py index 626c5402500a6c94279cc28fc4a3e259a3400cf5..e8e7fb235e912fc57d17efc67b9ac6038b93ec4c 100644 --- a/helios/tests.py +++ b/helios/tests.py @@ -312,6 +312,10 @@ class DataFormatBlackboxTests(object): response = self.client.get("/helios/elections/%s" % self.election.uuid, follow=False) self.assertEqualsToFile(response, self.EXPECTED_ELECTION_FILE) + def test_election_metadata(self): + response = self.client.get("/helios/elections/%s/meta" % self.election.uuid, follow=False) + self.assertEqualsToFile(response, self.EXPECTED_ELECTION_METADATA_FILE) + def test_voters_list(self): response = self.client.get("/helios/elections/%s/voters/" % self.election.uuid, follow=False) self.assertEqualsToFile(response, self.EXPECTED_VOTERS_FILE) @@ -331,6 +335,7 @@ class DataFormatBlackboxTests(object): class LegacyElectionBlackboxTests(DataFormatBlackboxTests, TestCase): fixtures = ['legacy-data.json'] EXPECTED_ELECTION_FILE = 'helios/fixtures/legacy-election-expected.json' + EXPECTED_ELECTION_METADATA_FILE = 'helios/fixtures/legacy-election-metadata-expected.json' EXPECTED_VOTERS_FILE = 'helios/fixtures/legacy-election-voters-expected.json' EXPECTED_TRUSTEES_FILE = 'helios/fixtures/legacy-trustees-expected.json' EXPECTED_BALLOTS_FILE = 'helios/fixtures/legacy-ballots-expected.json' diff --git a/helios/views.py b/helios/views.py index 54faf880f14c1475e262295326f60ebe3ea30930..45b1c8a453c51f312742dbf08d800208bc591c56 100644 --- a/helios/views.py +++ b/helios/views.py @@ -290,6 +290,13 @@ def one_election(request, election): raise Http404 return election.toJSONDict(complete=True) +@election_view() +@json +def one_election_meta(request, election): + if not election: + raise Http404 + return election.metadata + @election_view() def election_badge(request, election): election_url = get_election_url(election) diff --git a/heliosbooth/templates/footer.html b/heliosbooth/templates/footer.html index e064204a9b3792a77ae1437da4876b7a2d37eec5..750fa43285c79eb4ec92e162e07a7cb97fd22d9e 100644 --- a/heliosbooth/templates/footer.html +++ b/heliosbooth/templates/footer.html @@ -1,5 +1,5 @@ <span style="float:right; padding-right:20px;"> -<a target="_new" href="mailto:help@heliosvoting.org?subject=help%20with%20election%20{$T.election.name}&body=I%20need%20help%20with%20election%20{$T.election.uuid}">help!</a> +<a target="_new" href="mailto:{$T.election_metadata.help_email}?subject=help%20with%20election%20{$T.election.name}&body=I%20need%20help%20with%20election%20{$T.election.uuid}">help!</a> </span> {#if $T.election.BOGUS_P} The public key for this election is not yet ready. This election is in preview mode only. diff --git a/heliosbooth/vote.html b/heliosbooth/vote.html index 803a917aa1790244225622415949e5d254c9471a..7ab271f9e24f4f06ee26b085ff00e6348304662d 100644 --- a/heliosbooth/vote.html +++ b/heliosbooth/vote.html @@ -182,8 +182,8 @@ BOOTH.setup_election = function(raw_json) { BOOTH.election[field] = escape_html(BOOTH.election[field]); }); - $('#header').processTemplate({'election' : BOOTH.election}); - $('#footer').processTemplate({'election' : BOOTH.election}); + $('#header').processTemplate({'election' : BOOTH.election, 'election_metadata': BOOTH.election_metadata}); + $('#footer').processTemplate({'election' : BOOTH.election, 'election_metadata': BOOTH.election_metadata}); BOOTH.setup_ballot(); }; @@ -326,9 +326,13 @@ BOOTH.show_encryption_message_before = function(func_to_execute) { BOOTH.load_and_setup_election = function(election_url) { // the hash will be computed within the setup function call now $.get(election_url, function(raw_json) { - BOOTH.setup_election(raw_json); - BOOTH.show_election(); - BOOTH.election_url = election_url; + // let's also get the metadata + $.getJSON(election_url + "/meta", {}, function(election_metadata) { + BOOTH.election_metadata = election_metadata; + BOOTH.setup_election(raw_json); + BOOTH.show_election(); + BOOTH.election_url = election_url; + }); });