#406: Hiding email from public profile

This commit is contained in:
Vokhmin Alexey V 2014-06-26 00:49:06 +04:00
parent 5611a94281
commit 4cad27ae53
7 changed files with 20 additions and 7 deletions

View File

@ -51,7 +51,7 @@ class User < Avatar
validates :language, inclusion: { in: LANGUAGES }, allow_blank: true validates :language, inclusion: { in: LANGUAGES }, allow_blank: true
attr_accessible :email, :password, :password_confirmation, :current_password, :remember_me, :login, :name, :uname, :language, 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_readonly :uname
attr_accessor :login attr_accessor :login

View File

@ -20,11 +20,13 @@
= link_to image_tag('gears.png'), edit_url if edit_url.present? = link_to image_tag('gears.png'), edit_url if edit_url.present?
.both .both
- if user - if user
%p.info.first - show_email = current_user == user || !user.hide_email?
- message = "#{t 'activerecord.attributes.user.email'}: " - if show_email
= message %p.info.first
= mail_to user.email, short_message(user.email, max_length - message.length), encode: 'javascript', title: user.email - message = "#{t 'activerecord.attributes.user.email'}: "
%p.info = 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 = "#{t 'activerecord.attributes.user.site'}: "
= message = message
= link_to short_message(user.site, max_length - message.length), user.site, title: user.site = link_to short_message(user.site, max_length - message.length), user.site, title: user.site

View File

@ -16,6 +16,9 @@
.leftlist= f.label :email, t("activerecord.attributes.user.email") .leftlist= f.label :email, t("activerecord.attributes.user.email")
.rightlist= f.text_field :email .rightlist= f.text_field :email
.both .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") .leftlist= f.label :site, t("activerecord.attributes.user.site")
.rightlist= f.text_field :site .rightlist= f.text_field :site
.both .both

View File

@ -36,6 +36,7 @@ en:
name: Name name: Name
login: Nickname or Email login: Nickname or Email
email: Email email: Email
hide_email: Hide email
uname: Nickname uname: Nickname
ssh_key: SSH key ssh_key: SSH key
current_password: Current password current_password: Current password

View File

@ -36,6 +36,7 @@ ru:
name: Имя name: Имя
login: Псевдоним или Email login: Псевдоним или Email
email: Email email: Email
hide_email: Прятать email
uname: Никнейм uname: Никнейм
ssh_key: SSH ключ ssh_key: SSH ключ
current_password: Текущий пароль current_password: Текущий пароль

View File

@ -0,0 +1,5 @@
class AddHideEmailToUsers < ActiveRecord::Migration
def change
add_column :users, :hide_email, :boolean, default: true, null: 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: 20140612213342) do ActiveRecord::Schema.define(version: 20140625204136) 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"
@ -360,6 +360,7 @@ ActiveRecord::Schema.define(version: 20140612213342) do
t.string "authentication_token" t.string "authentication_token"
t.integer "build_priority", default: 50 t.integer "build_priority", default: 50
t.boolean "sound_notifications", default: true 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 ["authentication_token"], :name => "index_users_on_authentication_token"
t.index ["confirmation_token"], :name => "index_users_on_confirmation_token", :unique => true t.index ["confirmation_token"], :name => "index_users_on_confirmation_token", :unique => true
t.index ["email"], :name => "index_users_on_email", :unique => true t.index ["email"], :name => "index_users_on_email", :unique => true