<commit_before>class PublicSignupsController < ApplicationController
  def new
    @public_signup = PublicSignup.new(registration_attributes: { angel_attributes: {}})
    render_site_new_template
  end

  def create
    @public_signup = PublicSignup.new(params_with_nested_models)
    if @public_signup.save
      redirect_to Site.thankyou_url
      @public_signup.send_email(EventEmail::SIGNUP)
    else
      # fixes bug where "0" (unchecked box value) gets rerendered as checked state
      unless @public_signup.terms_and_conditions == '1'
        @public_signup.terms_and_conditions = nil
      end
      render_site_new_template
    end
  end

  protected

  # ensure we have a nested registration_attributes and within that angel_attributes
  def params_with_nested_models
    {registration_attributes: {angel_attributes: {}}}.with_indifferent_access.merge(params[:public_signup] || {})
  end

  def render_site_new_template
    @basedir = "public_signups/#{Site.name}"
    render "#{@basedir}/new", :layout => "#{Site.name}#{template_version}_site"
  end

  def template_version
    @version ||= params[:template_version].to_s.match(/\d+/).to_s
  end
  helper_method :template_version
end
<commit_msg>allow event to be preselected when the correct event_id is passed<commit_after>class PublicSignupsController < ApplicationController
  def new
    @public_signup = PublicSignup.new(registration_attributes: { event_id: params[:event_id], angel_attributes: {}})
    render_site_new_template
  end

  def create
    @public_signup = PublicSignup.new(params_with_nested_models)
    if @public_signup.save
      redirect_to Site.thankyou_url
      @public_signup.send_email(EventEmail::SIGNUP)
    else
      # fixes bug where "0" (unchecked box value) gets rerendered as checked state
      unless @public_signup.terms_and_conditions == '1'
        @public_signup.terms_and_conditions = nil
      end
      render_site_new_template
    end
  end

  protected

  # ensure we have a nested registration_attributes and within that angel_attributes
  def params_with_nested_models
    {registration_attributes: {angel_attributes: {}}}.with_indifferent_access.merge(params[:public_signup] || {})
  end

  def render_site_new_template
    @basedir = "public_signups/#{Site.name}"
    render "#{@basedir}/new", :layout => "#{Site.name}#{template_version}_site"
  end

  def template_version
    @version ||= params[:template_version].to_s.match(/\d+/).to_s
  end
  helper_method :template_version
end

{'fraction_non_alphanumeric': 0.08923569427771108, 'fraction_numerical': 0.001600640256102441, 'mean_word_length': 4.446623093681917, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7310502', 'n_tokens_mistral': 784, 'n_tokens_neox': 761, 'n_words': 162}