summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/my_controller.rb1
-rw-r--r--app/models/custom_value.rb8
-rw-r--r--app/views/account/register.rhtml2
-rw-r--r--app/views/custom_fields/_form.rhtml1
-rw-r--r--app/views/my/account.rhtml4
-rw-r--r--db/migrate/102_add_custom_fields_editable.rb9
-rw-r--r--db/migrate/103_set_custom_fields_editable.rb9
-rw-r--r--lang/bg.yml1
-rw-r--r--lang/ca.yml1
-rw-r--r--lang/cs.yml1
-rw-r--r--lang/da.yml1
-rw-r--r--lang/de.yml1
-rw-r--r--lang/en.yml1
-rw-r--r--lang/es.yml1
-rw-r--r--lang/fi.yml1
-rw-r--r--lang/fr.yml1
-rw-r--r--lang/he.yml1
-rw-r--r--lang/hu.yml1
-rw-r--r--lang/it.yml1
-rw-r--r--lang/ja.yml1
-rw-r--r--lang/ko.yml1
-rw-r--r--lang/lt.yml1
-rw-r--r--lang/nl.yml1
-rw-r--r--lang/no.yml1
-rw-r--r--lang/pl.yml1
-rw-r--r--lang/pt-br.yml1
-rw-r--r--lang/pt.yml1
-rw-r--r--lang/ro.yml1
-rw-r--r--lang/ru.yml1
-rw-r--r--lang/sk.yml1
-rw-r--r--lang/sr.yml1
-rw-r--r--lang/sv.yml1
-rw-r--r--lang/th.yml1
-rw-r--r--lang/tr.yml1
-rw-r--r--lang/uk.yml1
-rw-r--r--lang/vn.yml1
-rw-r--r--lang/zh-tw.yml1
-rw-r--r--lang/zh.yml1
-rw-r--r--test/fixtures/custom_fields.yml6
-rw-r--r--test/functional/my_controller_test.rb23
40 files changed, 90 insertions, 4 deletions
diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb
index 1cfa3e531..5e1b9d2c8 100644
--- a/app/controllers/my_controller.rb
+++ b/app/controllers/my_controller.rb
@@ -19,6 +19,7 @@ class MyController < ApplicationController
before_filter :require_login
helper :issues
+ helper :custom_fields
BLOCKS = { 'issuesassignedtome' => :label_assigned_to_me_issues,
'issuesreportedbyme' => :label_reported_issues,
diff --git a/app/models/custom_value.rb b/app/models/custom_value.rb
index 085d242fa..1f662baa7 100644
--- a/app/models/custom_value.rb
+++ b/app/models/custom_value.rb
@@ -30,6 +30,14 @@ class CustomValue < ActiveRecord::Base
self.value == '1'
end
+ def editable?
+ custom_field.editable?
+ end
+
+ def required?
+ custom_field.is_required?
+ end
+
def to_s
value.to_s
end
diff --git a/app/views/account/register.rhtml b/app/views/account/register.rhtml
index 755a7ad4b..45719f055 100644
--- a/app/views/account/register.rhtml
+++ b/app/views/account/register.rhtml
@@ -29,7 +29,7 @@
<p><label for="user_language"><%=l(:field_language)%></label>
<%= select("user", "language", lang_options_for_select) %></p>
-<% @user.custom_field_values.each do |value| %>
+<% @user.custom_field_values.select {|v| v.editable? || v.required?}.each do |value| %>
<p><%= custom_field_tag_with_label :user, value %></p>
<% end %>
<!--[eoform:user]-->
diff --git a/app/views/custom_fields/_form.rhtml b/app/views/custom_fields/_form.rhtml
index 0222ddb66..874c571bf 100644
--- a/app/views/custom_fields/_form.rhtml
+++ b/app/views/custom_fields/_form.rhtml
@@ -84,6 +84,7 @@ when "IssueCustomField" %>
<% when "UserCustomField" %>
<p><%= f.check_box :is_required %></p>
+ <p><%= f.check_box :editable %></p>
<% when "ProjectCustomField" %>
<p><%= f.check_box :is_required %></p>
diff --git a/app/views/my/account.rhtml b/app/views/my/account.rhtml
index f4b726f96..ef5b222e4 100644
--- a/app/views/my/account.rhtml
+++ b/app/views/my/account.rhtml
@@ -15,6 +15,10 @@
<p><%= f.text_field :lastname, :required => true %></p>
<p><%= f.text_field :mail, :required => true %></p>
<p><%= f.select :language, lang_options_for_select %></p>
+
+<% @user.custom_field_values.select(&:editable?).each do |value| %>
+ <p><%= custom_field_tag_with_label :user, value %></p>
+<% end %>
</div>
<%= submit_tag l(:button_save) %>
diff --git a/db/migrate/102_add_custom_fields_editable.rb b/db/migrate/102_add_custom_fields_editable.rb
new file mode 100644
index 000000000..949f9db9d
--- /dev/null
+++ b/db/migrate/102_add_custom_fields_editable.rb
@@ -0,0 +1,9 @@
+class AddCustomFieldsEditable < ActiveRecord::Migration
+ def self.up
+ add_column :custom_fields, :editable, :boolean, :default => true
+ end
+
+ def self.down
+ remove_column :custom_fields, :editable
+ end
+end
diff --git a/db/migrate/103_set_custom_fields_editable.rb b/db/migrate/103_set_custom_fields_editable.rb
new file mode 100644
index 000000000..465c929ec
--- /dev/null
+++ b/db/migrate/103_set_custom_fields_editable.rb
@@ -0,0 +1,9 @@
+class SetCustomFieldsEditable < ActiveRecord::Migration
+ def self.up
+ UserCustomField.update_all('editable = false')
+ end
+
+ def self.down
+ UserCustomField.update_all('editable = true')
+ end
+end
diff --git a/lang/bg.yml b/lang/bg.yml
index d0df0bd9e..bb80f1708 100644
--- a/lang/bg.yml
+++ b/lang/bg.yml
@@ -701,3 +701,4 @@ warning_attachments_not_saved: "%d file(s) could not be saved."
button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value'
label_display: Display
+field_editable: Editable
diff --git a/lang/ca.yml b/lang/ca.yml
index 26c309ee5..b0bbee2eb 100644
--- a/lang/ca.yml
+++ b/lang/ca.yml
@@ -702,3 +702,4 @@ warning_attachments_not_saved: "%d file(s) could not be saved."
button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value'
label_display: Display
+field_editable: Editable
diff --git a/lang/cs.yml b/lang/cs.yml
index ce32e3637..ab0624860 100644
--- a/lang/cs.yml
+++ b/lang/cs.yml
@@ -706,3 +706,4 @@ warning_attachments_not_saved: "%d file(s) could not be saved."
button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value'
label_display: Display
+field_editable: Editable
diff --git a/lang/da.yml b/lang/da.yml
index d46d60fef..b0df54468 100644
--- a/lang/da.yml
+++ b/lang/da.yml
@@ -702,3 +702,4 @@ warning_attachments_not_saved: "%d file(s) could not be saved."
button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value'
label_display: Display
+field_editable: Editable
diff --git a/lang/de.yml b/lang/de.yml
index c49aba0f1..e8a9d937c 100644
--- a/lang/de.yml
+++ b/lang/de.yml
@@ -703,3 +703,4 @@ warning_attachments_not_saved: "%d file(s) could not be saved."
button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value'
label_display: Display
+field_editable: Editable
diff --git a/lang/en.yml b/lang/en.yml
index 3dbfd851d..36e454692 100644
--- a/lang/en.yml
+++ b/lang/en.yml
@@ -186,6 +186,7 @@ field_searchable: Searchable
field_default_value: Default value
field_comments_sorting: Display comments
field_parent_title: Parent page
+field_editable: Editable
setting_app_title: Application title
setting_app_subtitle: Application subtitle
diff --git a/lang/es.yml b/lang/es.yml
index 9c6a08e43..c6e6234e8 100644
--- a/lang/es.yml
+++ b/lang/es.yml
@@ -686,3 +686,4 @@ warning_attachments_not_saved: "%d file(s) could not be saved."
button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value'
label_display: Display
+field_editable: Editable
diff --git a/lang/fi.yml b/lang/fi.yml
index e80a5c705..dce1192ea 100644
--- a/lang/fi.yml
+++ b/lang/fi.yml
@@ -701,3 +701,4 @@ warning_attachments_not_saved: "%d file(s) could not be saved."
button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value'
label_display: Display
+field_editable: Editable
diff --git a/lang/fr.yml b/lang/fr.yml
index ab77094a8..84f18e839 100644
--- a/lang/fr.yml
+++ b/lang/fr.yml
@@ -186,6 +186,7 @@ field_searchable: Utilisé pour les recherches
field_default_value: Valeur par défaut
field_comments_sorting: Afficher les commentaires
field_parent_title: Page parent
+field_editable: Modifiable
setting_app_title: Titre de l'application
setting_app_subtitle: Sous-titre de l'application
diff --git a/lang/he.yml b/lang/he.yml
index 447c84933..2fae88e80 100644
--- a/lang/he.yml
+++ b/lang/he.yml
@@ -701,3 +701,4 @@ warning_attachments_not_saved: "%d file(s) could not be saved."
button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value'
label_display: Display
+field_editable: Editable
diff --git a/lang/hu.yml b/lang/hu.yml
index 765c503bc..eb1670c34 100644
--- a/lang/hu.yml
+++ b/lang/hu.yml
@@ -702,3 +702,4 @@ warning_attachments_not_saved: "%d file(s) could not be saved."
button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value'
label_display: Display
+field_editable: Editable
diff --git a/lang/it.yml b/lang/it.yml
index 8838ab62b..a5d645694 100644
--- a/lang/it.yml
+++ b/lang/it.yml
@@ -701,3 +701,4 @@ warning_attachments_not_saved: "%d file(s) could not be saved."
button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value'
label_display: Display
+field_editable: Editable
diff --git a/lang/ja.yml b/lang/ja.yml
index 31ba66268..f6b696fb4 100644
--- a/lang/ja.yml
+++ b/lang/ja.yml
@@ -702,3 +702,4 @@ warning_attachments_not_saved: "%d file(s) could not be saved."
button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value'
label_display: Display
+field_editable: Editable
diff --git a/lang/ko.yml b/lang/ko.yml
index d56460ff1..8da9ac6d0 100644
--- a/lang/ko.yml
+++ b/lang/ko.yml
@@ -701,3 +701,4 @@ warning_attachments_not_saved: "%d file(s) could not be saved."
button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value'
label_display: Display
+field_editable: Editable
diff --git a/lang/lt.yml b/lang/lt.yml
index e8fb5176e..9bd57f8c6 100644
--- a/lang/lt.yml
+++ b/lang/lt.yml
@@ -703,3 +703,4 @@ warning_attachments_not_saved: "%d file(s) could not be saved."
button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value'
label_display: Display
+field_editable: Editable
diff --git a/lang/nl.yml b/lang/nl.yml
index b0db9f5e2..e223d13a6 100644
--- a/lang/nl.yml
+++ b/lang/nl.yml
@@ -703,3 +703,4 @@ warning_attachments_not_saved: "%d file(s) could not be saved."
button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value'
label_display: Display
+field_editable: Editable
diff --git a/lang/no.yml b/lang/no.yml
index 2154f56a9..0e848772e 100644
--- a/lang/no.yml
+++ b/lang/no.yml
@@ -702,3 +702,4 @@ warning_attachments_not_saved: "%d file(s) could not be saved."
button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value'
label_display: Display
+field_editable: Editable
diff --git a/lang/pl.yml b/lang/pl.yml
index a9c78da63..508216bf7 100644
--- a/lang/pl.yml
+++ b/lang/pl.yml
@@ -720,3 +720,4 @@ warning_attachments_not_saved: "%d file(s) could not be saved."
button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value'
label_display: Display
+field_editable: Editable
diff --git a/lang/pt-br.yml b/lang/pt-br.yml
index 7c494cfe3..d25260ffd 100644
--- a/lang/pt-br.yml
+++ b/lang/pt-br.yml
@@ -702,3 +702,4 @@ warning_attachments_not_saved: "%d file(s) could not be saved."
button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value'
label_display: Display
+field_editable: Editable
diff --git a/lang/pt.yml b/lang/pt.yml
index 1ec65d23b..980a6e5e0 100644
--- a/lang/pt.yml
+++ b/lang/pt.yml
@@ -703,3 +703,4 @@ warning_attachments_not_saved: "%d file(s) could not be saved."
button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value'
label_display: Display
+field_editable: Editable
diff --git a/lang/ro.yml b/lang/ro.yml
index de89d093c..bf1f11769 100644
--- a/lang/ro.yml
+++ b/lang/ro.yml
@@ -701,3 +701,4 @@ warning_attachments_not_saved: "%d file(s) could not be saved."
button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value'
label_display: Display
+field_editable: Editable
diff --git a/lang/ru.yml b/lang/ru.yml
index 0d54f8a7d..62ea8e340 100644
--- a/lang/ru.yml
+++ b/lang/ru.yml
@@ -735,3 +735,4 @@ warning_attachments_not_saved: "%d file(s) could not be saved."
button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value'
label_display: Display
+field_editable: Editable
diff --git a/lang/sk.yml b/lang/sk.yml
index 853aff646..3f7c7dc72 100644
--- a/lang/sk.yml
+++ b/lang/sk.yml
@@ -707,3 +707,4 @@ warning_attachments_not_saved: "%d file(s) could not be saved."
button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value'
label_display: Display
+field_editable: Editable
diff --git a/lang/sr.yml b/lang/sr.yml
index fd8f3ebac..455173d0c 100644
--- a/lang/sr.yml
+++ b/lang/sr.yml
@@ -702,3 +702,4 @@ warning_attachments_not_saved: "%d file(s) could not be saved."
button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value'
label_display: Display
+field_editable: Editable
diff --git a/lang/sv.yml b/lang/sv.yml
index 878d1b9f6..4a85f1504 100644
--- a/lang/sv.yml
+++ b/lang/sv.yml
@@ -702,3 +702,4 @@ warning_attachments_not_saved: "%d file(s) could not be saved."
button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value'
label_display: Display
+field_editable: Editable
diff --git a/lang/th.yml b/lang/th.yml
index a2b4d292b..8d39fb5db 100644
--- a/lang/th.yml
+++ b/lang/th.yml
@@ -704,3 +704,4 @@ warning_attachments_not_saved: "%d file(s) could not be saved."
button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value'
label_display: Display
+field_editable: Editable
diff --git a/lang/tr.yml b/lang/tr.yml
index e6dfad2d5..80655926f 100644
--- a/lang/tr.yml
+++ b/lang/tr.yml
@@ -702,3 +702,4 @@ warning_attachments_not_saved: "%d file(s) could not be saved."
button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value'
label_display: Display
+field_editable: Editable
diff --git a/lang/uk.yml b/lang/uk.yml
index 70fa21956..75c6639cb 100644
--- a/lang/uk.yml
+++ b/lang/uk.yml
@@ -703,3 +703,4 @@ warning_attachments_not_saved: "%d file(s) could not be saved."
button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value'
label_display: Display
+field_editable: Editable
diff --git a/lang/vn.yml b/lang/vn.yml
index 90b8965b8..0bff54b57 100644
--- a/lang/vn.yml
+++ b/lang/vn.yml
@@ -704,3 +704,4 @@ warning_attachments_not_saved: "%d file(s) could not be saved."
button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value'
label_display: Display
+field_editable: Editable
diff --git a/lang/zh-tw.yml b/lang/zh-tw.yml
index 72e5358ec..028457e87 100644
--- a/lang/zh-tw.yml
+++ b/lang/zh-tw.yml
@@ -703,3 +703,4 @@ warning_attachments_not_saved: "%d file(s) could not be saved."
button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value'
label_display: Display
+field_editable: Editable
diff --git a/lang/zh.yml b/lang/zh.yml
index 3bb139ab1..d25963941 100644
--- a/lang/zh.yml
+++ b/lang/zh.yml
@@ -703,3 +703,4 @@ warning_attachments_not_saved: "%d file(s) could not be saved."
button_create_and_continue: Create and continue
text_custom_field_possible_values_info: 'One line for each value'
label_display: Display
+field_editable: Editable
diff --git a/test/fixtures/custom_fields.yml b/test/fixtures/custom_fields.yml
index b7718b169..a17827473 100644
--- a/test/fixtures/custom_fields.yml
+++ b/test/fixtures/custom_fields.yml
@@ -15,6 +15,7 @@ custom_fields_001:
is_required: false
field_format: list
default_value: ""
+ editable: true
custom_fields_002:
name: Searchable field
min_length: 1
@@ -28,6 +29,7 @@ custom_fields_002:
field_format: string
searchable: true
default_value: "Default string"
+ editable: true
custom_fields_003:
name: Development status
min_length: 0
@@ -45,6 +47,7 @@ custom_fields_003:
is_required: true
field_format: list
default_value: ""
+ editable: true
custom_fields_004:
name: Phone number
min_length: 0
@@ -57,6 +60,7 @@ custom_fields_004:
is_required: false
field_format: string
default_value: ""
+ editable: true
custom_fields_005:
name: Money
min_length: 0
@@ -69,6 +73,7 @@ custom_fields_005:
is_required: false
field_format: float
default_value: ""
+ editable: true
custom_fields_006:
name: Float field
min_length: 0
@@ -81,4 +86,5 @@ custom_fields_006:
is_required: false
field_format: float
default_value: ""
+ editable: true
\ No newline at end of file
diff --git a/test/functional/my_controller_test.rb b/test/functional/my_controller_test.rb
index c1349ace4..997340096 100644
--- a/test/functional/my_controller_test.rb
+++ b/test/functional/my_controller_test.rb
@@ -22,7 +22,7 @@ require 'my_controller'
class MyController; def rescue_action(e) raise e end; end
class MyControllerTest < Test::Unit::TestCase
- fixtures :users, :issues, :issue_statuses, :trackers, :enumerations
+ fixtures :users, :issues, :issue_statuses, :trackers, :enumerations, :custom_fields
def setup
@controller = MyController.new
@@ -43,20 +43,37 @@ class MyControllerTest < Test::Unit::TestCase
assert_template 'page'
end
- def test_get_account
+ def test_my_account_should_show_editable_custom_fields
get :account
assert_response :success
assert_template 'account'
assert_equal User.find(2), assigns(:user)
+
+ assert_tag :input, :attributes => { :name => 'user[custom_field_values][4]'}
+ end
+
+ def test_my_account_should_not_show_non_editable_custom_fields
+ UserCustomField.find(4).update_attribute :editable, false
+
+ get :account
+ assert_response :success
+ assert_template 'account'
+ assert_equal User.find(2), assigns(:user)
+
+ assert_no_tag :input, :attributes => { :name => 'user[custom_field_values][4]'}
end
def test_update_account
- post :account, :user => {:firstname => "Joe", :login => "root", :admin => 1}
+ post :account, :user => {:firstname => "Joe",
+ :login => "root",
+ :admin => 1,
+ :custom_field_values => {"4" => "0100562500"}}
assert_redirected_to 'my/account'
user = User.find(2)
assert_equal user, assigns(:user)
assert_equal "Joe", user.firstname
assert_equal "jsmith", user.login
+ assert_equal "0100562500", user.custom_value_for(4).value
assert !user.admin?
end