<commit_before>class Project::BaseForm < ::Form

  attribute :project, :model, primary: true, new_records: true, default: proc { circle.projects.build }

  attribute :name, :string
  attribute :description, :string, required: false
  attribute :organizer_id, :integer, default: proc { project.admins.first.try(:id) || user.id }
  attribute :working_group_id, :string

  attribute :circle, :model
  attribute :user, :model
  attribute :ability, :model

  def available_working_groups
    @available_working_groups ||= begin
      working_groups = circle.working_groups.asc_order.to_a
      working_groups.select! { |wg| ability.can?(:manage, wg) } unless ability.can?(:manage, circle)
      working_groups << project.working_group unless working_groups.present?
      working_groups
    end
  end

  def available_working_groups_disabled?
    available_working_groups.size == 1 && ability.cannot?(:manage, available_working_groups.first)
  end
  
  class Submit < ::Form::Submit  <commit_msg>Don't allow changing a project's work group after it was created. #29<commit_after>class Project::BaseForm < ::Form

  attribute :project, :model, primary: true, new_records: true, default: proc { circle.projects.build }

  attribute :name, :string
  attribute :description, :string, required: false
  attribute :organizer_id, :integer, default: proc { project.admins.first.try(:id) || user.id }
  attribute :working_group_id, :string

  attribute :circle, :model
  attribute :user, :model
  attribute :ability, :model

  def available_working_groups
    @available_working_groups ||= begin
      working_groups = circle.working_groups.asc_order.to_a
      working_groups.select! { |wg| ability.can?(:manage, wg) } unless ability.can?(:manage, circle)
      working_groups << project.working_group unless working_groups.present?
      working_groups
    end
  end

  def available_working_groups_disabled?
    !project.new_record?
  end
  
  class Submit < ::Form::Submit  
{'fraction_non_alphanumeric': 0.10539714867617107, 'fraction_numerical': 0.0015274949083503055, 'mean_word_length': 4.614285714285714, 'pattern_counts': {'":': 0, '<': 11, '<?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': '3203250', 'n_tokens_mistral': 596, 'n_tokens_neox': 571, 'n_words': 148}