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
42ba703f
Commit
42ba703f
authored
14 years ago
by
Ben Adida
Browse files
Options
Downloads
Patches
Plain Diff
updated voters to be properly linked to users, and fixed issues along the way
parent
7ce7a156
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
+25
-5
25 additions, 5 deletions
helios/models.py
helios/views.py
+1
-1
1 addition, 1 deletion
helios/views.py
with
26 additions
and
6 deletions
helios/models.py
+
25
−
5
View file @
42ba703f
...
...
@@ -542,16 +542,15 @@ class VoterFile(models.Model):
class
Voter
(
models
.
Model
,
electionalgs
.
Voter
):
election
=
models
.
ForeignKey
(
Election
)
name
=
models
.
CharField
(
max_length
=
200
,
null
=
True
)
# let's link directly to the user now
# voter_type = models.CharField(max_length = 100)
user
=
models
.
ForeignKey
(
'
auth.User
'
,
null
=
True
)
# if user is null, then you need a voter login ID and password
voter_id
=
models
.
CharField
(
max_length
=
100
,
null
=
True
)
voter_
login_
id
=
models
.
CharField
(
max_length
=
100
,
null
=
True
)
voter_password
=
models
.
CharField
(
max_length
=
100
,
null
=
True
)
voter_name
=
models
.
CharField
(
max_length
=
200
,
null
=
True
)
uuid
=
models
.
CharField
(
max_length
=
50
)
...
...
@@ -567,7 +566,7 @@ class Voter(models.Model, electionalgs.Voter):
@transaction.commit_on_success
def
register_user_in_election
(
cls
,
user
,
election
):
voter_uuid
=
str
(
uuid
.
uuid4
())
voter
=
Voter
(
uuid
=
voter_uuid
,
user
=
user
,
election
=
election
,
name
=
user
.
name
)
voter
=
Voter
(
uuid
=
voter_uuid
,
user
=
user
,
election
=
election
)
# do we need to generate an alias?
if
election
.
use_voter_aliases
:
...
...
@@ -617,7 +616,7 @@ class Voter(models.Model, electionalgs.Voter):
@classmethod
def
get_by_election_and_voter_id
(
cls
,
election
,
voter_id
):
query
=
cls
.
objects
.
filter
(
election
=
election
,
voter_id
=
voter_id
)
query
=
cls
.
objects
.
filter
(
election
=
election
,
voter_
login_
id
=
voter_id
)
try
:
return
query
[
0
]
...
...
@@ -650,6 +649,27 @@ class Voter(models.Model, electionalgs.Voter):
def
election_uuid
(
self
):
return
self
.
election
.
uuid
@property
def
name
(
self
):
if
self
.
user
:
return
self
.
user
.
name
else
:
return
self
.
voter_name
@property
def
voter_id
(
self
):
if
self
.
user
:
return
self
.
user
.
user_id
else
:
return
self
.
voter_login_id
@property
def
voter_type
(
self
):
if
self
.
user
:
return
self
.
user
.
user_type
else
:
return
'
password
'
def
store_vote
(
self
,
cast_vote
):
# only store the vote if it's cast later than the current one
if
self
.
cast_at
and
cast_vote
.
cast_at
<
self
.
cast_at
:
...
...
This diff is collapsed.
Click to expand it.
helios/views.py
+
1
−
1
View file @
42ba703f
...
...
@@ -951,7 +951,7 @@ def voters_list_pretty(request, election):
limit
=
int
(
request
.
GET
.
get
(
'
limit
'
,
50
))
q
=
request
.
GET
.
get
(
'
q
'
,
''
)
order_by
=
'
vot
er_id
'
order_by
=
'
user__us
er_id
'
# unless it's by alias, in which case we better go by UUID
if
election
.
use_voter_aliases
:
...
...
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