def reject_suggestions(suggestion_ids, reviewer_id, review_message): """Rejects the suggestions with the given suggestion_ids. Args: suggestion_ids: list(str). The ids of the suggestions to be rejected. reviewer_id: str. The ID of the reviewer rejecting the suggestions. review_message: str. The message provided by the reviewer while rejecting the suggestions. Raises: Exception. One or more of the suggestions has already been handled. """ suggestions = get_suggestions_by_ids(suggestion_ids) for index, suggestion in enumerate(suggestions): if suggestion is None: raise Exception( 'You cannot reject the suggestion with id %s because it does ' 'not exist.' % (suggestion_ids[index])) if suggestion.is_handled: raise Exception( 'The suggestion with id %s has already been accepted/' 'rejected.' % (suggestion.suggestion_id)) if not review_message: raise Exception('Review message cannot be empty.') for suggestion in suggestions: suggestion.set_suggestion_status_to_rejected() suggestion.set_final_reviewer_id(reviewer_id) _update_suggestions(suggestions) feedback_services.create_messages(suggestion_ids, reviewer_id, feedback_models.STATUS_CHOICES_IGNORED, None, review_message)
def reject_suggestions(suggestions, reviewer_id, review_message): """Rejects the suggestions. Args: suggestions: list(Suggestion). The suggestions to be rejected. reviewer_id: str. The ID of the reviewer rejecting the suggestions. review_message: str. The message provided by the reviewer while rejecting the suggestions. Raises: Exception. One or more of the suggestions has already been handled. """ for suggestion in suggestions: if suggestion.is_handled: raise Exception( 'The suggestion with id %s has already been accepted/' 'rejected.' % (suggestion.suggestion_id) ) if not review_message: raise Exception('Review message cannot be empty.') mark_multiple_reviews_completed( suggestions, suggestion_models.STATUS_REJECTED, reviewer_id ) thread_ids = [suggestion.suggestion_id for suggestion in suggestions] feedback_services.create_messages( thread_ids, reviewer_id, feedback_models.STATUS_CHOICES_IGNORED, None, review_message )
def reject_suggestions(suggestion_ids, reviewer_id, review_message): """Rejects the suggestions with the given suggestion_ids. Args: suggestion_ids: list(str). The ids of the suggestions to be rejected. reviewer_id: str. The ID of the reviewer rejecting the suggestions. review_message: str. The message provided by the reviewer while rejecting the suggestions. Raises: Exception. One or more of the suggestions has already been handled. """ suggestions = get_suggestions_by_ids(suggestion_ids) for index, suggestion in enumerate(suggestions): if suggestion is None: raise Exception( 'You cannot reject the suggestion with id %s because it does ' 'not exist.' % (suggestion_ids[index])) if suggestion.is_handled: raise Exception( 'The suggestion with id %s has already been accepted/' 'rejected.' % (suggestion.suggestion_id)) if not review_message: raise Exception('Review message cannot be empty.') for suggestion in suggestions: suggestion.set_suggestion_status_to_rejected() suggestion.set_final_reviewer_id(reviewer_id) _update_suggestions(suggestions) # Update the community contribution stats so that the number of suggestions # that are in review decreases, since these suggestions are no longer in # review. _update_suggestion_counts_in_community_contribution_stats(suggestions, -1) feedback_services.create_messages(suggestion_ids, reviewer_id, feedback_models.STATUS_CHOICES_IGNORED, None, review_message, should_send_email=False)