Home > Redmine > Redmine 1.4 & Hide list of members(author, assignee) in reports (show only for admin)

Redmine 1.4 & Hide list of members(author, assignee) in reports (show only for admin)

vi app/views/reports/issue_report.html.erb

<%= render :partial => 'simple', :locals => { :data => @issues_by_priority, :field_name => "priority_id", :rows => @priorities } %>
<br />
<% if User.current.admin? %>
<h3><%=l(:field_assigned_to)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), :action => 'issue_report_details', :detail => 'assigned_to' %></h3>
<%= render :partial => 'simple', :locals => { :data => @issues_by_assigned_to, :field_name => "assigned_to_id", :rows => @assignees } %>
<h3><%=l(:field_author)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), :action => 'issue_report_details', :detail => 'author' %></h3>
<%= render :partial => 'simple', :locals => { :data => @issues_by_author, :field_name => "author_id", :rows => @authors } %>
<% end %>

 

vi app/controllers/reports_controller.rb

    when "assigned_to"
      if User.current.admin?
        @field = "assigned_to_id"
        @rows = (Setting.issue_group_assignment? ? @project.principals : @project.users).sort
        @data = Issue.by_assigned_to(@project)
        @report_title = l(:field_assigned_to)
      end
    when "author"
      if User.current.admin?
        @field = "author_id"
        @rows = @project.users.sort
        @data = Issue.by_author(@project)
        @report_title = l(:field_author)
      endif
...

 

vi app/models/query.rb

    users = principals.select {|p| p.is_a?(User)}

    if User.current.admin?
      assigned_to_values = []
      assigned_to_values << ["<< #{l(:label_me)} >>", "me"] if User.current.logged?
      assigned_to_values += (Setting.issue_group_assignment? ? principals : users).collect{|s| [s.name, s.id.to_s] }
      @available_filters["assigned_to_id"] = { :type => :list_optional, :o rder => 4, :values => assigned_to_values } unless assigned_to_values.empty?

      author_values = []
      author_values << ["<< #{l(:label_me)} >>", "me"] if User.current.logged?
      author_values += users.collect{|s| [s.name, s.id.to_s] }
      @available_filters["author_id"] = { :type => :list, :o rder => 5, :values => author_values } unless author_values.empty?

      group_values = Group.all.collect {|g| [g.name, g.id.to_s] }
      @available_filters["member_of_group"] = { :type => :list_optional, :o rder => 6, :values => group_values } unless group_values.empty?

      role_values = Role.givable.collect {|r| [r.name, r.id.to_s] }
      @available_filters["assigned_to_role"] = { :type => :list_optional, :o rder => 7, :values => role_values } unless role_values.empty?

      if User.current.logged?
        @available_filters["watcher_id"] = { :type => :list, :o rder => 15, :values => [["<< #{l(:label_me)} >>", "me"]] }
      end
    end
...

 

rake tmp:cache:clear
rake tmp:sessions:clear
touch tmp/restart.txt

Categories: Redmine Tags:
  1. No comments yet.
  1. No trackbacks yet.