Poll Result
Tool class used to create a results object instance for single option polls.
PollResult
dataclass
Compute a result of a closed poll.
Source code in apps/votes_results/classes/poll_result.py
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 | |
poll: PollModel = poll
class-attribute
instance-attribute
The poll the result is about
get_sorted_options()
Result as an ordered list of pairs (choice, n_votes).
Result is computed only once for efficiency reasons (and then memoized). If you want to compute it again, create another PollResult instance.
Source code in apps/votes_results/classes/poll_result.py
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 | |
PollResultVoice
dataclass
A single voice of the result. It's made of a PollOption and the number of received votes.
N votes are calculated during object building.
Source code in apps/votes_results/classes/poll_result.py
8 9 10 11 12 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 | |
n_votes = PollResultVoice.__count_n_votes(poll_option)
class-attribute
instance-attribute
Number of votes the option received
option = poll_option
class-attribute
instance-attribute
The voted option
position = 0
class-attribute
instance-attribute
Position in results