def publish(self, user=None): """ 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 self.save() for comment in self.comments.all(): comment.timetamp = self.timestamp comment.save() for comment in self.screenshot_comments.all(): comment.timetamp = self.timestamp comment.save() # Update the last_updated timestamp on the review request. self.review_request.last_review_timestamp = self.timestamp self.review_request.save() # Atomicly update the shipit_count if self.ship_it: self.review_request.increment_ship_it() if self.is_reply(): reply_published.send(sender=self.__class__, user=user, reply=self) else: review_published.send(sender=self.__class__, user=user, review=self)
def review_draft_save(request, review_request_id, publish=False): review_request = get_object_or_404(ReviewRequest, pk=review_request_id) review, review_is_new = Review.objects.get_or_create( user=request.user, review_request=review_request, public=False, base_reply_to__isnull=True ) if "shipit" in request.POST: review.ship_it = request.POST["shipit"] in (1, "1", True, "True") if "body_top" in request.POST: review.body_top = request.POST["body_top"] if "body_bottom" in request.POST: review.body_bottom = request.POST["body_bottom"] if publish: review.publish() else: review.save() if publish: review_published.send(sender=None, user=request.user, review=review) return WebAPIResponse(request)
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 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)