def revoke_ship_it(self, user): """Revoke the Ship It status on this review. The Ship It status will be removed, and the :py:data:`ReviewRequest.shipit_count <reviewboard.reviews.models.review_request.ReviewRequest.shipit_count>` counter will be decremented. If the :py:attr:`body_top` text is equal to :py:attr:`SHIP_IT_TEXT`, then it will replaced with :py:attr:`REVOKED_SHIP_IT_TEXT`. Callers are responsible for checking whether the user has permission to revoke Ship Its by using :py:meth:`can_user_revoke_ship_it`. Raises: reviewboard.reviews.errors.RevokeShipItError: The Ship It could not be revoked. Details will be in the error message. """ if not self.ship_it: raise RevokeShipItError('This review is not marked Ship It!') # This may raise a RevokeShipItError. try: review_ship_it_revoking.send(sender=self.__class__, user=user, review=self) except RevokeShipItError: raise except Exception as e: logging.exception( 'Unexpected error notifying listeners before ' 'revoking a Ship It for review ID=%d: %s', self.pk, e) raise RevokeShipItError(e) if self.extra_data is None: self.extra_data = {} self.extra_data['revoked_ship_it'] = True self.ship_it = False update_fields = ['extra_data', 'ship_it'] if self.body_top == self.SHIP_IT_TEXT: self.body_top = self.REVOKED_SHIP_IT_TEXT self.body_top_rich_text = True update_fields += ['body_top', 'body_top_rich_text'] self.save(update_fields=update_fields) self.review_request.decrement_shipit_count() self.review_request.last_review_activity_timestamp = timezone.now() self.review_request.save( update_fields=['last_review_activity_timestamp']) try: review_ship_it_revoked.send(sender=self.__class__, user=user, review=self) except Exception as e: logging.exception( 'Unexpected error notifying listeners after ' 'revoking a Ship It for review ID=%d: %s', self.pk, e)
def revoke_ship_it(self, user): """Revoke the Ship It status on this review. The Ship It status will be removed, and the :py:data:`ReviewRequest.shipit_count <reviewboard.reviews.models.review_request.ReviewRequest.shipit_count>` counter will be decremented. If the :py:attr:`body_top` text is equal to :py:attr:`SHIP_IT_TEXT`, then it will replaced with :py:attr:`REVOKED_SHIP_IT_TEXT`. Callers are responsible for checking whether the user has permission to revoke Ship Its by using :py:meth:`can_user_revoke_ship_it`. Raises: reviewboard.reviews.errors.RevokeShipItError: The Ship It could not be revoked. Details will be in the error message. """ if not self.ship_it: raise RevokeShipItError('This review is not marked Ship It!') # This may raise a RevokeShipItError. try: review_ship_it_revoking.send(sender=self.__class__, user=user, review=self) except RevokeShipItError: raise except Exception as e: logging.exception('Unexpected error notifying listeners before ' 'revoking a Ship It for review ID=%d: %s', self.pk, e) raise RevokeShipItError(e) if self.extra_data is None: self.extra_data = {} self.extra_data['revoked_ship_it'] = True self.ship_it = False update_fields = ['extra_data', 'ship_it'] if self.body_top == self.SHIP_IT_TEXT: self.body_top = self.REVOKED_SHIP_IT_TEXT self.body_top_rich_text = True update_fields += ['body_top', 'body_top_rich_text'] self.save(update_fields=update_fields) self.review_request.decrement_shipit_count() self.review_request.last_review_activity_timestamp = timezone.now() self.review_request.save( update_fields=['last_review_activity_timestamp']) try: review_ship_it_revoked.send(sender=self.__class__, user=user, review=self) except Exception as e: logging.exception('Unexpected error notifying listeners after ' 'revoking a Ship It for review ID=%d: %s', self.pk, e)