From bda9b98a562eba802e00781c355cbade50f3d267 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 22 Dec 2012 10:30:42 +0000 Subject: [PATCH] Code cleanup, use named routes. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11068 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/issue.rb | 5 +++++ app/views/issues/_action_menu.html.erb | 4 ++-- app/views/issues/_list_simple.html.erb | 4 ++-- app/views/issues/show.html.erb | 10 +++------- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/app/models/issue.rb b/app/models/issue.rb index 7f2996fd6..2d9228b1d 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -134,6 +134,11 @@ class Issue < ActiveRecord::Base end end + # Returns true if user or current user is allowed to edit or add a note to the issue + def editable?(user=User.current) + user.allowed_to?(:edit_issues, project) || user.allowed_to?(:add_issue_notes, project) + end + def initialize(attributes=nil, *args) super if new_record? diff --git a/app/views/issues/_action_menu.html.erb b/app/views/issues/_action_menu.html.erb index 69c0e2c1e..aade33970 100644 --- a/app/views/issues/_action_menu.html.erb +++ b/app/views/issues/_action_menu.html.erb @@ -1,7 +1,7 @@
-<%= link_to_if_authorized(l(:button_update), {:controller => 'issues', :action => 'edit', :id => @issue }, :onclick => 'showAndScrollTo("update", "issue_notes"); return false;', :class => 'icon icon-edit', :accesskey => accesskey(:edit)) %> +<%= link_to l(:button_update), edit_issue_path(@issue), :onclick => 'showAndScrollTo("update", "issue_notes"); return false;', :class => 'icon icon-edit', :accesskey => accesskey(:edit) if @issue.editable? %> <%= link_to l(:button_log_time), new_issue_time_entry_path(@issue), :class => 'icon icon-time-add' if User.current.allowed_to?(:log_time, @project) %> <%= watcher_tag(@issue, User.current) %> -<%= link_to_if_authorized l(:button_copy), {:controller => 'issues', :action => 'new', :project_id => @project, :copy_from => @issue}, :class => 'icon icon-copy' %> +<%= link_to l(:button_copy), project_copy_issue_path(@project, @issue), :class => 'icon icon-copy' if User.current.allowed_to?(:add_issues, @project) %> <%= link_to l(:button_delete), issue_path(@issue), :data => {:confirm => issues_destroy_confirmation_message(@issue)}, :method => :delete, :class => 'icon icon-del' if User.current.allowed_to?(:delete_issues, @project) %>
diff --git a/app/views/issues/_list_simple.html.erb b/app/views/issues/_list_simple.html.erb index ae34000f1..0e4aa0731 100644 --- a/app/views/issues/_list_simple.html.erb +++ b/app/views/issues/_list_simple.html.erb @@ -12,12 +12,12 @@ <%= check_box_tag("ids[]", issue.id, false, :style => 'display:none;', :id => nil) %> - <%= link_to(h(issue.id), :controller => 'issues', :action => 'show', :id => issue) %> + <%= link_to issue.id, issue_path(issue) %> <%= link_to_project(issue.project) %> <%=h issue.tracker %> - <%= link_to h(truncate(issue.subject, :length => 60)), :controller => 'issues', :action => 'show', :id => issue %> (<%=h issue.status %>) + <%= link_to truncate(issue.subject, :length => 60), issue_path(issue) %> (<%=h issue.status %>) <% end %> diff --git a/app/views/issues/show.html.erb b/app/views/issues/show.html.erb index c41b7b790..83b4f56ed 100644 --- a/app/views/issues/show.html.erb +++ b/app/views/issues/show.html.erb @@ -61,7 +61,7 @@ end end if User.current.allowed_to?(:view_time_entries, @project) - rows.right l(:label_spent_time), (@issue.total_spent_hours > 0 ? (link_to l_hours(@issue.total_spent_hours), {:controller => 'timelog', :action => 'index', :project_id => @project, :issue_id => @issue}) : "-"), :class => 'spent-time' + rows.right l(:label_spent_time), (@issue.total_spent_hours > 0 ? link_to(l_hours(@issue.total_spent_hours), project_issue_time_entries_path(@project, @issue)) : "-"), :class => 'spent-time' end end %> <%= render_custom_fields_rows(@issue) %> @@ -73,11 +73,7 @@ end %> <% if @issue.description? %>
- <%= link_to l(:button_quote), - {:controller => 'journals', :action => 'new', :id => @issue}, - :remote => true, - :method => 'post', - :class => 'icon icon-comment' if authorize_for('issues', 'edit') %> + <%= link_to l(:button_quote), quoted_issue_path(@issue), :remote => true, :method => 'post', :class => 'icon icon-comment' if authorize_for('issues', 'edit') %>

<%=l(:field_description)%>

@@ -130,7 +126,7 @@ end %> <%= render :partial => 'action_menu' %>
-<% if authorize_for('issues', 'edit') %> +<% if @issue.editable? %>