]> source.dussan.org Git - redmine.git/commitdiff
Added Issue#attributes_editable?
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 13 Feb 2015 19:30:15 +0000 (19:30 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 13 Feb 2015 19:30:15 +0000 (19:30 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@13996 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/issues_controller.rb
app/models/issue.rb
app/views/issues/_edit.html.erb

index 13de1661a320c508ada31bec39d4f541750a3295..f5d3fcd2e0a3e19e96b89feab26e18185f301656 100644 (file)
@@ -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]
index dcf844be095165c313ef5caaa5671ff097b781b0..1e1fb9afcbd7dbaec3bf04a932955b7a4939ac66 100644 (file)
@@ -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)
index b16e85f2fcbe8228ef9a6a4c49d4186dcfaa53e4..53d58c414f8fda9b985292afbb5dfdd02be8fbc1 100644 (file)
@@ -2,7 +2,7 @@
     <%= error_messages_for 'issue', 'time_entry' %>
     <%= render :partial => 'conflict' if @conflict %>
     <div class="box">
-    <% if @edit_allowed %>
+    <% if @issue.attributes_editable? %>
         <fieldset class="tabular"><legend><%= l(:label_change_properties) %></legend>
         <div id="all_attributes">
         <%= render :partial => 'form', :locals => {:f => f} %>