Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

custom_field.rb 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # redMine - project management software
  2. # Copyright (C) 2006 Jean-Philippe Lang
  3. #
  4. # This program is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU General Public License
  6. # as published by the Free Software Foundation; either version 2
  7. # of the License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. class CustomField < ActiveRecord::Base
  18. has_many :custom_values, :dependent => true
  19. FIELD_FORMATS = { "list" => :label_list,
  20. "date" => :label_date,
  21. "bool" => :label_boolean,
  22. "int" => :label_integer,
  23. "string" => :label_string,
  24. "text" => :label_text
  25. }.freeze
  26. validates_presence_of :name, :field_format
  27. validates_uniqueness_of :name
  28. validates_inclusion_of :field_format, :in => FIELD_FORMATS.keys
  29. validates_presence_of :possible_values, :if => Proc.new { |field| field.field_format == "list" }
  30. # to move in project_custom_field
  31. def self.for_all
  32. find(:all, :conditions => ["is_for_all=?", true])
  33. end
  34. def type_name
  35. nil
  36. end
  37. end