<commit_before>class API::V1::TeachersController < API::APIController

  # Note that two scenarios are possible:
  # - 'school_id' is provided - school is expected to exist
  # - 'school_name', 'country_id' and 'zipcode' are provided instead - school may be created in case of need
  def create
    teacher_registration = API::V1::TeacherRegistration.new(params)
    if !current_visitor.anonymous?
      teacher_registration.set_user current_visitor
    end

    if should_create_new_school(teacher_registration)
      school_id, school_reg_errors = create_new_school
      if school_id
        teacher_registration.school_id = school_id
      else
        error(school_reg_errors)
        return
      end
    end

    if teacher_registration.valid?
      teacher_registration.save
      render status: 201, json: teacher_registration.attributes
    else
      error(teacher_registration.errors)
    end
  end
<commit_msg>Remove password from teacher registration response too<commit_after>class API::V1::TeachersController < API::APIController

  # Note that two scenarios are possible:
  # - 'school_id' is provided - school is expected to exist
  # - 'school_name', 'country_id' and 'zipcode' are provided instead - school may be created in case of need
  def create
    teacher_registration = API::V1::TeacherRegistration.new(params)
    if !current_visitor.anonymous?
      teacher_registration.set_user current_visitor
    end

    if should_create_new_school(teacher_registration)
      school_id, school_reg_errors = create_new_school
      if school_id
        teacher_registration.school_id = school_id
      else
        error(school_reg_errors)
        return
      end
    end

    if teacher_registration.valid?
      teacher_registration.save
      attributes = teacher_registration.attributes
      attributes.delete(:password)
      attributes.delete(:password_confirmation)
      render status: 201, json: attributes
    else
      error(teacher_registration.errors)
    end
  end

{'fraction_non_alphanumeric': 0.0615, 'fraction_numerical': 0.005, 'mean_word_length': 3.486547085201794, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '815633', 'n_tokens_mistral': 575, 'n_tokens_neox': 554, 'n_words': 144}