Skip to content

Commit

Permalink
fixed empty voters
Browse files Browse the repository at this point in the history
  • Loading branch information
benadida committed Sep 17, 2008
1 parent cd183b8 commit 14bd4f8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
6 changes: 3 additions & 3 deletions index.yaml
Expand Up @@ -10,14 +10,14 @@ indexes:
# automatically uploaded to the admin console when you next deploy
# your application using appcfg.py.

# Used 10 times in query history.
# Used 12 times in query history.
- kind: ElectionExponent
properties:
- name: election
- name: exponent
direction: desc

# Used 126 times in query history.
# Used 168 times in query history.
- kind: KeyShare
properties:
- name: election
Expand All @@ -43,7 +43,7 @@ indexes:
- name: tallied_at
- name: cast_id

# Used 206 times in query history.
# Used 267 times in query history.
- kind: Voter
properties:
- name: election
Expand Down
18 changes: 16 additions & 2 deletions models/modelsbase.py
Expand Up @@ -312,16 +312,30 @@ def compute_vote_hash(self):
return vote_hash

def get_vote(self):
return electionalgs.EncryptedVote.fromJSONDict(utils.from_json(self.vote or "null"))
vote_dict = utils.from_json(self.vote or "null")

# null vote
if not vote_dict or vote_dict == "":
return None

return electionalgs.EncryptedVote.fromJSONDict(vote_dict)

def toJSONDict(self, with_vote = False):
json_dict = super(VoterBase, self).toJSONDict()

if not self.email and self.openid_url:
json_dict['openid'] = self.openid_url

if with_vote:
json_dict['vote'] = self.get_vote().toJSONDict()
vote = self.get_vote()
if vote:
json_dict['vote'] = vote.toJSONDict()
else:
json_dict['vote'] = None

if not json_dict['category'] or json_dict['category'] == "":
del json_dict['category']

return json_dict

##
Expand Down

0 comments on commit 14bd4f8

Please sign in to comment.