Schulze Method Services
Schulze Method services related to vote.
SchulzeMethodVoteService
Class that handles vote procedures for the majority vote case
Source code in apps/votes_results/services/schulze_method_vote_service.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
calculate_result(poll, user=None)
staticmethod
Calculate result of a poll.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
poll |
PollModel
|
the poll you want to calculate results |
required |
Raises:
| Type | Description |
|---|---|
PollDoesNotExistException
|
you tried to calculate results on a non-existent poll |
ResultsNotAvailableException
|
raised if you try to check results not visible |
Returns:
| Name | Type | Description |
|---|---|---|
result |
SchulzeResultsAdapter
|
list of PollOptions sorted by ranking number as Schulze algorithm results |
Source code in apps/votes_results/services/schulze_method_vote_service.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
get_vote_by_id(vote_id)
staticmethod
Retrieve a vote by its ID
(temporary method! In future we will wanna use
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vote_id |
str
|
id of the vote object you want to retrieve |
required |
Raises:
| Type | Description |
|---|---|
VoteDoesNotExistException
|
if vote does not exists |
Returns:
| Name | Type | Description |
|---|---|---|
SchulzeVoteModel |
SchulzeVoteModel
|
schulze vote by the specified id |
Source code in apps/votes_results/services/schulze_method_vote_service.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
perform_vote(options_rated, poll_id)
staticmethod
Perform a vote on a majority vote poll
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
poll_id |
str
|
the id of the poll. |
required |
options_rated |
List[str]
|
List of string of option id [12,14,13,15] |
required |
Raises:
| Type | Description |
|---|---|
PollDoesNotExistException
|
execption raised when the poll selected is not present in the database |
Returns:
| Name | Type | Description |
|---|---|---|
vote |
SchulzeVoteModel
|
the schulze vote model created. |
Source code in apps/votes_results/services/schulze_method_vote_service.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |