Skip to content
Permalink
Browse files

Disable AutoPush for critical update if it receives negative karma

  • Loading branch information...
trishnaguha committed Aug 29, 2016
1 parent c02fd26 commit b1f710066bfb6efa7cfe0ec6cbac31bf52bc4ef7
Showing with 390 additions and 1 deletion.
  1. +17 −1 bodhi/server/models/models.py
  2. +373 −0 bodhi/tests/server/functional/test_updates.py
@@ -1653,7 +1653,11 @@ def check_karma_thresholds(self, db, agent):
"""Check if we have reached either karma threshold, and call set_request if necessary"""
if not self.locked:
if self.status is UpdateStatus.testing:
if self.stable_karma not in (0, None) and self.karma >= self.stable_karma:
# If critical update receives negative karma disable autopush
if self.critpath and self.autokarma and self.has_negative_karma:
log.info("Disabling Auto Push since the critical update has negative karma")
self.autokarma = False
elif self.stable_karma not in (0, None) and self.karma >= self.stable_karma:
if self.autokarma:
log.info("Automatically marking %s as stable" % self.title)
self.set_request(db, UpdateRequest.stable, agent)
@@ -1707,6 +1711,18 @@ def last_modified(self):
possibilities.sort() # Sort smallest to largest (oldest to newest)
return possibilities[-1] # Return the last one

@property
def has_negative_karma(self):
"""Check for negative karma, Returns True if the update has negative karma"""
feedback = defaultdict(int)
for comment in self.comments:
if not comment.anonymous:
feedback[comment.user.name] = comment.karma
for karma in feedback.values():
if karma < 0:
return True
return False

@property
def critpath_approved(self):
""" Return whether or not this critpath update has been approved """

0 comments on commit b1f7100

Please sign in to comment.
You can’t perform that action at this time.