diff --git a/app/models/environment.rb b/app/models/environment.rb index 53c087d..aeb9ec1 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -591,7 +591,7 @@ class Environment < ActiveRecord::Base # only one environment can be the default one validates_uniqueness_of :is_default, :if => (lambda do |environment| environment.is_default? end), :message => N_('Only one Virtual Community can be the default one') - validates_format_of :contact_email, :with => Noosfero::Constants::EMAIL_FORMAT, :if => (lambda { |record| ! record.contact_email.blank? }) + validates_format_of :contact_email, :noreply_email, :with => Noosfero::Constants::EMAIL_FORMAT, :allow_blank => true xss_terminate :only => [ :message_for_disabled_enterprise ], :with => 'white_list', :on => 'validation' diff --git a/db/migrate/20140303173209_move_contact_email_to_noreply_email_at_environment.rb b/db/migrate/20140303173209_move_contact_email_to_noreply_email_at_environment.rb new file mode 100644 index 0000000..b49fec5 --- /dev/null +++ b/db/migrate/20140303173209_move_contact_email_to_noreply_email_at_environment.rb @@ -0,0 +1,16 @@ +class MoveContactEmailToNoreplyEmailAtEnvironment < ActiveRecord::Migration + def self.up + add_column :environments, :noreply_email, :string + Environment.reset_column_information + + Environment.find_each do |environment| + environment.noreply_email = environment.contact_email + environment.contact_email = nil + environment.save! + end + end + + def self.down + say "this migration can't be reverted" + end +end diff --git a/db/schema.rb b/db/schema.rb index afa3e66..2471cbf 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1,4 +1,4 @@ -# This file is auto-generated from the current state of the database. Instead of editing this file, +# This file is auto-generated from the current state of the database. Instead of editing this file, # please use the migrations feature of Active Record to incrementally modify your database, and # then regenerate this schema definition. # @@ -9,7 +9,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140108132730) do +ActiveRecord::Schema.define(:version => 20140303173209) do create_table "abuse_reports", :force => true do |t| t.integer "reporter_id" @@ -282,6 +282,7 @@ ActiveRecord::Schema.define(:version => 20140108132730) do t.text "signup_welcome_text" t.string "languages" t.string "default_language" + t.string "noreply_email" end create_table "external_feeds", :force => true do |t| -- libgit2 0.21.2