def publish(self, user=None, trivial=False, to_submitter_only=False): """Publishes this review. This will make the review public and update the timestamps of all contained comments. """ if not user: user = self.user self.public = True if self.is_reply(): reply_publishing.send(sender=self.__class__, user=user, reply=self) else: review_publishing.send(sender=self.__class__, user=user, review=self) self.save() self.comments.update(timestamp=self.timestamp) self.screenshot_comments.update(timestamp=self.timestamp) self.file_attachment_comments.update(timestamp=self.timestamp) self.general_comments.update(timestamp=self.timestamp) # Update the last_updated timestamp and the last review activity # timestamp on the review request. self.review_request.last_review_activity_timestamp = self.timestamp self.review_request.save( update_fields=['last_review_activity_timestamp', 'last_updated']) if self.is_reply(): reply_published.send(sender=self.__class__, user=user, reply=self, trivial=trivial) else: issue_counts = fetch_issue_counts(self.review_request, Q(pk=self.pk)) # Since we're publishing the review, all filed issues should be # open. assert issue_counts[BaseComment.RESOLVED] == 0 assert issue_counts[BaseComment.DROPPED] == 0 if self.ship_it: ship_it_value = 1 else: ship_it_value = 0 # Atomically update the issue count and Ship It count. CounterField.increment_many( self.review_request, { 'issue_open_count': issue_counts[BaseComment.OPEN], 'issue_dropped_count': 0, 'issue_resolved_count': 0, 'shipit_count': ship_it_value, }) review_published.send(sender=self.__class__, user=user, review=self, to_submitter_only=to_submitter_only)
def save(self, **kwargs): from reviewboard.reviews.models.review_request import ReviewRequest self.timestamp = timezone.now() super(BaseComment, self).save() try: # Update the review timestamp, but only if it's a draft. # Otherwise, resolving an issue will change the timestamp of # the review. review = self.get_review() if not review.public: review.timestamp = self.timestamp review.save() else: if not self.is_reply() and self._loaded_issue_status != self.issue_status: # The user has toggled the issue status of this comment, # so update the issue counts for the review request. old_field = ReviewRequest.ISSUE_COUNTER_FIELDS[self._loaded_issue_status] new_field = ReviewRequest.ISSUE_COUNTER_FIELDS[self.issue_status] CounterField.increment_many(self.get_review_request(), {old_field: -1, new_field: 1}) q = ReviewRequest.objects.filter(pk=review.review_request_id) q.update(last_review_activity_timestamp=self.timestamp) except ObjectDoesNotExist: pass
def save(self, **kwargs): from reviewboard.reviews.models.review_request import ReviewRequest self.timestamp = timezone.now() super(BaseComment, self).save() try: # Update the review timestamp, but only if it's a draft. # Otherwise, resolving an issue will change the timestamp of # the review. review = self.get_review() if not review.public: review.timestamp = self.timestamp review.save() else: if (not self.is_reply() and self.issue_opened and self._loaded_issue_status != self.issue_status): # The user has toggled the issue status of this comment, # so update the issue counts for the review request. old_field = ReviewRequest.ISSUE_COUNTER_FIELDS[ self._loaded_issue_status] new_field = ReviewRequest.ISSUE_COUNTER_FIELDS[ self.issue_status] CounterField.increment_many(self.get_review_request(), { old_field: -1, new_field: 1, }) q = ReviewRequest.objects.filter(pk=review.review_request_id) q.update(last_review_activity_timestamp=self.timestamp) except ObjectDoesNotExist: pass
def publish(self, user=None, trivial=False): """Publishes this review. This will make the review public and update the timestamps of all contained comments. """ if not user: user = self.user self.public = True if self.is_reply(): reply_publishing.send(sender=self.__class__, user=user, reply=self) else: review_publishing.send(sender=self.__class__, user=user, review=self) self.save() self.comments.update(timestamp=self.timestamp) self.screenshot_comments.update(timestamp=self.timestamp) self.file_attachment_comments.update(timestamp=self.timestamp) # Update the last_updated timestamp and the last review activity # timestamp on the review request. self.review_request.last_review_activity_timestamp = self.timestamp self.review_request.save( update_fields=['last_review_activity_timestamp', 'last_updated']) if self.is_reply(): reply_published.send(sender=self.__class__, user=user, reply=self, trivial=trivial) else: issue_counts = fetch_issue_counts(self.review_request, Q(pk=self.pk)) # Since we're publishing the review, all filed issues should be # open. assert issue_counts[BaseComment.RESOLVED] == 0 assert issue_counts[BaseComment.DROPPED] == 0 if self.ship_it: ship_it_value = 1 else: ship_it_value = 0 # Atomically update the issue count and Ship It count. CounterField.increment_many( self.review_request, { 'issue_open_count': issue_counts[BaseComment.OPEN], 'issue_dropped_count': 0, 'issue_resolved_count': 0, 'shipit_count': ship_it_value, }) review_published.send(sender=self.__class__, user=user, review=self, trivial=trivial)