Majority Judgment Services
Majority Judgment services related to vote.
MajorityJudjmentVoteService
Class that handles vote procedures for the majority vote case
Source code in apps/votes_results/services/majority_judgment_vote_service.py
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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
calculate_result(poll_id, user=None)
staticmethod
Calculate result of a majority poll.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
poll_id |
str
|
The id of the poll. |
required |
Raises:
| Type | Description |
|---|---|
PollDoesNotExistException
|
If the poll does not exist. |
ResultsNotAvailableException
|
you tried to access results on a poll that are not available |
Returns:
| Type | Description |
|---|---|
IMajorityJudgmentResults
|
List[MajorityPollResultData]: List of calculated result for each option. |
Source code in apps/votes_results/services/majority_judgment_vote_service.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
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 |
|---|---|---|
MajorityVoteModel |
MajorityVoteModel
|
the majority vote model with the specified id |
Source code in apps/votes_results/services/majority_judgment_vote_service.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
perform_vote(rating_options, 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 |
rating_options |
List[dict]
|
List of dictionaries of ratings assigned to an option [{'poll_choice_id': ..., 'rating': ...}, ...]. |
required |
Raises:
| Type | Description |
|---|---|
PollDoesNotExistException
|
execption raised when the poll selected is not present in the database |
PollOptionRatingUnvalidException
|
exception raised when there are no rating choices in the options (None) |
MajorityNumberOfRatingsNotValid
|
exception raised when the rating number is not between 1 and 5 |
Returns:
| Name | Type | Description |
|---|---|---|
vote |
MajorityVoteModel
|
the majority vote model created. |
Source code in apps/votes_results/services/majority_judgment_vote_service.py
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 | |