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
fb996233
Commit
fb996233
authored
14 years ago
by
Ben Adida
Browse files
Options
Downloads
Patches
Plain Diff
continued voter data model changes
parent
ca54abef
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
+18
-10
18 additions, 10 deletions
helios/models.py
helios/stats_views.py
+1
-1
1 addition, 1 deletion
helios/stats_views.py
with
19 additions
and
11 deletions
helios/models.py
+
18
−
10
View file @
fb996233
...
@@ -319,7 +319,11 @@ class Election(models.Model, electionalgs.Election):
...
@@ -319,7 +319,11 @@ class Election(models.Model, electionalgs.Election):
return
return
auth_systems
=
copy
.
copy
(
settings
.
AUTH_ENABLED_AUTH_SYSTEMS
)
auth_systems
=
copy
.
copy
(
settings
.
AUTH_ENABLED_AUTH_SYSTEMS
)
voter_types
=
[
r
[
'
voter_type
'
]
for
r
in
self
.
voter_set
.
values
(
'
voter_type
'
).
distinct
()]
voter_types
=
[
r
[
'
user__user_type
'
]
for
r
in
self
.
voter_set
.
values
(
'
user__user_type
'
).
distinct
()]
# password is now separate, not an explicit voter type
if
self
.
voter_set
.
filter
(
user
=
None
).
count
()
>
0
:
voter_types
.
append
(
'
password
'
)
if
self
.
openreg
:
if
self
.
openreg
:
if
not
'
password
'
in
voter_types
and
'
password
'
in
auth_systems
:
if
not
'
password
'
in
voter_types
and
'
password
'
in
auth_systems
:
...
@@ -539,8 +543,16 @@ class Voter(models.Model, electionalgs.Voter):
...
@@ -539,8 +543,16 @@ class Voter(models.Model, electionalgs.Voter):
election
=
models
.
ForeignKey
(
Election
)
election
=
models
.
ForeignKey
(
Election
)
name
=
models
.
CharField
(
max_length
=
200
,
null
=
True
)
name
=
models
.
CharField
(
max_length
=
200
,
null
=
True
)
voter_type
=
models
.
CharField
(
max_length
=
100
)
voter_id
=
models
.
CharField
(
max_length
=
100
)
# 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_password
=
models
.
CharField
(
max_length
=
100
,
null
=
True
)
uuid
=
models
.
CharField
(
max_length
=
50
)
uuid
=
models
.
CharField
(
max_length
=
50
)
# if election uses aliases
# if election uses aliases
...
@@ -555,7 +567,7 @@ class Voter(models.Model, electionalgs.Voter):
...
@@ -555,7 +567,7 @@ class Voter(models.Model, electionalgs.Voter):
@transaction.commit_on_success
@transaction.commit_on_success
def
register_user_in_election
(
cls
,
user
,
election
):
def
register_user_in_election
(
cls
,
user
,
election
):
voter_uuid
=
str
(
uuid
.
uuid4
())
voter_uuid
=
str
(
uuid
.
uuid4
())
voter
=
Voter
(
uuid
=
voter_uuid
,
voter_type
=
user
.
user_type
,
voter_id
=
user
.
user_id
,
election
=
election
,
name
=
user
.
name
)
voter
=
Voter
(
uuid
=
voter_uuid
,
user
=
user
,
election
=
election
,
name
=
user
.
name
)
# do we need to generate an alias?
# do we need to generate an alias?
if
election
.
use_voter_aliases
:
if
election
.
use_voter_aliases
:
...
@@ -614,7 +626,7 @@ class Voter(models.Model, electionalgs.Voter):
...
@@ -614,7 +626,7 @@ class Voter(models.Model, electionalgs.Voter):
@classmethod
@classmethod
def
get_by_election_and_user
(
cls
,
election
,
user
):
def
get_by_election_and_user
(
cls
,
election
,
user
):
query
=
cls
.
objects
.
filter
(
election
=
election
,
voter_id
=
user
.
user_id
,
voter_type
=
user
.
user_type
)
query
=
cls
.
objects
.
filter
(
election
=
election
,
user
=
user
)
try
:
try
:
return
query
[
0
]
return
query
[
0
]
...
@@ -632,11 +644,7 @@ class Voter(models.Model, electionalgs.Voter):
...
@@ -632,11 +644,7 @@ class Voter(models.Model, electionalgs.Voter):
@classmethod
@classmethod
def
get_by_user
(
cls
,
user
):
def
get_by_user
(
cls
,
user
):
return
cls
.
objects
.
select_related
().
filter
(
voter_type
=
user
.
user_type
,
voter_id
=
user
.
user_id
).
order_by
(
'
-cast_at
'
)
return
cls
.
objects
.
select_related
().
filter
(
user
=
user
).
order_by
(
'
-cast_at
'
)
@property
def
user
(
self
):
return
User
.
get_by_type_and_id
(
self
.
voter_type
,
self
.
voter_id
)
@property
@property
def
election_uuid
(
self
):
def
election_uuid
(
self
):
...
...
This diff is collapsed.
Click to expand it.
helios/stats_views.py
+
1
−
1
View file @
fb996233
...
@@ -23,7 +23,7 @@ def require_admin(request):
...
@@ -23,7 +23,7 @@ def require_admin(request):
def
home
(
request
):
def
home
(
request
):
user
=
require_admin
(
request
)
user
=
require_admin
(
request
)
num_votes_in_queue
=
CastVote
.
objects
.
filter
(
invalidated_at
=
None
,
cast
_at
=
None
).
count
()
num_votes_in_queue
=
CastVote
.
objects
.
filter
(
invalidated_at
=
None
,
verified
_at
=
None
).
count
()
return
render_template
(
request
,
'
stats
'
,
{
'
num_votes_in_queue
'
:
num_votes_in_queue
})
return
render_template
(
request
,
'
stats
'
,
{
'
num_votes_in_queue
'
:
num_votes_in_queue
})
def
elections
(
request
):
def
elections
(
request
):
...
...
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