From 37aa016740399f2adffe43a509571b13e9025b9b Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Fri, 13 Feb 2015 19:30:15 +0000 Subject: [PATCH] Added Issue#attributes_editable? git-svn-id: http://svn.redmine.org/redmine/trunk@13996 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/issues_controller.rb | 2 -- app/models/issue.rb | 7 ++++++- app/views/issues/_edit.html.erb | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 13de1661a..f5d3fcd2e 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -116,7 +116,6 @@ class IssuesController < ApplicationController @relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? } @allowed_statuses = @issue.new_statuses_allowed_to(User.current) - @edit_allowed = User.current.allowed_to?(:edit_issues, @project) @priorities = IssuePriority.active @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project) @relation = IssueRelation.new @@ -393,7 +392,6 @@ class IssuesController < ApplicationController # from the params # TODO: Refactor, not everything in here is needed by #edit def update_issue_from_params - @edit_allowed = User.current.allowed_to?(:edit_issues, @project) @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project) if params[:time_entry] @time_entry.attributes = params[:time_entry] diff --git a/app/models/issue.rb b/app/models/issue.rb index dcf844be0..1e1fb9afc 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -153,7 +153,12 @@ class Issue < ActiveRecord::Base # 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) + attributes_editable?(user) || user.allowed_to?(:add_issue_notes, project) + end + + # Returns true if user or current user is allowed to edit the issue + def attributes_editable?(user=User.current) + user.allowed_to?(:edit_issues, project) end def initialize(attributes=nil, *args) diff --git a/app/views/issues/_edit.html.erb b/app/views/issues/_edit.html.erb index b16e85f2f..53d58c414 100644 --- a/app/views/issues/_edit.html.erb +++ b/app/views/issues/_edit.html.erb @@ -2,7 +2,7 @@ <%= error_messages_for 'issue', 'time_entry' %> <%= render :partial => 'conflict' if @conflict %>
- <% if @edit_allowed %> + <% if @issue.attributes_editable? %>
<%= l(:label_change_properties) %>
<%= render :partial => 'form', :locals => {:f => f} %> -- 2.39.5