diff --git a/app/controllers/journals_controller.rb b/app/controllers/journals_controller.rb index 1908213c..28505a04 100644 --- a/app/controllers/journals_controller.rb +++ b/app/controllers/journals_controller.rb @@ -16,7 +16,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class JournalsController < ApplicationController - before_filter :find_journal, :only => [:edit, :diff] + before_filter :find_journal, :only => [:edit, :diff, :destroy] before_filter :find_issue, :only => [:new] before_filter :find_optional_project, :only => [:index] before_filter :authorize, :only => [:new, :edit, :diff] @@ -94,6 +94,12 @@ class JournalsController < ApplicationController end end end + + # Delete a journals added by young + def destroy + @journal.destroy + redirect_to issue_path(@journal.journalized) + end private diff --git a/app/helpers/journals_helper.rb b/app/helpers/journals_helper.rb index b8e7f8bf..80bfd65b 100644 --- a/app/helpers/journals_helper.rb +++ b/app/helpers/journals_helper.rb @@ -21,6 +21,7 @@ module JournalsHelper def render_notes(issue, journal, options={}) content = '' editable = User.current.logged? && (User.current.allowed_to?(:edit_issue_notes, issue.project) || (journal.user == User.current && User.current.allowed_to?(:edit_own_issue_notes, issue.project))) + destroyable = User.current.logged? && ((journal.user == User.current) || (issue.author_id == User.current.id) || (User.current.admin == 1)) links = [] if !journal.notes.blank? links << link_to(image_tag('comment.png'), @@ -31,8 +32,13 @@ module JournalsHelper links << link_to_in_place_notes_editor(image_tag('edit.png'), "journal-#{journal.id}-notes", { :controller => 'journals', :action => 'edit', :id => journal, :format => 'js' }, :title => l(:button_edit)) if editable + #Added by young + if destroyable + links << link_to(image_tag('delete.png'), { :controller => 'journals', :action => 'destroy', :id => journal, :format => 'js' }, + :title => l(:button_delete)) + end end - content << content_tag('div', links.join(' ').html_safe, :class => 'contextual') unless links.empty? + content << content_tag('div', links.join(' ').html_safe, :class => 'contextual', :style => 'margin-top:-25px;') unless links.empty? content << textilizable(journal, :notes) css_classes = "wiki" css_classes << " editable" if editable diff --git a/app/views/issues/_attributes.html.erb b/app/views/issues/_attributes.html.erb index 9b4c508c..83822397 100644 --- a/app/views/issues/_attributes.html.erb +++ b/app/views/issues/_attributes.html.erb @@ -1,6 +1,8 @@ <%= labelled_fields_for :issue, @issue do |f| %> -