Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Helios Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
Helios Server
Commits
339e7aae
Commit
339e7aae
authored
13 years ago
by
Ben Adida
Browse files
Options
Downloads
Patches
Plain Diff
moved voter files to content
parent
f1b46067
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
helios/models.py
+22
-7
22 additions, 7 deletions
helios/models.py
helios/tests.py
+1
-4
1 addition, 4 deletions
helios/tests.py
with
23 additions
and
11 deletions
helios/models.py
+
22
−
7
View file @
339e7aae
...
@@ -11,7 +11,7 @@ from django.utils import simplejson
...
@@ -11,7 +11,7 @@ from django.utils import simplejson
from
django.conf
import
settings
from
django.conf
import
settings
from
django.core.mail
import
send_mail
from
django.core.mail
import
send_mail
import
datetime
,
logging
,
uuid
,
random
import
datetime
,
logging
,
uuid
,
random
,
StringIO
from
crypto
import
electionalgs
,
algs
,
utils
from
crypto
import
electionalgs
,
algs
,
utils
from
helios
import
utils
as
heliosutils
from
helios
import
utils
as
heliosutils
...
@@ -219,11 +219,14 @@ class Election(HeliosModel):
...
@@ -219,11 +219,14 @@ class Election(HeliosModel):
"""
"""
expects a django uploaded_file data structure, which has filename, content, size...
expects a django uploaded_file data structure, which has filename, content, size...
"""
"""
random_filename
=
str
(
uuid
.
uuid4
())
# now we're just storing the content
new_voter_file
=
VoterFile
(
election
=
self
)
# random_filename = str(uuid.uuid4())
new_voter_file
.
voter_file
.
save
(
random_filename
,
uploaded_file
)
# new_voter_file.voter_file.save(random_filename, uploaded_file)
self
.
append_log
(
ElectionLog
.
VOTER_FILE_ADDED
)
new_voter_file
=
VoterFile
(
election
=
self
,
voter_file_content
=
uploaded_file
.
read
())
new_voter_file
.
save
()
self
.
append_log
(
ElectionLog
.
VOTER_FILE_ADDED
)
return
new_voter_file
return
new_voter_file
def
user_eligible_p
(
self
,
user
):
def
user_eligible_p
(
self
,
user
):
...
@@ -636,7 +639,12 @@ class VoterFile(models.Model):
...
@@ -636,7 +639,12 @@ class VoterFile(models.Model):
num_voters
=
models
.
IntegerField
(
null
=
True
)
num_voters
=
models
.
IntegerField
(
null
=
True
)
def
itervoters
(
self
):
def
itervoters
(
self
):
reader
=
unicode_csv_reader
(
open
(
self
.
voter_file
.
path
,
"
rU
"
))
if
self
.
voter_file_content
:
voter_stream
=
StringIO
.
StringIO
(
self
.
voter_file_content
)
else
:
voter_stream
=
open
(
self
.
voter_file
.
path
,
"
rU
"
)
reader
=
unicode_csv_reader
(
voter_stream
)
for
voter_fields
in
reader
:
for
voter_fields
in
reader
:
# bad line
# bad line
...
@@ -658,7 +666,14 @@ class VoterFile(models.Model):
...
@@ -658,7 +666,14 @@ class VoterFile(models.Model):
self
.
save
()
self
.
save
()
election
=
self
.
election
election
=
self
.
election
reader
=
unicode_csv_reader
(
open
(
self
.
voter_file
.
path
,
"
rU
"
))
# now we're looking straight at the content
if
self
.
voter_file_content
:
voter_stream
=
StringIO
.
StringIO
(
self
.
voter_file_content
)
else
:
voter_stream
=
open
(
self
.
voter_file
.
path
,
"
rU
"
)
reader
=
unicode_csv_reader
(
voter_stream
)
last_alias_num
=
election
.
last_alias_num
last_alias_num
=
election
.
last_alias_num
...
...
This diff is collapsed.
Click to expand it.
helios/tests.py
+
1
−
4
View file @
339e7aae
...
@@ -588,10 +588,7 @@ class ElectionBlackboxTests(WebTest):
...
@@ -588,10 +588,7 @@ class ElectionBlackboxTests(WebTest):
# vote by preparing a ballot via the server-side encryption
# vote by preparing a ballot via the server-side encryption
response
=
self
.
app
.
post
(
"
/helios/elections/%s/encrypt-ballot
"
%
election_id
,
{
response
=
self
.
app
.
post
(
"
/helios/elections/%s/encrypt-ballot
"
%
election_id
,
{
'
answers_json
'
:
utils
.
to_json
([[
1
]])})
'
answers_json
'
:
utils
.
to_json
([[
1
]])})
try
:
self
.
assertContains
(
response
,
"
answers
"
)
self
.
assertContains
(
response
,
"
answers
"
)
except
:
import
pdb
;
pdb
.
set_trace
()
# parse it as an encrypted vote with randomness, and make sure randomness is there
# parse it as an encrypted vote with randomness, and make sure randomness is there
the_ballot
=
utils
.
from_json
(
response
.
testbody
)
the_ballot
=
utils
.
from_json
(
response
.
testbody
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment