668 |
668 |
target.destroy unless target.blank?
|
669 |
669 |
end
|
670 |
670 |
|
|
671 |
# Ennder 2014-12-18 custom values roles
|
|
672 |
# Returns the custom_field_values that can be edited by the given user
|
|
673 |
def editable_custom_field_values(user=nil)
|
|
674 |
user_real = user || User.current
|
|
675 |
custom_field_values.select do |value|
|
|
676 |
value.custom_field.editable_by?(project, user_real)
|
|
677 |
end
|
|
678 |
end
|
|
679 |
|
671 |
680 |
safe_attributes 'name',
|
672 |
681 |
'description',
|
673 |
682 |
'homepage',
|
... | ... | |
678 |
687 |
'tracker_ids',
|
679 |
688 |
'issue_custom_field_ids'
|
680 |
689 |
|
|
690 |
# Ennder 2014-12-18 custom values roles
|
|
691 |
# Safely sets attributes
|
|
692 |
def safe_attributes=(attrs, user=User.current)
|
|
693 |
return unless attrs.is_a?(Hash)
|
|
694 |
|
|
695 |
attrs = attrs.dup
|
|
696 |
|
|
697 |
attrs = delete_unsafe_attributes(attrs, user)
|
|
698 |
return if attrs.empty?
|
|
699 |
|
|
700 |
if attrs['custom_field_values'].present?
|
|
701 |
editable_custom_field_ids = editable_custom_field_values(user).map {|v| v.custom_field_id.to_s}
|
|
702 |
# TODO: use #select when ruby1.8 support is dropped
|
|
703 |
attrs['custom_field_values'] = attrs['custom_field_values'].reject {|k, v| !editable_custom_field_ids.include?(k.to_s)}
|
|
704 |
end
|
|
705 |
|
|
706 |
if attrs['custom_fields'].present?
|
|
707 |
editable_custom_field_ids = editable_custom_field_values(user).map {|v| v.custom_field_id.to_s}
|
|
708 |
# TODO: use #select when ruby1.8 support is dropped
|
|
709 |
attrs['custom_fields'] = attrs['custom_fields'].reject {|c| !editable_custom_field_ids.include?(c['id'].to_s)}
|
|
710 |
end
|
|
711 |
|
|
712 |
# mass-assignment security bypass
|
|
713 |
assign_attributes attrs, :without_protection => true
|
|
714 |
end
|
|
715 |
|
681 |
716 |
safe_attributes 'enabled_module_names',
|
682 |
717 |
:if => lambda {|project, user| project.new_record? || user.allowed_to?(:select_project_modules, project) }
|
683 |
718 |
|
684 |
|
-- /tmp/D5JbSb_project_custom_field.rb 2014-12-19 02:26:38.000000000 +0100
|
|
719 |
++ /mnt/donnees/amoi/devs/professionnel/web/rails/v3/redmine/app/models/project_custom_field.rb 2014-12-19 01:58:06.053804375 +0100
|
... | ... | |
19 |
19 |
def type_name
|
20 |
20 |
:label_project_plural
|
21 |
21 |
end
|
|
22 |
|
|
23 |
#Ennder 2014-12-18 project custom fields edition roles
|
|
24 |
def editable_by?(project, user=User.current)
|
|
25 |
editable || (roles & user.roles_for_project(project)).present?
|
|
26 |
end
|
22 |
27 |
end
|
23 |
|
-- /tmp/HxpIta__form.html.erb 2014-12-19 02:26:38.000000000 +0100
|
|
28 |
++ /mnt/donnees/amoi/devs/professionnel/web/rails/v3/redmine/app/views/custom_fields/_form.html.erb 2014-12-19 01:55:27.873407107 +0100
|
... | ... | |
66 |
66 |
<p><%= f.check_box :searchable %></p>
|
67 |
67 |
<% end %>
|
68 |
68 |
<p><%= f.check_box :is_filter %></p>
|
|
69 |
<p>
|
|
70 |
<label><%= l(:field_editable) %></label>
|
|
71 |
<label class="block">
|
|
72 |
<%= radio_button_tag 'custom_field[editable]', 1, @custom_field.editable?, :id => 'custom_field_editable_on',
|
|
73 |
:data => {:disables => '.custom_field_role input'} %>
|
|
74 |
<%= l(:label_visibility_public) %>
|
|
75 |
</label>
|
|
76 |
<label class="block">
|
|
77 |
<%= radio_button_tag 'custom_field[editable]', 0, !@custom_field.editable?, :id => 'custom_field_editable_off',
|
|
78 |
:data => {:enables => '.custom_field_role input'} %>
|
|
79 |
<%= l(:label_visibility_roles) %>:
|
|
80 |
</label>
|
|
81 |
<% Role.givable.sorted.each do |role| %>
|
|
82 |
<label class="block custom_field_role" style="padding-left:2em;">
|
|
83 |
<%= check_box_tag 'custom_field[role_ids][]', role.id, @custom_field.roles.include?(role), :id => nil %>
|
|
84 |
<%= role.name %>
|
|
85 |
</label>
|
|
86 |
<% end %>
|
|
87 |
<%= hidden_field_tag 'custom_field[role_ids][]', '' %>
|
|
88 |
</p>
|
69 |
89 |
|
70 |
90 |
<% when "VersionCustomField" %>
|
71 |
91 |
<p><%= f.check_box :is_required %></p>
|
72 |
|
-- /tmp/13wo6a__form.html.erb 2014-12-19 02:26:38.000000000 +0100
|
|
92 |
++ /mnt/donnees/amoi/devs/professionnel/web/rails/v3/redmine/app/views/projects/_form.html.erb 2014-12-18 01:31:45.763029689 +0100
|
... | ... | |
22 |
22 |
|
23 |
23 |
<%= wikitoolbar_for 'project_description' %>
|
24 |
24 |
|
25 |
|
<% @project.custom_field_values.each do |value| %>
|
|
25 |
<% @project.editable_custom_field_values.each do |value| %>
|
26 |
26 |
<p><%= custom_field_tag_with_label :project, value %></p>
|
27 |
27 |
<% end %>
|
28 |
28 |
<%= call_hook(:view_projects_form, :project => @project, :form => f) %>
|