10
10
11
11
## Vote Totals
12
12
13
- | Yes | No | Abstain | Total |
14
- | --- | -- | ------- | ----- |
15
- | %s | %s | %s | %s |
13
+ | Yes | No | Abstain | Voters |
14
+ | --- | -- | ------- | ------ |
15
+ | %s | %s | %s | %s |
16
16
17
17
18
18
## Vote Breakdown
@@ -99,11 +99,15 @@ def __init__(self, repository, number):
99
99
self .no = []
100
100
self .abstain = []
101
101
self .users = []
102
+ self .doubles = []
102
103
for reaction in reactions :
103
104
content = reaction ['content' ]
104
105
user = reaction ['user' ]
105
106
username = user ['login' ]
106
107
108
+ if username in self .doubles :
109
+ continue
110
+
107
111
if 'collaborators_only' in self .repository .rules and self .repository .rules ['collaborators_only' ]:
108
112
if not isCollaborator (username ):
109
113
continue
@@ -116,6 +120,19 @@ def __init__(self, repository, number):
116
120
if username not in self .repository .rules ['whitelist' ]:
117
121
continue
118
122
123
+ if 'prevent_doubles' in self .repository .rules and self .repository .rules ['prevent_doubles' ]:
124
+ # make sure user hasn't voted twice
125
+ if username in self .users :
126
+ self .doubles .append (username )
127
+ self .users .remove (username )
128
+ if username in self .yes :
129
+ self .yes .remove (username )
130
+ if username in self .no :
131
+ self .no .remove (username )
132
+ if username in self .abstain :
133
+ self .abstain .remove (username )
134
+ continue
135
+
119
136
if content == '+1' :
120
137
self .yes .append (user ['login' ])
121
138
elif content == '-1' :
@@ -199,6 +216,13 @@ def commentAction(self, action):
199
216
consensus .hasQuorum (self ),
200
217
consensus .hasVotes (self )
201
218
)
219
+
220
+ if len (self .doubles ) > 0 :
221
+ duplist = ["[%s](https://github.com/%s)" % (username , username ) for username in self .doubles ]
222
+ dupuserstring = ', ' .join (duplist )
223
+ dupstring = '\n \n The following users voted for multiple options and were exlcuded: \n %s' % (dupuserstring )
224
+ message = "%s\n %s" % (message , dupstring )
225
+
202
226
self .addComment (message )
203
227
204
228
def buildVoteTable (self ):
0 commit comments