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
420e05bc
Commit
420e05bc
authored
14 years ago
by
Ben Adida
Browse files
Options
Downloads
Patches
Plain Diff
tweaked migration, started adding quarantined cast votes
parent
76d20bf1
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
helios/migrations/0002_v3_1_new_election_and_voter_fields.py
+2
-1
2 additions, 1 deletion
helios/migrations/0002_v3_1_new_election_and_voter_fields.py
helios/models.py
+19
-0
19 additions, 0 deletions
helios/models.py
helios/tests.py
+13
-0
13 additions, 0 deletions
helios/tests.py
with
34 additions
and
1 deletion
helios/migrations/0002_v3_1_new_election_and_voter_fields.py
+
2
−
1
View file @
420e05bc
...
@@ -24,7 +24,8 @@ class Migration(SchemaMigration):
...
@@ -24,7 +24,8 @@ class Migration(SchemaMigration):
db
.
add_column
(
'
helios_voter
'
,
'
voter_email
'
,
self
.
gf
(
'
django.db.models.fields.CharField
'
)(
max_length
=
250
,
null
=
True
),
keep_default
=
False
)
db
.
add_column
(
'
helios_voter
'
,
'
voter_email
'
,
self
.
gf
(
'
django.db.models.fields.CharField
'
)(
max_length
=
250
,
null
=
True
),
keep_default
=
False
)
# Adding field 'Election.datatype'
# Adding field 'Election.datatype'
db
.
add_column
(
'
helios_election
'
,
'
datatype
'
,
self
.
gf
(
'
django.db.models.fields.CharField
'
)(
default
=
'
2011/01/election
'
,
max_length
=
250
),
keep_default
=
False
)
# manually tweaked default value to ensure proper datatype for older elections
db
.
add_column
(
'
helios_election
'
,
'
datatype
'
,
self
.
gf
(
'
django.db.models.fields.CharField
'
)(
default
=
'
legacy/election
'
,
max_length
=
250
),
keep_default
=
False
)
# Adding field 'Election.election_type'
# Adding field 'Election.election_type'
db
.
add_column
(
'
helios_election
'
,
'
election_type
'
,
self
.
gf
(
'
django.db.models.fields.CharField
'
)(
default
=
'
election
'
,
max_length
=
250
),
keep_default
=
False
)
db
.
add_column
(
'
helios_election
'
,
'
election_type
'
,
self
.
gf
(
'
django.db.models.fields.CharField
'
)(
default
=
'
election
'
,
max_length
=
250
),
keep_default
=
False
)
...
...
This diff is collapsed.
Click to expand it.
helios/models.py
+
19
−
0
View file @
420e05bc
...
@@ -87,6 +87,13 @@ class Election(models.Model, electionalgs.Election):
...
@@ -87,6 +87,13 @@ class Election(models.Model, electionalgs.Election):
registration_starts_at
=
models
.
DateTimeField
(
auto_now_add
=
False
,
default
=
None
,
null
=
True
)
registration_starts_at
=
models
.
DateTimeField
(
auto_now_add
=
False
,
default
=
None
,
null
=
True
)
voting_starts_at
=
models
.
DateTimeField
(
auto_now_add
=
False
,
default
=
None
,
null
=
True
)
voting_starts_at
=
models
.
DateTimeField
(
auto_now_add
=
False
,
default
=
None
,
null
=
True
)
voting_ends_at
=
models
.
DateTimeField
(
auto_now_add
=
False
,
default
=
None
,
null
=
True
)
voting_ends_at
=
models
.
DateTimeField
(
auto_now_add
=
False
,
default
=
None
,
null
=
True
)
# if this is non-null, then a complaint period, where people can cast a quarantined ballot.
# we do NOT call this a "provisional" ballot, since provisional implies that the voter has not
# been qualified. We may eventually add this, but it can't be in the same CastVote table, which
# is tied to a voter.
complaint_period_ends_at
=
models
.
DateTimeField
(
auto_now_add
=
False
,
default
=
None
,
null
=
True
)
tallying_starts_at
=
models
.
DateTimeField
(
auto_now_add
=
False
,
default
=
None
,
null
=
True
)
tallying_starts_at
=
models
.
DateTimeField
(
auto_now_add
=
False
,
default
=
None
,
null
=
True
)
# dates when things were forced to be performed
# dates when things were forced to be performed
...
@@ -730,6 +737,10 @@ class CastVote(models.Model, electionalgs.CastVote):
...
@@ -730,6 +737,10 @@ class CastVote(models.Model, electionalgs.CastVote):
cast_at
=
models
.
DateTimeField
(
auto_now_add
=
True
)
cast_at
=
models
.
DateTimeField
(
auto_now_add
=
True
)
# some ballots can be quarantined (this is not the same thing as provisional)
quarantined_p
=
modelsBooleanField
(
default
=
False
,
null
=
False
)
released_from_quarantine_at
=
models
.
DateTimeField
(
auto_now_add
=
False
,
null
=
True
)
# when is the vote verified?
# when is the vote verified?
verified_at
=
models
.
DateTimeField
(
null
=
True
)
verified_at
=
models
.
DateTimeField
(
null
=
True
)
invalidated_at
=
models
.
DateTimeField
(
null
=
True
)
invalidated_at
=
models
.
DateTimeField
(
null
=
True
)
...
@@ -742,6 +753,10 @@ class CastVote(models.Model, electionalgs.CastVote):
...
@@ -742,6 +753,10 @@ class CastVote(models.Model, electionalgs.CastVote):
def
voter_hash
(
self
):
def
voter_hash
(
self
):
return
self
.
voter
.
hash
return
self
.
voter
.
hash
@property
def
is_quarantined
(
self
):
return
self
.
quarantined_p
and
not
self
.
released_from_quarantine_at
def
set_tinyhash
(
self
):
def
set_tinyhash
(
self
):
"""
"""
find a tiny version of the hash for a URL slug.
find a tiny version of the hash for a URL slug.
...
@@ -774,6 +789,10 @@ class CastVote(models.Model, electionalgs.CastVote):
...
@@ -774,6 +789,10 @@ class CastVote(models.Model, electionalgs.CastVote):
return
cls
.
objects
.
filter
(
voter
=
voter
).
order_by
(
'
-cast_at
'
)
return
cls
.
objects
.
filter
(
voter
=
voter
).
order_by
(
'
-cast_at
'
)
def
verify_and_store
(
self
):
def
verify_and_store
(
self
):
# if it's quarantined, don't let this go through
if
self
.
is_quarantined
:
raise
Exception
(
"
cast vote is quarantined, verification and storage is delayed.
"
)
result
=
self
.
vote
.
verify
(
self
.
voter
.
election
)
result
=
self
.
vote
.
verify
(
self
.
voter
.
election
)
if
result
:
if
result
:
...
...
This diff is collapsed.
Click to expand it.
helios/tests.py
+
13
−
0
View file @
420e05bc
...
@@ -200,6 +200,19 @@ class VoterModelTests(TestCase):
...
@@ -200,6 +200,19 @@ class VoterModelTests(TestCase):
# check that you can get at the voter user structure
# check that you can get at the voter user structure
self
.
assertEquals
(
v
.
user
.
user_id
,
v
.
voter_email
)
self
.
assertEquals
(
v
.
user
.
user_id
,
v
.
voter_email
)
class
CastVoteModelTests
(
TestCase
):
fixtures
=
[
'
users.json
'
,
'
election.json
'
]
def
setUp
(
self
):
self
.
election
=
models
.
Election
.
objects
.
get
(
short_name
=
'
test
'
)
self
.
user
=
auth_models
.
User
.
objects
.
get
(
user_id
=
'
ben@adida.net
'
,
user_type
=
'
google
'
)
# register the voter
self
.
voter
=
models
.
Voter
.
register_user_in_election
(
self
.
user
,
self
.
election
)
def
test_cast_vote
(
self
):
assert
False
##
##
## Black box tests
## Black box tests
##
##
...
...
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