def accept_suggestion(editor_id, thread_id, exploration_id, commit_message):
 if ((not commit_message) or (not commit_message.strip())):
  raise Exception('Commit message cannot be empty.')
 if _is_suggestion_handled(thread_id, exploration_id):
  raise Exception('Suggestion has already been accepted/rejected.')
 elif (not _is_suggestion_valid(thread_id, exploration_id)):
  raise Exception('Invalid suggestion: The state for which it was made has been removed/renamed.')
 else:
  suggestion = feedback_services.get_suggestion(exploration_id, thread_id)
  suggestion_author_username = suggestion.get_author_name()
  change_list = _create_change_list_from_suggestion(suggestion)
  update_exploration(editor_id, exploration_id, change_list, _get_commit_message_for_suggestion(suggestion_author_username, commit_message), is_suggestion=True)
  feedback_services.create_message(exploration_id, thread_id, editor_id, feedback_models.STATUS_CHOICES_FIXED, None, 'Suggestion accepted.')

def accept_suggestion ( editor_id , thread_id , exploration_id , commit_message ) : if ( ( not commit_message ) or ( not commit_message . strip ( ) ) ) : raise Exception ( 'Commit message cannot be empty.' ) if _is_suggestion_handled ( thread_id , exploration_id ) : raise Exception ( 'Suggestion has already been accepted/rejected.' ) elif ( not _is_suggestion_valid ( thread_id , exploration_id ) ) : raise Exception ( 'Invalid suggestion: The state for which it was made has been removed/renamed.' ) else : suggestion = feedback_services . get_suggestion ( exploration_id , thread_id ) suggestion_author_username = suggestion . get_author_name ( ) change_list = _create_change_list_from_suggestion ( suggestion ) update_exploration ( editor_id , exploration_id , change_list , _get_commit_message_for_suggestion ( suggestion_author_username , commit_message ) , is_suggestion = True ) feedback_services . create_message ( exploration_id , thread_id , editor_id , feedback_models . STATUS_CHOICES_FIXED , None , 'Suggestion accepted.' )
if the suggestion is valid .