diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 62292bf0..423a12b4 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -24,7 +24,7 @@ class RegistrationsController < Devise::RegistrationsController def configure_permitted_parameters devise_parameter_sanitizer.for(:account_update) do |u| u. - permit(:email, :password, :password_confirmation, :current_password, :username) + permit(:email, :password, :password_confirmation, :current_password, :username, :email_public) end devise_parameter_sanitizer.for(:sign_up) do |u| u. diff --git a/app/views/devise/registrations/edit.html.haml b/app/views/devise/registrations/edit.html.haml index 964ec334..d97b4867 100644 --- a/app/views/devise/registrations/edit.html.haml +++ b/app/views/devise/registrations/edit.html.haml @@ -8,6 +8,7 @@ = semantic_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| = f.input :username, required: false, input_html: { autocomplete: 'off' } = f.input :email, required: false, input_html: { autocomplete: 'off' } + = f.input :email_public = f.input :password, hint: "(Leave blank if you don't want to change it)", input_html: { autocomplete: 'off' } = f.input :password_confirmation, input_html: { autocomplete: 'off' } = f.inputs name: 'OpenID' do diff --git a/app/views/proposals/show.html.haml b/app/views/proposals/show.html.haml index 432a5dcd..baf0e404 100644 --- a/app/views/proposals/show.html.haml +++ b/app/views/proposals/show.html.haml @@ -32,7 +32,7 @@ %h3 by = link_to @speaker.name, user_path(@speaker.id) - = "(#{@speaker.email})" + = "(#{@speaker.email})" if @speaker.email_public - if @speaker.affiliation? %br %span.muted diff --git a/db/migrate/20170213145807_change_email_public_from_users.rb b/db/migrate/20170213145807_change_email_public_from_users.rb new file mode 100644 index 00000000..2bbaffa6 --- /dev/null +++ b/db/migrate/20170213145807_change_email_public_from_users.rb @@ -0,0 +1,9 @@ +class ChangeEmailPublicFromUsers < ActiveRecord::Migration + def up + change_column_default :users, :email_public, true + end + + def down + change_column_default :users, :email_public, nil + end +end diff --git a/db/schema.rb b/db/schema.rb index 5b7be51c..d0d4de72 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: 20170129075434) do +ActiveRecord::Schema.define(version: 20170213145807) do create_table "ahoy_events", force: :cascade do |t| t.uuid "visit_id", limit: 16 @@ -482,7 +482,7 @@ ActiveRecord::Schema.define(version: 20170129075434) do t.datetime "created_at" t.datetime "updated_at" t.string "name" - t.boolean "email_public" + t.boolean "email_public", default: true t.text "biography" t.string "nickname" t.string "affiliation" diff --git a/lib/tasks/user.rake b/lib/tasks/user.rake index 0e199d72..97e56e40 100644 --- a/lib/tasks/user.rake +++ b/lib/tasks/user.rake @@ -14,4 +14,8 @@ namespace :user do end end + desc "Set email_public attrubute true for all users" + task :set_email_public => :environment do + User.update_all email_public: true + end end