Commit d96fa2ea202aab43ab09a4e7fa6ed9253f6c6704

Authored by Braulio Bhavamitra
1 parent a508d544

Replace contact_email with noreply_email on environment

app/models/environment.rb
@@ -591,7 +591,7 @@ class Environment < ActiveRecord::Base @@ -591,7 +591,7 @@ class Environment < ActiveRecord::Base
591 # only one environment can be the default one 591 # only one environment can be the default one
592 validates_uniqueness_of :is_default, :if => (lambda do |environment| environment.is_default? end), :message => N_('Only one Virtual Community can be the default one') 592 validates_uniqueness_of :is_default, :if => (lambda do |environment| environment.is_default? end), :message => N_('Only one Virtual Community can be the default one')
593 593
594 - validates_format_of :contact_email, :with => Noosfero::Constants::EMAIL_FORMAT, :if => (lambda { |record| ! record.contact_email.blank? }) 594 + validates_format_of :contact_email, :noreply_email, :with => Noosfero::Constants::EMAIL_FORMAT, :allow_blank => true
595 595
596 xss_terminate :only => [ :message_for_disabled_enterprise ], :with => 'white_list', :on => 'validation' 596 xss_terminate :only => [ :message_for_disabled_enterprise ], :with => 'white_list', :on => 'validation'
597 597
db/migrate/20140303173209_move_contact_email_to_noreply_email_at_environment.rb 0 → 100644
@@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
  1 +class MoveContactEmailToNoreplyEmailAtEnvironment < ActiveRecord::Migration
  2 + def self.up
  3 + add_column :environments, :noreply_email, :string
  4 + Environment.reset_column_information
  5 +
  6 + Environment.find_each do |environment|
  7 + environment.noreply_email = environment.contact_email
  8 + environment.contact_email = nil
  9 + environment.save!
  10 + end
  11 + end
  12 +
  13 + def self.down
  14 + say "this migration can't be reverted"
  15 + end
  16 +end
1 -# This file is auto-generated from the current state of the database. Instead of editing this file, 1 +# This file is auto-generated from the current state of the database. Instead of editing this file,
2 # please use the migrations feature of Active Record to incrementally modify your database, and 2 # please use the migrations feature of Active Record to incrementally modify your database, and
3 # then regenerate this schema definition. 3 # then regenerate this schema definition.
4 # 4 #
@@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
9 # 9 #
10 # It's strongly recommended to check this file into your version control system. 10 # It's strongly recommended to check this file into your version control system.
11 11
12 -ActiveRecord::Schema.define(:version => 20140108132730) do 12 +ActiveRecord::Schema.define(:version => 20140303173209) do
13 13
14 create_table "abuse_reports", :force => true do |t| 14 create_table "abuse_reports", :force => true do |t|
15 t.integer "reporter_id" 15 t.integer "reporter_id"
@@ -282,6 +282,7 @@ ActiveRecord::Schema.define(:version =&gt; 20140108132730) do @@ -282,6 +282,7 @@ ActiveRecord::Schema.define(:version =&gt; 20140108132730) do
282 t.text "signup_welcome_text" 282 t.text "signup_welcome_text"
283 t.string "languages" 283 t.string "languages"
284 t.string "default_language" 284 t.string "default_language"
  285 + t.string "noreply_email"
285 end 286 end
286 287
287 create_table "external_feeds", :force => true do |t| 288 create_table "external_feeds", :force => true do |t|