Skip to content
Snippets Groups Projects
Unverified Commit 5bfd91a5 authored by millosolomillo's avatar millosolomillo Committed by GitHub
Browse files

Revert "Pulling updated benadida master branch (#6)" (#7)

This reverts commit 9b697dc6.
parent 9b697dc6
Branches
No related tags found
No related merge requests found
Showing
with 151 additions and 321 deletions
......@@ -2,41 +2,16 @@ sudo: false
language: python
python:
- "2.7"
os: linux
before_install:
- export BOTO_CONFIG=/dev/null
# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors
install:
- pip install --upgrade pip
- pip install setuptools==24.3.1
- pip install -r requirements.txt
# command to run tests, e.g. python setup.py test
script: "python manage.py test"
addons:
postgresql: "9.3"
before_script:
- psql -c 'create database helios;' -U postgres
before_install:
- export BOTO_CONFIG=/dev/null
script: "python -Wall manage.py test"
jobs:
include:
- dist: trusty
addons:
postgresql: "9.3"
- dist: trusty
addons:
postgresql: "9.4"
- dist: trusty
addons:
postgresql: "9.5"
- dist: trusty
addons:
postgresql: "9.6"
- dist: xenial
addons:
postgresql: "9.4"
- dist: xenial
addons:
postgresql: "9.5"
- dist: xenial
addons:
postgresql: "9.6"
......@@ -7,5 +7,3 @@ Significant contributors:
- Olivier de Marneffe
- Emily Stark, Mike Hamburg, Tom Wu, and Dan Boneh for SJCL and integration of javascript crypto.
- Nicholas Chang-Fong and Aleksander Essex for security reports and fixes.
- Shirley Chaves
- Marco Ciotola
web: gunicorn wsgi:application -b 0.0.0.0:$PORT -w 8
worker: celery worker --app helios --events --beat --concurrency 1 --logfile celeryw.log --pidfile celeryw.pid
\ No newline at end of file
worker: python manage.py celeryd -E -B --beat --concurrency=1
\ No newline at end of file
......@@ -2,6 +2,6 @@
Helios is an end-to-end verifiable voting system.
[![Travis Build Status](https://travis-ci.org/benadida/helios-server.svg?branch=master)](https://travis-ci.org/benadida/helios-server)
![Travis Build Status](https://travis-ci.org/benadida/helios-server.svg?branch=master)
[![Stories in Ready](https://badge.waffle.io/benadida/helios-server.png?label=ready&title=Ready)](https://waffle.io/benadida/helios-server)
......@@ -5,16 +5,12 @@
# python extract-passwords-for-email.py <election_uuid> <email_address>
#
import sys
from django.core.management import setup_environ
import settings, sys, csv
import csv
import django
import os
setup_environ(settings)
from helios.models import Election
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
django.setup()
from helios.models import *
election_uuid = sys.argv[1]
email = sys.argv[2]
......
from django.conf import settings
# This will make sure the app is always imported when
# Django starts so that shared_task will use this app.
from celery_app import app as celery_app
__all__ = ('celery_app', 'TEMPLATE_BASE', 'ADMIN_ONLY', 'VOTERS_UPLOAD', 'VOTERS_EMAIL',)
from django.core.urlresolvers import reverse
TEMPLATE_BASE = settings.HELIOS_TEMPLATE_BASE or "helios/templates/base.html"
......
from django.apps import AppConfig
class HeliosConfig(AppConfig):
name = 'helios'
verbose_name = "Helios"
import os
# set the default Django settings module for the 'celery' program.
from celery import Celery
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings')
app = Celery()
# Using a string here means the worker doesn't have to serialize
# the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys
# should have a `CELERY_` prefix.
app.config_from_object('django.conf:settings', namespace='CELERY')
# Load task modules from all registered Django app configs.
app.autodiscover_tasks()
@app.task(bind=True)
def debug_task(self):
print('Request: {0!r}'.format(self.request))
......@@ -33,7 +33,7 @@ from helios.crypto import utils as cryptoutils
## utility function
##
def recursiveToDict(obj):
if obj is None:
if obj == None:
return None
if type(obj) == list:
......@@ -53,7 +53,7 @@ def get_class(datatype):
dynamic_module = __import__(".".join(parsed_datatype[:-1]), globals(), locals(), [], level=-1)
if not dynamic_module:
raise Exception("no module for %s" % datatype)
raise Exception("no module for %s" % datatpye)
# go down the attributes to get to the class
try:
......@@ -130,7 +130,7 @@ class LDObject(object):
raise Exception("no datatype found")
# nulls
if obj is None:
if obj == None:
return None
# the class
......@@ -171,7 +171,7 @@ class LDObject(object):
self.structured_fields[f] = sub_ld_object
# set the field on the wrapped object too
if sub_ld_object is not None:
if sub_ld_object != None:
self._setattr_wrapped(f, sub_ld_object.wrapped_obj)
else:
self._setattr_wrapped(f, None)
......@@ -190,7 +190,7 @@ class LDObject(object):
fields = self.FIELDS
if not self.structured_fields:
if self.wrapped_obj.alias is not None:
if self.wrapped_obj.alias != None:
fields = self.ALIASED_VOTER_FIELDS
for f in (alternate_fields or fields):
......@@ -214,7 +214,7 @@ class LDObject(object):
@classmethod
def fromDict(cls, d, type_hint=None):
# null objects
if d is None:
if d == None:
return None
# the LD type is either in d or in type_hint
......@@ -248,11 +248,11 @@ class LDObject(object):
"""
process some fields on the way into the object
"""
if field_value is None:
if field_value == None:
return None
val = self._process_value_in(field_name, field_value)
if val is not None:
if val != None:
return val
else:
return field_value
......@@ -264,11 +264,11 @@ class LDObject(object):
"""
process some fields on the way out of the object
"""
if field_value is None:
if field_value == None:
return None
val = self._process_value_out(field_name, field_value)
if val is not None:
if val != None:
return val
else:
return field_value
......@@ -280,7 +280,7 @@ class LDObject(object):
if not hasattr(self, 'uuid'):
return super(LDObject,self) == other
return other is not None and self.uuid == other.uuid
return other != None and self.uuid == other.uuid
class BaseArrayOfObjects(LDObject):
......
......@@ -6,12 +6,15 @@ http://www.djangosnippets.org/snippets/377/
and adapted to LDObject
"""
import datetime
import json
from django.db import models
from django.db.models import signals
from django.conf import settings
from django.core.serializers.json import DjangoJSONEncoder
from . import LDObject
class LDObjectField(models.TextField):
"""
LDObject is a generic textfield that neatly serializes/unserializes
......@@ -20,6 +23,9 @@ class LDObjectField(models.TextField):
deserialization_params added on 2011-01-09 to provide additional hints at deserialization time
"""
# Used so to_python() is called
__metaclass__ = models.SubfieldBase
def __init__(self, type_hint=None, **kwargs):
self.type_hint = type_hint
super(LDObjectField, self).__init__(**kwargs)
......@@ -31,11 +37,7 @@ class LDObjectField(models.TextField):
if not isinstance(value, basestring):
return value
return self.from_db_value(value)
# noinspection PyUnusedLocal
def from_db_value(self, value, *args, **kwargs):
if value is None:
if value == None:
return None
# in some cases, we're loading an existing array or dict,
......@@ -48,8 +50,8 @@ class LDObjectField(models.TextField):
else:
parsed_value = value
if parsed_value is not None:
# we give the wrapped object back because we're not dealing with serialization types
if parsed_value != None:
"we give the wrapped object back because we're not dealing with serialization types"
return_val = LDObject.fromDict(parsed_value, type_hint = self.type_hint).wrapped_obj
return return_val
else:
......@@ -60,7 +62,7 @@ class LDObjectField(models.TextField):
if isinstance(value, basestring):
return value
if value is None:
if value == None:
return None
# instantiate the proper LDObject to dump it appropriately
......@@ -69,4 +71,4 @@ class LDObjectField(models.TextField):
def value_to_string(self, obj):
value = self._get_val_from_obj(obj)
return self.get_db_prep_value(value, None)
return self.get_db_prep_value(value)
......@@ -77,7 +77,7 @@ class Voter(LegacyObject):
"""
depending on whether the voter is aliased, use different fields
"""
if self.wrapped_obj.alias is not None:
if self.wrapped_obj.alias != None:
return super(Voter, self).toDict(self.ALIASED_VOTER_FIELDS, complete = complete)
else:
return super(Voter,self).toDict(complete = complete)
......
......@@ -25,8 +25,6 @@ calbtn = u'''<img src="%smedia/admin/img/admin/icon_calendar.gif" alt="calendar"
</script>'''
class DateTimeWidget(forms.widgets.TextInput):
template_name = ''
class Media:
css = {
'all': (
......
ELECTION_HOME="election@home"
ELECTION_VIEW="election@view"
ELECTION_META="election@meta"
ELECTION_EDIT="election@edit"
ELECTION_SCHEDULE="election@schedule"
ELECTION_EXTEND="election@extend"
ELECTION_ARCHIVE="election@archive"
ELECTION_COPY="election@copy"
ELECTION_BADGE="election@badge"
ELECTION_TRUSTEES_HOME="election@trustees"
ELECTION_TRUSTEES_VIEW="election@trustees@view"
ELECTION_TRUSTEES_NEW="election@trustees@new"
ELECTION_TRUSTEES_ADD_HELIOS="election@trustees@add-helios"
ELECTION_TRUSTEES_DELETE="election@trustees@delete"
ELECTION_TRUSTEE_HOME="election@trustee"
ELECTION_TRUSTEE_SEND_URL="election@trustee@send-url"
ELECTION_TRUSTEE_KEY_GENERATOR="election@trustee@key-generator"
ELECTION_TRUSTEE_CHECK_SK="election@trustee@check-sk"
ELECTION_TRUSTEE_UPLOAD_PK="election@trustee@upload-pk"
ELECTION_TRUSTEE_DECRYPT_AND_PROVE="election@trustee@decrypt-and-prove"
ELECTION_TRUSTEE_UPLOAD_DECRYPTION="election@trustee@upload-decryption"
ELECTION_RESULT="election@result"
ELECTION_RESULT_PROOF="election@result@proof"
ELECTION_BBOARD="election@bboard"
ELECTION_AUDITED_BALLOTS="election@audited-ballots"
ELECTION_GET_RANDOMNESS="election@get-randomness"
ELECTION_ENCRYPT_BALLOT="election@encrypt-ballot"
ELECTION_QUESTIONS="election@questions"
ELECTION_SET_REG="election@set-reg"
ELECTION_SET_FEATURED="election@set-featured"
ELECTION_SAVE_QUESTIONS="election@save-questions"
ELECTION_REGISTER="election@register"
ELECTION_FREEZE="election@freeze"
ELECTION_COMPUTE_TALLY="election@compute-tally"
ELECTION_COMBINE_DECRYPTIONS="election@combine-decryptions"
ELECTION_RELEASE_RESULT="election@release-result"
ELECTION_CAST="election@cast"
ELECTION_CAST_CONFIRM="election@cast-confirm"
ELECTION_PASSWORD_VOTER_LOGIN="election@password-voter-login"
ELECTION_CAST_DONE="election@cast-done"
ELECTION_POST_AUDITED_BALLOT="election@post-audited-ballot"
ELECTION_VOTERS_HOME="election@voters"
ELECTION_VOTERS_UPLOAD="election@voters@upload"
ELECTION_VOTERS_UPLOAD_CANCEL="election@voters@upload-cancel"
ELECTION_VOTERS_LIST="election@voters@list"
ELECTION_VOTERS_LIST_PRETTY="election@voters@list-pretty"
ELECTION_VOTERS_ELIGIBILITY="election@voters@eligibility"
ELECTION_VOTERS_EMAIL="election@voters@email"
ELECTION_VOTER="election@voter"
ELECTION_VOTER_DELETE="election@voter@delete"
ELECTION_BALLOTS_LIST="election@ballots@list"
ELECTION_BALLOTS_VOTER="election@ballots@voter"
ELECTION_BALLOTS_VOTER_LAST="election@ballots@voter@last"
......@@ -4,99 +4,91 @@ Helios URLs for Election related stuff
Ben Adida (ben@adida.net)
"""
from django.conf.urls import url
from django.conf.urls import *
from helios import views
from helios import election_url_names as names
from helios.views import *
urlpatterns = [
urlpatterns = patterns('',
# election data that is cryptographically verified
url(r'^$', views.one_election, name=names.ELECTION_HOME),
(r'^$', one_election),
# metadata that need not be verified
url(r'^/meta$', views.one_election_meta, name=names.ELECTION_META),
(r'^/meta$', one_election_meta),
# edit election params
url(r'^/edit$', views.one_election_edit, name=names.ELECTION_EDIT),
url(r'^/schedule$', views.one_election_schedule, name=names.ELECTION_SCHEDULE),
url(r'^/extend$', views.one_election_extend, name=names.ELECTION_EXTEND),
url(r'^/archive$', views.one_election_archive, name=names.ELECTION_ARCHIVE),
url(r'^/copy$', views.one_election_copy, name=names.ELECTION_COPY),
(r'^/edit$', one_election_edit),
(r'^/schedule$', one_election_schedule),
(r'^/extend$', one_election_extend),
(r'^/archive$', one_election_archive),
(r'^/copy$', one_election_copy),
# badge
url(r'^/badge$', views.election_badge, name=names.ELECTION_BADGE),
(r'^/badge$', election_badge),
# adding trustees
url(r'^/trustees/$', views.list_trustees, name=names.ELECTION_TRUSTEES_HOME),
url(r'^/trustees/view$', views.list_trustees_view, name=names.ELECTION_TRUSTEES_VIEW),
url(r'^/trustees/new$', views.new_trustee, name=names.ELECTION_TRUSTEES_NEW),
url(r'^/trustees/add-helios$', views.new_trustee_helios, name=names.ELECTION_TRUSTEES_ADD_HELIOS),
url(r'^/trustees/delete$', views.delete_trustee, name=names.ELECTION_TRUSTEES_DELETE),
(r'^/trustees/$', list_trustees),
(r'^/trustees/view$', list_trustees_view),
(r'^/trustees/new$', new_trustee),
(r'^/trustees/add-helios$', new_trustee_helios),
(r'^/trustees/delete$', delete_trustee),
# trustee pages
url(r'^/trustees/(?P<trustee_uuid>[^/]+)/home$',
views.trustee_home, name=names.ELECTION_TRUSTEE_HOME),
url(r'^/trustees/(?P<trustee_uuid>[^/]+)/sendurl$',
views.trustee_send_url, name=names.ELECTION_TRUSTEE_SEND_URL),
url(r'^/trustees/(?P<trustee_uuid>[^/]+)/keygenerator$',
views.trustee_keygenerator, name=names.ELECTION_TRUSTEE_KEY_GENERATOR),
url(r'^/trustees/(?P<trustee_uuid>[^/]+)/check-sk$',
views.trustee_check_sk, name=names.ELECTION_TRUSTEE_CHECK_SK),
url(r'^/trustees/(?P<trustee_uuid>[^/]+)/upoad-pk$',
views.trustee_upload_pk, name=names.ELECTION_TRUSTEE_UPLOAD_PK),
url(r'^/trustees/(?P<trustee_uuid>[^/]+)/decrypt-and-prove$',
views.trustee_decrypt_and_prove, name=names.ELECTION_TRUSTEE_DECRYPT_AND_PROVE),
url(r'^/trustees/(?P<trustee_uuid>[^/]+)/upload-decryption$',
views.trustee_upload_decryption, name=names.ELECTION_TRUSTEE_UPLOAD_DECRYPTION),
(r'^/trustees/(?P<trustee_uuid>[^/]+)/home$', trustee_home),
(r'^/trustees/(?P<trustee_uuid>[^/]+)/sendurl$', trustee_send_url),
(r'^/trustees/(?P<trustee_uuid>[^/]+)/keygenerator$', trustee_keygenerator),
(r'^/trustees/(?P<trustee_uuid>[^/]+)/check-sk$', trustee_check_sk),
(r'^/trustees/(?P<trustee_uuid>[^/]+)/upoad-pk$', trustee_upload_pk),
(r'^/trustees/(?P<trustee_uuid>[^/]+)/decrypt-and-prove$', trustee_decrypt_and_prove),
(r'^/trustees/(?P<trustee_uuid>[^/]+)/upload-decryption$', trustee_upload_decryption),
# election voting-process actions
url(r'^/view$', views.one_election_view, name=names.ELECTION_VIEW),
url(r'^/result$', views.one_election_result, name=names.ELECTION_RESULT),
url(r'^/result_proof$', views.one_election_result_proof, name=names.ELECTION_RESULT_PROOF),
# url(r'^/bboard$', views.one_election_bboard, name=names.ELECTION_BBOARD),
url(r'^/audited-ballots/$', views.one_election_audited_ballots, name=names.ELECTION_AUDITED_BALLOTS),
(r'^/view$', one_election_view),
(r'^/result$', one_election_result),
(r'^/result_proof$', one_election_result_proof),
# (r'^/bboard$', one_election_bboard),
(r'^/audited-ballots/$', one_election_audited_ballots),
# get randomness
url(r'^/get-randomness$', views.get_randomness, name=names.ELECTION_GET_RANDOMNESS),
(r'^/get-randomness$', get_randomness),
# server-side encryption
url(r'^/encrypt-ballot$', views.encrypt_ballot, name=names.ELECTION_ENCRYPT_BALLOT),
(r'^/encrypt-ballot$', encrypt_ballot),
# construct election
url(r'^/questions$', views.one_election_questions, name=names.ELECTION_QUESTIONS),
url(r'^/set_reg$', views.one_election_set_reg, name=names.ELECTION_SET_REG),
url(r'^/set_featured$', views.one_election_set_featured, name=names.ELECTION_SET_FEATURED),
url(r'^/save_questions$', views.one_election_save_questions, name=names.ELECTION_SAVE_QUESTIONS),
url(r'^/register$', views.one_election_register, name=names.ELECTION_REGISTER),
url(r'^/freeze$', views.one_election_freeze, name=names.ELECTION_FREEZE), # includes freeze_2 as POST target
(r'^/questions$', one_election_questions),
(r'^/set_reg$', one_election_set_reg),
(r'^/set_featured$', one_election_set_featured),
(r'^/save_questions$', one_election_save_questions),
(r'^/register$', one_election_register),
(r'^/freeze$', one_election_freeze), # includes freeze_2 as POST target
# computing tally
url(r'^/compute_tally$', views.one_election_compute_tally, name=names.ELECTION_COMPUTE_TALLY),
url(r'^/combine_decryptions$', views.combine_decryptions, name=names.ELECTION_COMBINE_DECRYPTIONS),
url(r'^/release_result$', views.release_result, name=names.ELECTION_RELEASE_RESULT),
(r'^/compute_tally$', one_election_compute_tally),
(r'^/combine_decryptions$', combine_decryptions),
(r'^/release_result$', release_result),
# casting a ballot before we know who the voter is
url(r'^/cast$', views.one_election_cast, name=names.ELECTION_CAST),
url(r'^/cast_confirm$', views.one_election_cast_confirm, name=names.ELECTION_CAST_CONFIRM),
url(r'^/password_voter_login$', views.password_voter_login, name=names.ELECTION_PASSWORD_VOTER_LOGIN),
url(r'^/cast_done$', views.one_election_cast_done, name=names.ELECTION_CAST_DONE),
(r'^/cast$', one_election_cast),
(r'^/cast_confirm$', one_election_cast_confirm),
(r'^/password_voter_login$', password_voter_login),
(r'^/cast_done$', one_election_cast_done),
# post audited ballot
url(r'^/post-audited-ballot', views.post_audited_ballot, name=names.ELECTION_POST_AUDITED_BALLOT),
(r'^/post-audited-ballot', post_audited_ballot),
# managing voters
url(r'^/voters/$', views.voter_list, name=names.ELECTION_VOTERS_LIST),
url(r'^/voters/upload$', views.voters_upload, name=names.ELECTION_VOTERS_UPLOAD),
url(r'^/voters/upload-cancel$', views.voters_upload_cancel, name=names.ELECTION_VOTERS_UPLOAD_CANCEL),
url(r'^/voters/list$', views.voters_list_pretty, name=names.ELECTION_VOTERS_LIST_PRETTY),
url(r'^/voters/eligibility$', views.voters_eligibility, name=names.ELECTION_VOTERS_ELIGIBILITY),
url(r'^/voters/email$', views.voters_email, name=names.ELECTION_VOTERS_EMAIL),
url(r'^/voters/(?P<voter_uuid>[^/]+)$', views.one_voter, name=names.ELECTION_VOTER),
url(r'^/voters/(?P<voter_uuid>[^/]+)/delete$', views.voter_delete, name=names.ELECTION_VOTER_DELETE),
(r'^/voters/$', voter_list),
(r'^/voters/upload$', voters_upload),
(r'^/voters/upload-cancel$', voters_upload_cancel),
(r'^/voters/list$', voters_list_pretty),
(r'^/voters/eligibility$', voters_eligibility),
(r'^/voters/email$', voters_email),
(r'^/voters/(?P<voter_uuid>[^/]+)$', one_voter),
(r'^/voters/(?P<voter_uuid>[^/]+)/delete$', voter_delete),
# ballots
url(r'^/ballots/$', views.ballot_list, name=names.ELECTION_BALLOTS_LIST),
url(r'^/ballots/(?P<voter_uuid>[^/]+)/all$', views.voter_votes, name=names.ELECTION_BALLOTS_VOTER),
url(r'^/ballots/(?P<voter_uuid>[^/]+)/last$', views.voter_last_vote, name=names.ELECTION_BALLOTS_VOTER_LAST),
(r'^/ballots/$', ballot_list),
(r'^/ballots/(?P<voter_uuid>[^/]+)/all$', voter_votes),
(r'^/ballots/(?P<voter_uuid>[^/]+)/last$', voter_last_vote),
]
)
[
{
"pk": 1,
"model": "helios_auth.user",
"fields": {
"info": "{}",
"user_id": "ben@adida.net",
"name": "Ben Adida",
"user_type": "google",
"token": null,
"admin_p": false
}
},
{
"pk": 2,
"model": "helios_auth.user",
"fields": {
"info": "{}",
"user_id": "12345",
"name": "Ben Adida",
"user_type": "facebook",
"token": {
"access_token": "1234"
},
"admin_p": false
}
},
{
"pk": 3,
"model": "helios_auth.user",
"fields": {
"info": "{}",
"user_id": "mccio@github.com",
"name": "Marco Ciotola",
"user_type": "google",
"token": null,
"admin_p": true
}
}
]
\ No newline at end of file
[{"pk": 1, "model": "helios_auth.user", "fields": {"info": "{}", "user_id": "ben@adida.net", "name": "Ben Adida", "user_type": "google", "token": null, "admin_p": false}},{"pk": 2, "model": "helios_auth.user", "fields": {"info": "{}", "user_id": "12345", "name": "Ben Adida", "user_type": "facebook", "token": {"access_token":"1234"}, "admin_p": false}}]
\ No newline at end of file
......@@ -4,8 +4,8 @@ Forms for Helios
from django import forms
from models import Election
from widgets import SplitSelectDateTimeWidget
from fields import SplitDateTimeField
from widgets import *
from fields import *
from django.conf import settings
......
......@@ -8,10 +8,12 @@ ben@adida.net
2010-05-22
"""
from django.core.management.base import BaseCommand
from django.core.management.base import BaseCommand, CommandError
import csv, datetime
from helios.models import Trustee
from helios import utils as helios_utils
from helios.models import *
class Command(BaseCommand):
args = ''
......
......@@ -8,15 +8,12 @@ ben@adida.net
2010-05-22
"""
import datetime
import csv
import uuid
from django.core.management.base import BaseCommand
from django.core.management.base import BaseCommand, CommandError
import csv, datetime
from helios import utils as helios_utils
from helios.models import User, Voter, VoterFile
from helios.models import *
##
## UTF8 craziness for CSV
......@@ -30,12 +27,10 @@ def unicode_csv_reader(unicode_csv_data, dialect=csv.excel, **kwargs):
# decode UTF-8 back to Unicode, cell by cell:
yield [unicode(cell, 'utf-8') for cell in row]
def utf_8_encoder(unicode_csv_data):
for line in unicode_csv_data:
yield line.encode('utf-8')
def process_csv_file(election, f):
reader = unicode_csv_reader(f)
......@@ -57,8 +52,7 @@ def process_csv_file(election, f):
name = voter[2]
# create the user
user = User.update_or_create(user_type='password', user_id=voter_id,
info={'password': helios_utils.random_string(10), 'email': email, 'name': name})
user = User.update_or_create(user_type='password', user_id=voter_id, info = {'password': helios_utils.random_string(10), 'email': email, 'name': name})
user.save()
# does voter for this user already exist
......@@ -92,3 +86,5 @@ class Command(BaseCommand):
file_to_process.processing_finished_at = datetime.datetime.utcnow()
file_to_process.num_voters = num_voters
file_to_process.save()
......@@ -6,10 +6,12 @@ ben@adida.net
2010-05-22
"""
from django.core.management.base import BaseCommand
from django.core.management.base import BaseCommand, CommandError
import csv, datetime
from helios.models import CastVote
from helios import utils as helios_utils
from helios.models import *
def get_cast_vote_to_verify():
# fixme: add "select for update" functionality here
......
......@@ -87,7 +87,7 @@ class Migration(migrations.Migration):
('result_proof', helios_auth.jsonfield.JSONField(null=True)),
('help_email', models.EmailField(max_length=75, null=True)),
('election_info_url', models.CharField(max_length=300, null=True)),
('admin', models.ForeignKey(to='helios_auth.User', on_delete=models.CASCADE)),
('admin', models.ForeignKey(to='helios_auth.User')),
],
options={
'abstract': False,
......@@ -100,7 +100,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('log', models.CharField(max_length=500)),
('at', models.DateTimeField(auto_now_add=True)),
('election', models.ForeignKey(to='helios.Election', on_delete=models.CASCADE)),
('election', models.ForeignKey(to='helios.Election')),
],
options={
},
......@@ -120,7 +120,7 @@ class Migration(migrations.Migration):
('pok', helios.datatypes.djangofield.LDObjectField(null=True)),
('decryption_factors', helios.datatypes.djangofield.LDObjectField(null=True)),
('decryption_proofs', helios.datatypes.djangofield.LDObjectField(null=True)),
('election', models.ForeignKey(to='helios.Election', on_delete=models.CASCADE)),
('election', models.ForeignKey(to='helios.Election')),
],
options={
},
......@@ -139,8 +139,8 @@ class Migration(migrations.Migration):
('vote', helios.datatypes.djangofield.LDObjectField(null=True)),
('vote_hash', models.CharField(max_length=100, null=True)),
('cast_at', models.DateTimeField(null=True)),
('election', models.ForeignKey(to='helios.Election', on_delete=models.CASCADE)),
('user', models.ForeignKey(to='helios_auth.User', null=True, on_delete=models.CASCADE)),
('election', models.ForeignKey(to='helios.Election')),
('user', models.ForeignKey(to='helios_auth.User', null=True)),
],
options={
},
......@@ -156,7 +156,7 @@ class Migration(migrations.Migration):
('processing_started_at', models.DateTimeField(null=True)),
('processing_finished_at', models.DateTimeField(null=True)),
('num_voters', models.IntegerField(null=True)),
('election', models.ForeignKey(to='helios.Election', on_delete=models.CASCADE)),
('election', models.ForeignKey(to='helios.Election')),
],
options={
},
......@@ -173,13 +173,13 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='castvote',
name='voter',
field=models.ForeignKey(to='helios.Voter', on_delete=models.CASCADE),
field=models.ForeignKey(to='helios.Voter'),
preserve_default=True,
),
migrations.AddField(
model_name='auditedballot',
name='election',
field=models.ForeignKey(to='helios.Election', on_delete=models.CASCADE),
field=models.ForeignKey(to='helios.Election'),
preserve_default=True,
),
]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment