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
0f744df5
Commit
0f744df5
authored
9 years ago
by
Lukáš Nový
Browse files
Options
Downloads
Patches
Plain Diff
Add support for fetch voters list and freezing it
parent
bb2c3c90
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
helios/models.py
+37
-2
37 additions, 2 deletions
helios/models.py
with
37 additions
and
2 deletions
helios/models.py
+
37
−
2
View file @
0f744df5
...
...
@@ -436,7 +436,40 @@ class Election(HeliosModel):
def
increment_cast_votes
(
self
):
## FIXME
return
0
def
load_eligible_voters
(
self
):
"""
try to load voters by eligibility constraints
"""
if
self
.
eligibility
==
None
:
return
if
self
.
openreg
==
False
:
return
total_load
=
True
for
eligibility_case
in
self
.
eligibility
:
print
eligibility_case
auth_system
=
eligibility_case
[
'
auth_system
'
]
if
not
eligibility_case
.
has_key
(
'
constraint
'
):
total_load
=
False
else
:
if
hasattr
(
AUTH_SYSTEMS
[
auth_system
],
'
can_list_category_members
'
):
for
constraint
in
eligibility_case
[
'
constraint
'
]:
category_id
=
AUTH_SYSTEMS
[
auth_system
].
eligibility_category_id
(
constraint
)
for
u
in
AUTH_SYSTEMS
[
auth_system
].
list_category_members
(
category_id
):
user
=
User
.
update_or_create
(
user_type
=
u
[
'
type
'
],
user_id
=
u
[
'
id
'
],
name
=
u
[
'
name
'
],
info
=
u
[
'
info
'
],
token
=
u
[
'
token
'
])
Voter
.
register_user_in_election
(
user
,
self
)
else
:
total_load
=
False
if
total_load
:
self
.
openreg
=
False
def
set_eligibility
(
self
):
"""
if registration is closed and eligibility has not been
...
...
@@ -485,7 +518,9 @@ class Election(HeliosModel):
raise
Exception
(
"
cannot freeze an election that has issues
"
)
self
.
frozen_at
=
datetime
.
datetime
.
utcnow
()
self
.
load_eligible_voters
()
# voters hash
self
.
generate_voters_hash
()
...
...
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