Skip to content

Commit

Permalink
fixed some newly introduced bugs in emailing voters and such
Browse files Browse the repository at this point in the history
  • Loading branch information
benadida committed Aug 31, 2008
1 parent d55fc95 commit 38d7d55
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
7 changes: 2 additions & 5 deletions controllers/election.py
Expand Up @@ -496,11 +496,8 @@ def email_voters_2(self, election, introductory_message):

mail.simple_send([voter.name],[voter.email],"Helios","ben@adida.net","An Invitation to Vote in %s" % election.name, message)

# raise cherrypy.HTTPRedirect("/elections/%s/view" % election.election_id)
if len(voters) == 0:
return "DONE"
else:
return utils.to_json([v.toJSONDict() for v in voters])
# hack for now, no more batching
return "DONE"

@web
@session.login_protect
Expand Down
4 changes: 2 additions & 2 deletions index.yaml
Expand Up @@ -10,7 +10,7 @@ indexes:
# automatically uploaded to the admin console when you next deploy
# your application using appcfg.py.

# Used 8 times in query history.
# Used 12 times in query history.
- kind: ElectionExponent
properties:
- name: election
Expand All @@ -37,7 +37,7 @@ indexes:
- name: tallied_at
- name: cast_id

# Used 29 times in query history.
# Used 57 times in query history.
- kind: Voter
properties:
- name: election
Expand Down
10 changes: 4 additions & 6 deletions templates/election/email_voters.tmpl
Expand Up @@ -3,13 +3,13 @@
<script>
BATCH_SIZE = 10;

function send_email(offset) {
function send_email() {
var form = document.forms['email_form'];

\$.post("email_voters_2", {'introductory_message' : form.introductory_message.value, 'offset' : offset, 'limit' : BATCH_SIZE}, function(data) {
\$.post("email_voters_2", {'introductory_message' : form.introductory_message.value}, function(data) {
// decide whether or not to keep going
if (data != "DONE") {
setTimeout("send_email(" + (offset + BATCH_SIZE) + ")", 5000);
alert('oy unexpected: ' + data);
} else {
alert('done!');
document.location = "./view";
Expand All @@ -25,7 +25,7 @@ You are about to email all voters in this election. You can fill in the middle p
</p>

<blockquote>
<form name="email_form" method="post" onsubmit="send_email(this.offset.value); return false;">
<form name="email_form" method="post" onsubmit="send_email(); return false;">

<pre>
Dear [VOTER_NAME],
Expand All @@ -41,8 +41,6 @@ Your password: [VOTER_PASSWORD]
</blockquote>

<br />
<br />
Offset: <input type="text" name="offset" size="10" value="0" />
<br /><br />
<input type="submit" value="send now!" class="pretty" />
</form>
Expand Down

0 comments on commit 38d7d55

Please sign in to comment.