Author: humbedooh
Date: Sun Mar 27 17:57:02 2016
New Revision: 1736795
URL: http://svn.apache.org/viewvc?rev=1736795&view=rev
Log:
only scrub if the hash was current.
Modified:
steve/trunk/pysteve/lib/backends/es.py
steve/trunk/pysteve/lib/voter.py
Modified: steve/trunk/pysteve/lib/backends/es.py
URL:
http://svn.apache.org/viewvc/steve/trunk/pysteve/lib/backends/es.py?rev=1736795&r1=1736794&r2=1736795&view=diff
==============================================================================
--- steve/trunk/pysteve/lib/backends/es.py (original)
+++ steve/trunk/pysteve/lib/backends/es.py Sun Mar 27 17:57:02 2016
@@ -235,6 +235,9 @@ class ElasticSearchBackend:
xhash = hashlib.sha224(election + ":" + uid).hexdigest()
# Find ballots and votes matching
+ bid = self.voter_get_uid(election, xhash)
+ if not bid:
+ return None
res = self.es.search(index="steve", doc_type="votes", body = {
"query": {
"match": {
Modified: steve/trunk/pysteve/lib/voter.py
URL:
http://svn.apache.org/viewvc/steve/trunk/pysteve/lib/voter.py?rev=1736795&r1=1736794&r2=1736795&view=diff
==============================================================================
--- steve/trunk/pysteve/lib/voter.py (original)
+++ steve/trunk/pysteve/lib/voter.py Sun Mar 27 17:57:02 2016
@@ -63,12 +63,17 @@ def regenerate(election, basedata, xhash
try:
from lib import gateway
uid = gateway.uid()
- backend.ballot_scrub(election, xhash)
- ballot, xhash = add(election, basedata, uid)
- return {
- 'election': election,
- 'ballot': ballot
- }
+ valid = backend.ballot_scrub(election, xhash)
+ if valid:
+ ballot, xhash = add(election, basedata, uid)
+ return {
+ 'election': election,
+ 'ballot': ballot
+ }
+ else:
+ return {
+ 'error': "Not a valid ballot!"
+ }
except:
return {'error': "No suitable gateway mechanism found"}