diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/issues_helper.rb | 15 | ||||
-rw-r--r-- | app/models/issue.rb | 15 | ||||
-rw-r--r-- | app/models/journal_detail.rb | 18 | ||||
-rw-r--r-- | app/models/role.rb | 3 | ||||
-rw-r--r-- | app/views/issues/_form.rhtml | 5 |
5 files changed, 50 insertions, 6 deletions
diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index d47b6e7fe..86f11c706 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -61,18 +61,23 @@ module IssuesHelper def render_issue_subject_with_tree(issue) s = '' - ancestors = issue.root? ? [] : issue.ancestors.all + ancestors = issue.root? ? [] : issue.ancestors.visible.all ancestors.each do |ancestor| s << '<div>' + content_tag('p', link_to_issue(ancestor)) end - s << '<div>' + content_tag('h3', h(issue.subject)) + s << '<div>' + subject = h(issue.subject) + if issue.is_private? + subject = content_tag('span', l(:field_is_private), :class => 'private') + ' ' + subject + end + s << content_tag('h3', subject) s << '</div>' * (ancestors.size + 1) s end def render_descendants_tree(issue) s = '<form><table class="list issues">' - issue_list(issue.descendants.sort_by(&:lft)) do |child, level| + issue_list(issue.descendants.visible.sort_by(&:lft)) do |child, level| s << content_tag('tr', content_tag('td', check_box_tag("ids[]", child.id, false, :id => nil), :class => 'checkbox') + content_tag('td', link_to_issue(child, :truncate => 60), :class => 'subject') + @@ -159,6 +164,10 @@ module IssuesHelper label = l(:field_parent_issue) value = "##{detail.value}" unless detail.value.blank? old_value = "##{detail.old_value}" unless detail.old_value.blank? + + when detail.prop_key == 'is_private' + value = l(detail.value == "0" ? :general_text_No : :general_text_Yes) unless detail.value.blank? + old_value = l(detail.old_value == "0" ? :general_text_No : :general_text_Yes) unless detail.old_value.blank? end when 'cf' custom_field = CustomField.find_by_id(detail.prop_key) diff --git a/app/models/issue.rb b/app/models/issue.rb index cbfad6a57..07966d4f7 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -90,8 +90,10 @@ class Issue < ActiveRecord::Base def self.visible_condition(user, options={}) Project.allowed_to_condition(user, :view_issues, options) do |role, user| case role.issues_visibility - when 'default' + when 'all' nil + when 'default' + "(#{table_name}.is_private = #{connection.quoted_false} OR #{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id = #{user.id})" when 'own' "(#{table_name}.author_id = #{user.id} OR #{table_name}.assigned_to_id = #{user.id})" else @@ -104,8 +106,10 @@ class Issue < ActiveRecord::Base def visible?(usr=nil) (usr || User.current).allowed_to?(:view_issues, self.project) do |role, user| case role.issues_visibility - when 'default' + when 'all' true + when 'default' + !self.is_private? || self.author == user || self.assigned_to == user when 'own' self.author == user || self.assigned_to == user else @@ -257,6 +261,12 @@ class Issue < ActiveRecord::Base 'done_ratio', :if => lambda {|issue, user| issue.new_statuses_allowed_to(user).any? } + safe_attributes 'is_private', + :if => lambda {|issue, user| + user.allowed_to?(:set_issues_private, issue.project) || + (issue.author == user && user.allowed_to?(:set_own_issues_private, issue.project)) + } + # Safely sets attributes # Should be called from controllers instead of #attributes= # attr_accessible is too rough because we still want things like @@ -552,6 +562,7 @@ class Issue < ActiveRecord::Base s << ' overdue' if overdue? s << ' child' if child? s << ' parent' unless leaf? + s << ' private' if is_private? s << ' created-by-me' if User.current.logged? && author_id == User.current.id s << ' assigned-to-me' if User.current.logged? && assigned_to_id == User.current.id s diff --git a/app/models/journal_detail.rb b/app/models/journal_detail.rb index aa22e6f71..886fe3eb4 100644 --- a/app/models/journal_detail.rb +++ b/app/models/journal_detail.rb @@ -17,4 +17,22 @@ class JournalDetail < ActiveRecord::Base belongs_to :journal + before_save :normalize_values + + private + + def normalize_values + self.value = normalize(value) + self.old_value = normalize(old_value) + end + + def normalize(v) + if v == true + "1" + elsif v == false + "0" + else + v + end + end end diff --git a/app/models/role.rb b/app/models/role.rb index 38edd360d..c11111c0a 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -21,7 +21,8 @@ class Role < ActiveRecord::Base BUILTIN_ANONYMOUS = 2 ISSUES_VISIBILITY_OPTIONS = [ - ['default', :label_issues_visibility_all], + ['all', :label_issues_visibility_all], + ['default', :label_issues_visibility_public], ['own', :label_issues_visibility_own] ] diff --git a/app/views/issues/_form.rhtml b/app/views/issues/_form.rhtml index 63def343a..4f80ac51c 100644 --- a/app/views/issues/_form.rhtml +++ b/app/views/issues/_form.rhtml @@ -1,6 +1,11 @@ <%= call_hook(:view_issues_form_details_top, { :issue => @issue, :form => f }) %> <div id="issue_descr_fields" <%= 'style="display:none"' unless @issue.new_record? || @issue.errors.any? %>> +<% if @issue.safe_attribute_names.include?('is_private') %> +<p style="float:right; margin-right:1em;"> + <label class="inline" for="issue_is_private"><%= f.check_box :is_private, :no_label => true %> <%= l(:field_is_private) %></label> +</p> +<% end %> <p><%= f.select :tracker_id, @project.trackers.collect {|t| [t.name, t.id]}, :required => true %></p> <%= observe_field :issue_tracker_id, :url => { :action => :new, :project_id => @project, :id => @issue }, :update => :attributes, |