app/models/fields/field.rb in fat_free_crm-0.11.4 vs app/models/fields/field.rb in fat_free_crm-0.12.0

- old
+ new

@@ -1,22 +1,10 @@ -# Fat Free CRM -# Copyright (C) 2008-2011 by Michael Dvorkin +# Copyright (c) 2008-2013 Michael Dvorkin and contributors. # -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +# Fat Free CRM is freely distributable under the terms of MIT license. +# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php #------------------------------------------------------------------------------ - # == Schema Information # # Table name: fields # # id :integer not null, primary key @@ -42,11 +30,11 @@ serialize :collection, Array serialize :settings, HashWithIndifferentAccess belongs_to :field_group - + scope :core_fields, where(:type => 'CoreField') scope :custom_fields, where("type != 'CoreField'") scope :without_pairs, where(:pair_id => nil) delegate :klass, :klass_name, :klass_name=, :to => :field_group @@ -101,11 +89,11 @@ when 'checkbox' value.to_s == '0' ? "no" : "yes" when 'date' value && value.strftime(I18n.t("date.formats.mmddyy")) when 'datetime' - value && value.strftime(I18n.t("time.formats.mmddyyyy_hhmm")) + value && value.in_time_zone.strftime(I18n.t("time.formats.mmddyyyy_hhmm")) when 'check_boxes' value.select(&:present?).in_groups_of(2, false).map {|g| g.join(', ')}.join("<br />".html_safe) if Array === value else value.to_s end @@ -136,6 +124,7 @@ (@@field_types ||= BASE_FIELD_TYPES)[as][:klass] end end + ActiveSupport.run_load_hooks(:fat_free_crm_field, self) end