diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-02-16 13:19:33 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-02-16 13:19:33 +0000 |
commit | 1c8cf4ef8338736ebcaa905f8932545a24e817c6 (patch) | |
tree | 1511225a9139cd3f2113c9b908a88c70f4166958 /app | |
parent | abb0b15407b33cbe50dc263474631c5bfcf2bd5f (diff) | |
download | redmine-1c8cf4ef8338736ebcaa905f8932545a24e817c6.tar.gz redmine-1c8cf4ef8338736ebcaa905f8932545a24e817c6.zip |
Added the following permissions (#527, #585, #627):
* edit_issue_notes: let user edit any notes
* edit_own_issue_notes: let user edit his own notes only
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1152 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/journals_controller.rb | 2 | ||||
-rw-r--r-- | app/helpers/journals_helper.rb | 2 | ||||
-rw-r--r-- | app/models/journal.rb | 3 | ||||
-rw-r--r-- | app/views/issues/_history.rhtml | 2 | ||||
-rw-r--r-- | app/views/journals/update.rjs | 11 |
5 files changed, 14 insertions, 6 deletions
diff --git a/app/controllers/journals_controller.rb b/app/controllers/journals_controller.rb index 05d41fa30..758b8507f 100644 --- a/app/controllers/journals_controller.rb +++ b/app/controllers/journals_controller.rb @@ -22,11 +22,11 @@ class JournalsController < ApplicationController def edit if request.post? @journal.update_attributes(:notes => params[:notes]) if params[:notes] + @journal.destroy if @journal.details.empty? && @journal.notes.blank? respond_to do |format| format.html { redirect_to :controller => 'issues', :action => 'show', :id => @journal.journalized_id } format.js { render :action => 'update' } end - return end end diff --git a/app/helpers/journals_helper.rb b/app/helpers/journals_helper.rb index 2f902432d..234bfabc0 100644 --- a/app/helpers/journals_helper.rb +++ b/app/helpers/journals_helper.rb @@ -19,7 +19,7 @@ module JournalsHelper def render_notes(journal, options={}) content = '' editable = journal.editable_by?(User.current) - if editable + if editable && !journal.notes.blank? links = [] links << link_to_in_place_notes_editor(image_tag('edit.png'), "journal-#{journal.id}-notes", { :controller => 'journals', :action => 'edit', :id => journal }, diff --git a/app/models/journal.rb b/app/models/journal.rb index df7308435..013e2644d 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -51,6 +51,7 @@ class Journal < ActiveRecord::Base end def editable_by?(usr) - usr && usr.admin? + project = journalized.project + usr && usr.logged? && (usr.allowed_to?(:edit_issue_notes, project) || (self.user == usr && usr.allowed_to?(:edit_own_issue_notes, project))) end end diff --git a/app/views/issues/_history.rhtml b/app/views/issues/_history.rhtml index edfb9b94d..7c1ee2113 100644 --- a/app/views/issues/_history.rhtml +++ b/app/views/issues/_history.rhtml @@ -1,5 +1,6 @@ <% note_id = 1 %> <% for journal in journals %> + <div id="change-<%= journal.id %>"> <h4><div style="float:right;"><%= link_to "##{note_id}", :anchor => "note-#{note_id}" %></div> <%= content_tag('a', '', :name => "note-#{note_id}")%> <%= format_time(journal.created_on) %> - <%= journal.user.name %></h4> @@ -9,5 +10,6 @@ <% end %> </ul> <%= render_notes(journal) unless journal.notes.blank? %> + </div> <% note_id += 1 %> <% end %> diff --git a/app/views/journals/update.rjs b/app/views/journals/update.rjs index 9da0ebeae..2b5a54c0a 100644 --- a/app/views/journals/update.rjs +++ b/app/views/journals/update.rjs @@ -1,3 +1,8 @@ -page.replace "journal-#{@journal.id}-notes", render_notes(@journal) -page.show "journal-#{@journal.id}-notes" -page.remove "journal-#{@journal.id}-form" +if @journal.frozen? + # journal was destroyed + page.remove "change-#{@journal.id}" +else + page.replace "journal-#{@journal.id}-notes", render_notes(@journal) + page.show "journal-#{@journal.id}-notes" + page.remove "journal-#{@journal.id}-form" +end |