add option to subscribe/unsubscribe to website newsletter

This commit is contained in:
Julian Herrero
2015-12-16 16:14:35 +01:00
parent 81bc3d7267
commit e7314ac380
7 changed files with 36 additions and 15 deletions

View File

@@ -23,9 +23,9 @@ class AccountController < ApplicationController
def account_params def account_params
if @account.organization? 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 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
end end

View File

@@ -54,6 +54,13 @@
<% end %> <% end %>
</div> </div>
<div>
<%= f.label :email_newsletter_subscribed do %>
<%= f.check_box :subscription_to_website_newsletter, label: false %>
<span class="checkbox"><%= t("account.show.subscription_to_website_newsletter_label") %></span>
<% end %>
</div>
<%= f.submit t("account.show.save_changes_submit"), class: "button radius" %> <%= f.submit t("account.show.save_changes_submit"), class: "button radius" %>
</div> </div>

View File

@@ -291,6 +291,7 @@ en:
public_activity_label: "Keep my list of activities public" 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_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" 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" erase_account_link: "Erase my account"
personal: "Personal details" personal: "Personal details"
username_label: "Username" username_label: "Username"

View File

@@ -291,6 +291,7 @@ es:
public_activity_label: "Mostrar públicamente mi lista de actividades" 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_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" 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" erase_account_link: "Darme de baja"
personal: "Datos personales" personal: "Datos personales"
username_label: "Nombre de usuario" username_label: "Nombre de usuario"

View File

@@ -0,0 +1,5 @@
class AddNewsletterSubscriptionToUsers < ActiveRecord::Migration
def change
add_column :users, :subscription_to_website_newsletter, :boolean, default: false
end
end

View File

@@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # 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 # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" 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 add_index "tags", ["proposals_count"], name: "index_tags_on_proposals_count", using: :btree
create_table "users", force: :cascade do |t| create_table "users", force: :cascade do |t|
t.string "email", default: "" t.string "email", default: ""
t.string "encrypted_password", default: "", null: false t.string "encrypted_password", default: "", null: false
t.string "reset_password_token" t.string "reset_password_token"
t.datetime "reset_password_sent_at" t.datetime "reset_password_sent_at"
t.datetime "remember_created_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 "current_sign_in_at"
t.datetime "last_sign_in_at" t.datetime "last_sign_in_at"
t.string "current_sign_in_ip" t.string "current_sign_in_ip"
t.string "last_sign_in_ip" t.string "last_sign_in_ip"
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.string "confirmation_token" t.string "confirmation_token"
t.datetime "confirmed_at" t.datetime "confirmed_at"
t.datetime "confirmation_sent_at" t.datetime "confirmation_sent_at"
t.string "unconfirmed_email" t.string "unconfirmed_email"
t.boolean "email_on_comment", default: false t.boolean "email_on_comment", default: false
t.boolean "email_on_comment_reply", default: false t.boolean "email_on_comment_reply", default: false
t.string "phone_number", limit: 30 t.string "phone_number", limit: 30
t.string "official_position" t.string "official_position"
t.integer "official_level", default: 0 t.integer "official_level", default: 0
t.datetime "hidden_at" t.datetime "hidden_at"
t.string "sms_confirmation_code" t.string "sms_confirmation_code"
t.string "username", limit: 60 t.string "username", limit: 60
t.string "document_number" t.string "document_number"
t.string "document_type" t.string "document_type"
t.datetime "residence_verified_at" t.datetime "residence_verified_at"
@@ -304,11 +304,12 @@ ActiveRecord::Schema.define(version: 20151111202657) do
t.datetime "letter_requested_at" t.datetime "letter_requested_at"
t.datetime "confirmed_hide_at" t.datetime "confirmed_hide_at"
t.string "letter_verification_code" 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.datetime "level_two_verified_at"
t.string "erase_reason" t.string "erase_reason"
t.datetime "erased_at" 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 end
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree

View File

@@ -77,6 +77,12 @@ describe User do
expect(subject.email_on_comment_reply).to eq(false) expect(subject.email_on_comment_reply).to eq(false)
end end
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 end
describe 'OmniAuth' do describe 'OmniAuth' do