<commit_before>class Org < ActiveRecord::Base
  include GlobalHelpers
  include FlagShihTzu
  extend Dragonfly::Model::Validations

  ##
  # Associations
  belongs_to :organisation_type   # depricated, but cannot be removed until migration run
  belongs_to :language
  has_many :guidance_groups
  has_many :templates
  has_many :users
  has_many :suggested_answers
  has_and_belongs_to_many :token_permission_types, join_table: "org_token_permissions"

  ##
  # Possibly needed for active_admin
  #   -relies on protected_attributes gem as syntax depricated in rails 4.2
	attr_accessible :abbreviation, :banner_text, :logo, :remove_logo,
                  :logo_file_name, :name, :target_url,
                  :organisation_type_id, :wayfless_entity, :parent_id, :sort_name,
                  :token_permission_type_ids, :language_id, :contact_email

  ##
  # Validators
  validates :contact_email, email: true, allow_nil: true
  validates :name, presence: true, uniqueness: true
  # allow validations for logo upload
  dragonfly_accessor :logo do
    after_assign :resize_image
  end
  validates_property :height, of: :logo, in: (0..100)
  validates_property :format, of: :logo, in: ['jpeg', 'png', 'gif','jpg','bmp']
  validates_size_of :logo, maximum: 500.kilobytes

  ##
  # Define Bit Field values
  # Column org_type
  has_flags 1 => :institution,
            2 => :funder,
            3 => :organisation,
            4 => :research_institute,
            5 => :project,
            6 => :school,
            column: 'org_type'



  # EVALUATE CLASS AND INSTANCE METHODS BELOW
  #
  # What do they do? do they do it efficiently, and do we need them?



  ##
  # returns the name of the type of the organisation as a string
  # defaults to none if no org type present
  #
  # @return [String]
  def organisation_type
    if self.institution?
      return "Institution"
    elsif self.funder?
      return "Funder"
    elsif self.organisation?
      return "Organisation"
    elsif @org.research_institute?<commit_msg>changed Org.organisation_type to Org.type to fix conflict in running migration<commit_after>class Org < ActiveRecord::Base
  include GlobalHelpers
  include FlagShihTzu
  extend Dragonfly::Model::Validations

  ##
  # Associations
  belongs_to :organisation_type   # depricated, but cannot be removed until migration run
  belongs_to :language
  has_many :guidance_groups
  has_many :templates
  has_many :users
  has_many :suggested_answers
  has_and_belongs_to_many :token_permission_types, join_table: "org_token_permissions"

  ##
  # Possibly needed for active_admin
  #   -relies on protected_attributes gem as syntax depricated in rails 4.2
	attr_accessible :abbreviation, :banner_text, :logo, :remove_logo,
                  :logo_file_name, :name, :target_url,
                  :organisation_type_id, :wayfless_entity, :parent_id, :sort_name,
                  :token_permission_type_ids, :language_id, :contact_email

  ##
  # Validators
  validates :contact_email, email: true, allow_nil: true
  validates :name, presence: true, uniqueness: true
  # allow validations for logo upload
  dragonfly_accessor :logo do
    after_assign :resize_image
  end
  validates_property :height, of: :logo, in: (0..100)
  validates_property :format, of: :logo, in: ['jpeg', 'png', 'gif','jpg','bmp']
  validates_size_of :logo, maximum: 500.kilobytes

  ##
  # Define Bit Field values
  # Column org_type
  has_flags 1 => :institution,
            2 => :funder,
            3 => :organisation,
            4 => :research_institute,
            5 => :project,
            6 => :school,
            column: 'org_type'



  # EVALUATE CLASS AND INSTANCE METHODS BELOW
  #
  # What do they do? do they do it efficiently, and do we need them?



  ##
  # returns the name of the type of the organisation as a string
  # defaults to none if no org type present
  #
  # @return [String]
  def type
    if self.institution?
      return "Institution"
    elsif self.funder?
      return "Funder"
    elsif self.organisation?
      return "Organisation"
    elsif @org.research_institute?
{'fraction_non_alphanumeric': 0.084431429965837, 'fraction_numerical': 0.007320644216691069, 'mean_word_length': 3.269791666666667, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '4355450', 'n_tokens_mistral': 1335, 'n_tokens_neox': 1276, 'n_words': 378}