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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
Helios Server
Commits
7baef125
Commit
7baef125
authored
14 years ago
by
Ben Adida
Browse files
Options
Downloads
Patches
Plain Diff
added better error reporting for missing uploaded voter file
parent
7d00d841
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/templates/voters_upload.html
+11
-2
11 additions, 2 deletions
helios/templates/voters_upload.html
helios/views.py
+11
-8
11 additions, 8 deletions
helios/views.py
with
22 additions
and
10 deletions
helios/templates/voters_upload.html
+
11
−
2
View file @
7baef125
...
@@ -5,14 +5,23 @@
...
@@ -5,14 +5,23 @@
<form
method=
"post"
action=
""
id=
"upload_form"
enctype=
"multipart/form-data"
>
<form
method=
"post"
action=
""
id=
"upload_form"
enctype=
"multipart/form-data"
>
<p>
<p>
If your election allows for password-based voters, then you can bulk upload them here.
<br
/>
If you would like to specify your list of voters by name and email address,
<br
/>
Please enter CSV content for your list of voters as follows:
you can bulk upload a list of such voters here.
<br
/><br
/>
Please prepare a text file of comma-separated values, as follows:
</p>
</p>
<pre>
<pre>
benadida,ben@adida.net,Ben Adida
benadida,ben@adida.net,Ben Adida
bob,bob@acme.org,Bob Acme
bob,bob@acme.org,Bob Acme
...
...
</pre>
</pre>
<p>
The easiest way to prepare such a file is to use a spreadsheet program and to export as "CSV".
</p>
{% if error %}
<div
style=
"color: red;"
>
{{error}}
</div>
{% endif %}
<input
type=
"hidden"
name=
"csrf_token"
value=
"{{csrf_token}}"
/>
<input
type=
"hidden"
name=
"csrf_token"
value=
"{{csrf_token}}"
/>
<input
type=
"file"
name=
"voters_file"
/>
<input
type=
"file"
name=
"voters_file"
/>
...
...
This diff is collapsed.
Click to expand it.
helios/views.py
+
11
−
8
View file @
7baef125
...
@@ -1142,7 +1142,7 @@ def voters_upload(request, election):
...
@@ -1142,7 +1142,7 @@ def voters_upload(request, election):
# raise PermissionDenied()
# raise PermissionDenied()
if
request
.
method
==
"
GET
"
:
if
request
.
method
==
"
GET
"
:
return
render_template
(
request
,
'
voters_upload
'
,
{
'
election
'
:
election
})
return
render_template
(
request
,
'
voters_upload
'
,
{
'
election
'
:
election
,
'
error
'
:
request
.
GET
.
get
(
'
e
'
,
None
)
})
if
request
.
method
==
"
POST
"
:
if
request
.
method
==
"
POST
"
:
if
bool
(
request
.
POST
.
get
(
'
confirm_p
'
,
0
)):
if
bool
(
request
.
POST
.
get
(
'
confirm_p
'
,
0
)):
...
@@ -1153,6 +1153,7 @@ def voters_upload(request, election):
...
@@ -1153,6 +1153,7 @@ def voters_upload(request, election):
return
HttpResponseRedirect
(
reverse
(
voters_list_pretty
,
args
=
[
election
.
uuid
]))
return
HttpResponseRedirect
(
reverse
(
voters_list_pretty
,
args
=
[
election
.
uuid
]))
else
:
else
:
# we need to confirm
# we need to confirm
if
request
.
FILES
.
has_key
(
'
voters_file
'
):
voters_file
=
request
.
FILES
[
'
voters_file
'
]
voters_file
=
request
.
FILES
[
'
voters_file
'
]
voter_file_obj
=
election
.
add_voters_file
(
voters_file
)
voter_file_obj
=
election
.
add_voters_file
(
voters_file
)
...
@@ -1162,6 +1163,8 @@ def voters_upload(request, election):
...
@@ -1162,6 +1163,8 @@ def voters_upload(request, election):
voters
=
[
v
for
v
in
voter_file_obj
.
itervoters
()][:
5
]
voters
=
[
v
for
v
in
voter_file_obj
.
itervoters
()][:
5
]
return
render_template
(
request
,
'
voters_upload_confirm
'
,
{
'
election
'
:
election
,
'
voters
'
:
voters
})
return
render_template
(
request
,
'
voters_upload_confirm
'
,
{
'
election
'
:
election
,
'
voters
'
:
voters
})
else
:
return
HttpResponseRedirect
(
"
%s?%s
"
%
(
reverse
(
voters_upload
,
args
=
[
election
.
uuid
]),
urllib
.
urlencode
({
'
e
'
:
'
no voter file specified, try again
'
})))
@election_admin
()
@election_admin
()
def
voters_upload_cancel
(
request
,
election
):
def
voters_upload_cancel
(
request
,
election
):
...
...
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