Project

General



Profile

« Previous | Next » 

Revision 13996

Added Issue#attributes_editable?

View differences:

trunk/app/controllers/issues_controller.rb
116 116

  
117 117
    @relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? }
118 118
    @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
119
    @edit_allowed = User.current.allowed_to?(:edit_issues, @project)
120 119
    @priorities = IssuePriority.active
121 120
    @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
122 121
    @relation = IssueRelation.new
......
393 392
  # from the params
394 393
  # TODO: Refactor, not everything in here is needed by #edit
395 394
  def update_issue_from_params
396
    @edit_allowed = User.current.allowed_to?(:edit_issues, @project)
397 395
    @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
398 396
    if params[:time_entry]
399 397
      @time_entry.attributes = params[:time_entry]
trunk/app/models/issue.rb
153 153

  
154 154
  # Returns true if user or current user is allowed to edit or add a note to the issue
155 155
  def editable?(user=User.current)
156
    user.allowed_to?(:edit_issues, project) || user.allowed_to?(:add_issue_notes, project)
156
    attributes_editable?(user) || user.allowed_to?(:add_issue_notes, project)
157 157
  end
158 158

  
159
  # Returns true if user or current user is allowed to edit the issue
160
  def attributes_editable?(user=User.current)
161
    user.allowed_to?(:edit_issues, project)
162
  end
163

  
159 164
  def initialize(attributes=nil, *args)
160 165
    super
161 166
    if new_record?
trunk/app/views/issues/_edit.html.erb
2 2
    <%= error_messages_for 'issue', 'time_entry' %>
3 3
    <%= render :partial => 'conflict' if @conflict %>
4 4
    <div class="box">
5
    <% if @edit_allowed %>
5
    <% if @issue.attributes_editable? %>
6 6
        <fieldset class="tabular"><legend><%= l(:label_change_properties) %></legend>
7 7
        <div id="all_attributes">
8 8
        <%= render :partial => 'form', :locals => {:f => f} %>

Also available in: Unified diff