<commit_before>class Event < ActiveRecord::Base

  strip_attributes

  def coordinator_id=(val)
    # this was needed due to radio button converting 'nil' value to 'on' to 0
    val = nil unless val.to_i > 0
    super val
  end

  def changed_significantly?
    # todo: remove lat+lng from this and test separataly via removal or addition of coords or distance change > n
    ['start', 'finish', 'name', 'description', 'address', 'lat', 'lng'].each do |attr|
      return true if self.send(attr) != prior[attr]
    end
    false
  end

  attr_accessor :prior
  def track
    self.prior = attributes
    ['past?', 'awaiting_approval?'].each do |meth|
      self.prior[meth] = send(meth)
    end
  end

  enum status: [:proposed, :approved, :cancelled]

  def self.read_only_for_coordinators
    [:hide_specific_location, :min, :max, :name, :description, :notes, :coordinator]
  end
  def can_edit_attribute?(attribute, user)
    return false unless user.ability.can?(:edit, self)
    user.has_role?(:admin) || !self.class.read_only_for_coordinators.include?(attribute)<commit_msg>adding event location fields (e.g. address) to list of fields not editable by coordinators<commit_after>class Event < ActiveRecord::Base

  strip_attributes

  def coordinator_id=(val)
    # this was needed due to radio button converting 'nil' value to 'on' to 0
    val = nil unless val.to_i > 0
    super val
  end

  def changed_significantly?
    # todo: remove lat+lng from this and test separataly via removal or addition of coords or distance change > n
    ['start', 'finish', 'name', 'description', 'address', 'lat', 'lng'].each do |attr|
      return true if self.send(attr) != prior[attr]
    end
    false
  end

  attr_accessor :prior
  def track
    self.prior = attributes
    ['past?', 'awaiting_approval?'].each do |meth|
      self.prior[meth] = send(meth)
    end
  end

  enum status: [:proposed, :approved, :cancelled]

  def self.read_only_for_coordinators
    [:address, :ward, :lat, :lng, :hide_specific_location, :min, :max, :name, :description, :notes, :coordinator]
  end
  def can_edit_attribute?(attribute, user)
    return false unless user.ability.can?(:edit, self)
    user.has_role?(:admin) || !self.class.read_only_for_coordinators.include?(attribute)
{'fraction_non_alphanumeric': 0.11484098939929328, 'fraction_numerical': 0.0017667844522968198, 'mean_word_length': 3.9239130434782608, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '5857737', 'n_tokens_mistral': 757, 'n_tokens_neox': 721, 'n_words': 224}