1
0
mirror of https://github.com/meineerde/redmine.git synced 2025-12-19 15:01:14 +00:00

Added Issue#attributes_editable?

git-svn-id: http://svn.redmine.org/redmine/trunk@13996 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2015-02-13 19:30:15 +00:00
parent 9548d39a15
commit 37aa016740
3 changed files with 7 additions and 4 deletions

View File

@ -116,7 +116,6 @@ class IssuesController < ApplicationController
@relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? } @relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? }
@allowed_statuses = @issue.new_statuses_allowed_to(User.current) @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
@edit_allowed = User.current.allowed_to?(:edit_issues, @project)
@priorities = IssuePriority.active @priorities = IssuePriority.active
@time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project) @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
@relation = IssueRelation.new @relation = IssueRelation.new
@ -393,7 +392,6 @@ class IssuesController < ApplicationController
# from the params # from the params
# TODO: Refactor, not everything in here is needed by #edit # TODO: Refactor, not everything in here is needed by #edit
def update_issue_from_params def update_issue_from_params
@edit_allowed = User.current.allowed_to?(:edit_issues, @project)
@time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project) @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
if params[:time_entry] if params[:time_entry]
@time_entry.attributes = params[:time_entry] @time_entry.attributes = params[:time_entry]

View 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 # Returns true if user or current user is allowed to edit or add a note to the issue
def editable?(user=User.current) 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 end
def initialize(attributes=nil, *args) def initialize(attributes=nil, *args)

View File

@ -2,7 +2,7 @@
<%= error_messages_for 'issue', 'time_entry' %> <%= error_messages_for 'issue', 'time_entry' %>
<%= render :partial => 'conflict' if @conflict %> <%= render :partial => 'conflict' if @conflict %>
<div class="box"> <div class="box">
<% if @edit_allowed %> <% if @issue.attributes_editable? %>
<fieldset class="tabular"><legend><%= l(:label_change_properties) %></legend> <fieldset class="tabular"><legend><%= l(:label_change_properties) %></legend>
<div id="all_attributes"> <div id="all_attributes">
<%= render :partial => 'form', :locals => {:f => f} %> <%= render :partial => 'form', :locals => {:f => f} %>