<commit_before>ActiveAdmin.register Event do
  config.sort_order = "name_asc"
  menu priority: 2

  filter :name
  filter :region
  filter :category

  index do
    column :id
    column :name
    column :category
    column :url do |event|
      a "Link", href: event.url
    end
    column :twitter do |event|
      a "@#{event.twitter}", href: "http://twitter.com/#{event.twitter}" unless event.twitter.blank?
    end
    column :twitter_hashtag do |event|
      if event.twitter_hashtag.present?
        a "##{event.twitter_hashtag}", href: "http://twitter.com/search/%23#{event.twitter_hashtag}" unless event.twitter_hashtag.blank?
      else
        nil
      end
    end

    default_actions


  end

  show do
    render partial: 'show'
  end
  form do
    render partial: 'form'
  end

  controller do
    def permitted_params
      params.permit(event: %i[
        name
        region_id
        description
        schedule_yaml
        url
        twitter
        created_at
        updated_at
        full_day
        twitter_hashtag
        category_id
        venue_id
        venue_info
        picture_id
      ])
    end

    def create
      [[:schedule_rules_json, :schedule_rules], [:excluded_times_json, :excluded_times]].each do |item|
        if params[:event][item[0]]
          params[:event][item[1]] = JSON.parse(params[:event][item[0]])
          params[:event].delete item[0]
        end
      end
      create! do |format|
        format.html { redirect_to admin_event_path(@event) }
      end
    end

    def update
      [[:schedule_rules_json, :schedule_rules], [:excluded_times_json, :excluded_times]].each do |item|
        if params[:event][item[0]]
          params[:event][item[1]] = JSON.parse(params[:event][item[0]])
          params[:event].delete item[0]
        end
      end
      update! do |format|
        format.html { redirect_to admin_event_path(@event) }
      end
    end
  end
end<commit_msg>allow all params, fixes #307 ... but in an ugly way<commit_after>ActiveAdmin.register Event do
  config.sort_order = "name_asc"
  menu priority: 2

  filter :name
  filter :region
  filter :category

  index do
    column :id
    column :name
    column :category
    column :url do |event|
      a "Link", href: event.url
    end
    column :twitter do |event|
      a "@#{event.twitter}", href: "http://twitter.com/#{event.twitter}" unless event.twitter.blank?
    end
    column :twitter_hashtag do |event|
      if event.twitter_hashtag.present?
        a "##{event.twitter_hashtag}", href: "http://twitter.com/search/%23#{event.twitter_hashtag}" unless event.twitter_hashtag.blank?
      else
        nil
      end
    end

    default_actions
  end

  show do
    render partial: 'show'
  end
  form do
    render partial: 'form'
  end

  controller do
    def permitted_params
      # ToDo: this is a sad workaround, I could not
      # find a valid way to permit the schedule_rules and excluded_times
      # values from the event. Those are arrays and are filtered out
      # by default :(
      params.permit!
      # params.permit(event: %i[
      #   name
      #   region_id
      #   description
      #   schedule_yaml
      #   url
      #   twitter
      #   created_at
      #   updated_at
      #   full_day
      #   twitter_hashtag
      #   category_id
      #   venue_id
      #   venue_info
      #   picture_id
      #   tag_list
      #   start_time(1i)
      #   start_time(2i)
      #   start_time(3i)
      #   start_time(4i)
      #   start_time(5i)
      #   duration
      #   week_number
      #   day_of_week
      #   id
      # ])
    end

    def create
      [[:schedule_rules_json, :schedule_rules], [:excluded_times_json, :excluded_times]].each do |item|
        if params[:event][item[0]]
          params[:event][item[1]] = JSON.parse(params[:event][item[0]])
          params[:event].delete item[0]
        end
      end
      create! do |format|
        format.html { redirect_to admin_event_path(@event) }
      end
    end

    def update
      [[:schedule_rules_json, :schedule_rules], [:excluded_times_json, :excluded_times]].each do |item|
        if params[:event][item[0]]
          params[:event][item[1]] = JSON.parse(params[:event][item[0]])
          params[:event].delete item[0]
        end
      end
      update! do |format|
        format.html { redirect_to admin_event_path(@event) }
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.10450124406242932, 'fraction_numerical': 0.006785795068988917, 'mean_word_length': 2.1904761904761907, 'pattern_counts': {'":': 0, '<': 3, '<?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': '765016', 'n_tokens_mistral': 1415, 'n_tokens_neox': 1393, 'n_words': 337}