#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
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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -36,6 +36,7 @@ ru:
name: Имя
login: Псевдоним или Email
email: Email
hide_email: Прятать email
uname: Никнейм
ssh_key: SSH ключ
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.
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