def show
@user = User.find(params[:id])
- @custom_values = @user.custom_values
# show projects based on current user visibility
@memberships = @user.memberships.all(:conditions => Project.visible_by(User.current))
custom_field.editable?
end
+ def visible?
+ custom_field.visible?
+ end
+
def required?
custom_field.is_required?
end
<% when "UserCustomField" %>
<p><%= f.check_box :is_required %></p>
+ <p><%= f.check_box :visible %></p>
<p><%= f.check_box :editable %></p>
<% when "ProjectCustomField" %>
<p><%= f.check_box :is_required %></p>
+ <p><%= f.check_box :visible %></p>
<p><%= f.check_box :searchable %></p>
<% when "TimeEntryCustomField" %>
xml.description project.description
xml.parent(:id => project.parent_id, :name => project.parent.name) unless project.parent.nil?
xml.custom_fields do
- project.custom_field_values.each do |custom_value|
+ project.visible_custom_field_values.each do |custom_value|
xml.custom_field custom_value.value, :id => custom_value.custom_field_id, :name => custom_value.custom_field.name
end
end unless project.custom_field_values.empty?
<li><%=l(:label_subproject_plural)%>:
<%= @subprojects.collect{|p| link_to(h(p), :action => 'show', :id => p)}.join(", ") %></li>
<% end %>
- <% @project.custom_values.each do |custom_value| %>
+ <% @project.visible_custom_field_values.each do |custom_value| %>
<% if !custom_value.value.blank? %>
<li><%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
<% end %>
xml.homepage @project.homepage
xml.custom_fields do
- @project.custom_field_values.each do |custom_value|
+ @project.visible_custom_field_values.each do |custom_value|
xml.custom_field custom_value.value, :id => custom_value.custom_field_id, :name => custom_value.custom_field.name
end
end unless @project.custom_field_values.empty?
<% unless @user.pref.hide_mail %>
<li><%=l(:field_mail)%>: <%= mail_to(h(@user.mail), nil, :encode => 'javascript') %></li>
<% end %>
- <% for custom_value in @custom_values %>
+ <% @user.visible_custom_field_values.each do |custom_value| %>
<% if !custom_value.value.blank? %>
<li><%=h custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
<% end %>
field_member_of_group: "Assignee's group"
field_assigned_to_role: "Assignee's role"
field_text: Text field
+ field_visible: Visible
setting_app_title: Application title
setting_app_subtitle: Application subtitle
field_sharing: Partage
field_active: Actif
field_parent_issue: Tâche parente
+ field_visible: Visible
setting_app_title: Titre de l'application
setting_app_subtitle: Sous-titre de l'application
field_member_of_group: Groupe de l'assigné
field_assigned_to_role: Rôle de l'assigné
field_start_date: Start date
+ setting_emails_header: Emails header
--- /dev/null
+class AddCustomFieldsVisible < ActiveRecord::Migration
+ def self.up
+ add_column :custom_fields, :visible, :boolean, :null => false, :default => true
+ end
+
+ def self.down
+ remove_column :custom_fields, :visible
+ end
+end
custom_field_id: 4
customized_id: 2
id: 3
- value: ""
+ value: "01 42 50 00 00"
custom_values_004:
customized_type: Issue
custom_field_id: 2
assert_template 'show'
assert_not_nil assigns(:project)
assert_equal Project.find_by_identifier('ecookbook'), assigns(:project)
+
+ assert_tag 'li', :content => /Development status/
+ end
+
+ def test_show_should_not_display_hidden_custom_fields
+ ProjectCustomField.find_by_name('Development status').update_attribute :visible, false
+ get :show, :id => 'ecookbook'
+ assert_response :success
+ assert_template 'show'
+ assert_not_nil assigns(:project)
+
+ assert_no_tag 'li', :content => /Development status/
end
def test_show_should_not_fail_when_custom_values_are_nil
class UsersControllerTest < ActionController::TestCase
include Redmine::I18n
- fixtures :users, :projects, :members, :member_roles, :roles, :auth_sources
+ fixtures :users, :projects, :members, :member_roles, :roles, :auth_sources, :custom_fields, :custom_values
def setup
@controller = UsersController.new
assert_response :success
assert_template 'show'
assert_not_nil assigns(:user)
+
+ assert_tag 'li', :content => /Phone number/
+ end
+
+ def test_show_should_not_display_hidden_custom_fields
+ @request.session[:user_id] = nil
+ UserCustomField.find_by_name('Phone number').update_attribute :visible, false
+ get :show, :id => 2
+ assert_response :success
+ assert_template 'show'
+ assert_not_nil assigns(:user)
+
+ assert_no_tag 'li', :content => /Phone number/
end
def test_show_should_not_fail_when_custom_values_are_nil
get '/projects/1.xml'
assert_response :success
assert_equal 'application/xml', @response.content_type
+ assert_tag 'custom_field', :attributes => {:name => 'Development status'}, :content => 'Stable'
+ end
+
+ def test_show_should_not_display_hidden_custom_fields
+ ProjectCustomField.find_by_name('Development status').update_attribute :visible, false
+ get '/projects/1.xml'
+ assert_response :success
+ assert_equal 'application/xml', @response.content_type
+ assert_no_tag 'custom_field', :attributes => {:name => 'Development status'}
end
def test_create
@custom_field_values ||= available_custom_fields.collect { |x| custom_values.detect { |v| v.custom_field == x } || custom_values.build(:custom_field => x, :value => nil) }
end
+ def visible_custom_field_values
+ custom_field_values.select(&:visible?)
+ end
+
def custom_field_values_changed?
@custom_field_values_changed == true
end