diff --git a/app/models/user.rb b/app/models/user.rb index ed10519fd..e0913a290 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -51,7 +51,7 @@ class User < Avatar validates :language, inclusion: { in: LANGUAGES }, allow_blank: true attr_accessible :email, :password, :password_confirmation, :current_password, :remember_me, :login, :name, :uname, :language, - :site, :company, :professional_experience, :location, :sound_notifications + :site, :company, :professional_experience, :location, :sound_notifications, :hide_email attr_readonly :uname attr_accessor :login diff --git a/app/views/shared/_profile.html.haml b/app/views/shared/_profile.html.haml index 08ca0d24e..ee7deabe3 100644 --- a/app/views/shared/_profile.html.haml +++ b/app/views/shared/_profile.html.haml @@ -20,11 +20,13 @@ = link_to image_tag('gears.png'), edit_url if edit_url.present? .both - if user - %p.info.first - - message = "#{t 'activerecord.attributes.user.email'}: " - = message - = mail_to user.email, short_message(user.email, max_length - message.length), encode: 'javascript', title: user.email - %p.info + - show_email = current_user == user || !user.hide_email? + - if show_email + %p.info.first + - message = "#{t 'activerecord.attributes.user.email'}: " + = message + = mail_to user.email, short_message(user.email, max_length - message.length), encode: 'javascript', title: user.email + %p.info{ class: show_email ? '' : 'first' } - message = "#{t 'activerecord.attributes.user.site'}: " = message = link_to short_message(user.site, max_length - message.length), user.site, title: user.site diff --git a/app/views/users/base/_form.html.haml b/app/views/users/base/_form.html.haml index 594c859c7..2b2c4fbef 100644 --- a/app/views/users/base/_form.html.haml +++ b/app/views/users/base/_form.html.haml @@ -16,6 +16,9 @@ .leftlist= f.label :email, t("activerecord.attributes.user.email") .rightlist= f.text_field :email .both +.leftlist= f.label :hide_email, t("activerecord.attributes.user.hide_email") +.rightlist= f.check_box :hide_email +.both .leftlist= f.label :site, t("activerecord.attributes.user.site") .rightlist= f.text_field :site .both diff --git a/config/locales/users.en.yml b/config/locales/users.en.yml index 670b678d2..47e777b92 100644 --- a/config/locales/users.en.yml +++ b/config/locales/users.en.yml @@ -36,6 +36,7 @@ en: name: Name login: Nickname or Email email: Email + hide_email: Hide email uname: Nickname ssh_key: SSH key current_password: Current password diff --git a/config/locales/users.ru.yml b/config/locales/users.ru.yml index a79c1bf57..b07425e71 100644 --- a/config/locales/users.ru.yml +++ b/config/locales/users.ru.yml @@ -36,6 +36,7 @@ ru: name: Имя login: Псевдоним или Email email: Email + hide_email: Прятать email uname: Никнейм ssh_key: SSH ключ current_password: Текущий пароль diff --git a/db/migrate/20140625204136_add_hide_email_to_users.rb b/db/migrate/20140625204136_add_hide_email_to_users.rb new file mode 100644 index 000000000..0f8eac9da --- /dev/null +++ b/db/migrate/20140625204136_add_hide_email_to_users.rb @@ -0,0 +1,5 @@ +class AddHideEmailToUsers < ActiveRecord::Migration + def change + add_column :users, :hide_email, :boolean, default: true, null: false + end +end diff --git a/db/schema.rb b/db/schema.rb index a4195f668..b24587d21 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: 20140612213342) do +ActiveRecord::Schema.define(version: 20140625204136) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -360,6 +360,7 @@ ActiveRecord::Schema.define(version: 20140612213342) do t.string "authentication_token" t.integer "build_priority", default: 50 t.boolean "sound_notifications", default: true + t.boolean "hide_email", default: true, null: false t.index ["authentication_token"], :name => "index_users_on_authentication_token" t.index ["confirmation_token"], :name => "index_users_on_confirmation_token", :unique => true t.index ["email"], :name => "index_users_on_email", :unique => true