diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb
index f2a553c38..2d51c4b18 100644
--- a/app/controllers/account_controller.rb
+++ b/app/controllers/account_controller.rb
@@ -23,9 +23,9 @@ class AccountController < ApplicationController
def account_params
if @account.organization?
- params.require(:account).permit(:phone_number, :email_on_comment, :email_on_comment_reply, organization_attributes: [:name, :responsible_name])
+ params.require(:account).permit(:phone_number, :email_on_comment, :email_on_comment_reply, :subscription_to_website_newsletter, organization_attributes: [:name, :responsible_name])
else
- params.require(:account).permit(:username, :public_activity, :email_on_comment, :email_on_comment_reply)
+ params.require(:account).permit(:username, :public_activity, :email_on_comment, :email_on_comment_reply, :subscription_to_website_newsletter)
end
end
diff --git a/app/views/account/show.html.erb b/app/views/account/show.html.erb
index 5acf6eb62..452300f1b 100644
--- a/app/views/account/show.html.erb
+++ b/app/views/account/show.html.erb
@@ -54,6 +54,13 @@
<% end %>
+
+ <%= f.label :email_newsletter_subscribed do %>
+ <%= f.check_box :subscription_to_website_newsletter, label: false %>
+ <%= t("account.show.subscription_to_website_newsletter_label") %>
+ <% end %>
+
+
<%= f.submit t("account.show.save_changes_submit"), class: "button radius" %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 8f377af1d..7a5f3bd08 100755
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -291,6 +291,7 @@ en:
public_activity_label: "Keep my list of activities public"
email_on_comment_label: "Notify me by email when someone comments on my proposals or debates"
email_on_comment_reply_label: "Notify me by email when someone replies to my comments"
+ subscription_to_website_newsletter_label: "Receive by email website relevant information"
erase_account_link: "Erase my account"
personal: "Personal details"
username_label: "Username"
diff --git a/config/locales/es.yml b/config/locales/es.yml
index a1b1952f2..88f21506f 100644
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -291,6 +291,7 @@ es:
public_activity_label: "Mostrar públicamente mi lista de actividades"
email_on_comment_label: "Recibir un email cuando alguien comenta en mis propuestas o debates"
email_on_comment_reply_label: "Recibir un email cuando alguien contesta a mis comentarios"
+ subscription_to_website_newsletter_label: "Recibir emails con información interesante sobre la web"
erase_account_link: "Darme de baja"
personal: "Datos personales"
username_label: "Nombre de usuario"
diff --git a/db/migrate/20151215165824_add_newsletter_subscription_to_users.rb b/db/migrate/20151215165824_add_newsletter_subscription_to_users.rb
new file mode 100644
index 000000000..61e3ffff1
--- /dev/null
+++ b/db/migrate/20151215165824_add_newsletter_subscription_to_users.rb
@@ -0,0 +1,5 @@
+class AddNewsletterSubscriptionToUsers < ActiveRecord::Migration
+ def change
+ add_column :users, :subscription_to_website_newsletter, :boolean, default: false
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 448fa1a8e..7a02cd7cb 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20151111202657) do
+ActiveRecord::Schema.define(version: 20151215165824) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -270,30 +270,30 @@ ActiveRecord::Schema.define(version: 20151111202657) do
add_index "tags", ["proposals_count"], name: "index_tags_on_proposals_count", using: :btree
create_table "users", force: :cascade do |t|
- t.string "email", default: ""
- t.string "encrypted_password", default: "", null: false
+ t.string "email", default: ""
+ t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
- t.integer "sign_in_count", default: 0, null: false
+ t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.string "unconfirmed_email"
- t.boolean "email_on_comment", default: false
- t.boolean "email_on_comment_reply", default: false
- t.string "phone_number", limit: 30
+ t.boolean "email_on_comment", default: false
+ t.boolean "email_on_comment_reply", default: false
+ t.string "phone_number", limit: 30
t.string "official_position"
- t.integer "official_level", default: 0
+ t.integer "official_level", default: 0
t.datetime "hidden_at"
t.string "sms_confirmation_code"
- t.string "username", limit: 60
+ t.string "username", limit: 60
t.string "document_number"
t.string "document_type"
t.datetime "residence_verified_at"
@@ -304,11 +304,12 @@ ActiveRecord::Schema.define(version: 20151111202657) do
t.datetime "letter_requested_at"
t.datetime "confirmed_hide_at"
t.string "letter_verification_code"
- t.integer "failed_census_calls_count", default: 0
+ t.integer "failed_census_calls_count", default: 0
t.datetime "level_two_verified_at"
t.string "erase_reason"
t.datetime "erased_at"
- t.boolean "public_activity", default: true
+ t.boolean "public_activity", default: true
+ t.boolean "subscription_to_website_newsletter", default: false
end
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 9b654ddb2..aaf60586b 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -77,6 +77,12 @@ describe User do
expect(subject.email_on_comment_reply).to eq(false)
end
end
+
+ describe 'subscription_to_website_newsletter' do
+ it 'should be false by default' do
+ expect(subject.subscription_to_website_newsletter).to eq(false)
+ end
+ end
end
describe 'OmniAuth' do