From 4f2b26a9c54871b453d0bb755994ad2afea622ac Mon Sep 17 00:00:00 2001 From: zhangyang Date: Sun, 25 Aug 2013 21:53:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=97=AE=E9=A2=98bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/journals_controller.rb | 8 +++++++- app/helpers/journals_helper.rb | 8 +++++++- app/views/issues/_attributes.html.erb | 18 ++++-------------- app/views/issues/_edit.html.erb | 16 ---------------- app/views/issues/new.html.erb | 3 ++- config/routes.rb | 1 + 6 files changed, 21 insertions(+), 33 deletions(-) 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| %> -
+ <% if @issue.safe_attribute? 'custom_field_values' %> <%= render :partial => 'issues/form_custom_fields' %> diff --git a/app/views/issues/_edit.html.erb b/app/views/issues/_edit.html.erb index a59b0786..b9322243 100644 --- a/app/views/issues/_edit.html.erb +++ b/app/views/issues/_edit.html.erb @@ -9,22 +9,6 @@
<% end %> - <% if User.current.allowed_to?(:log_time, @project) %> -
<%= l(:button_log_time) %> - <%= labelled_fields_for :time_entry, @time_entry do |time_entry| %> -
-

<%= time_entry.text_field :hours, :size => 6, :label => :label_spent_time %> <%= l(:field_hours) %>

-
-
-

<%= time_entry.select :activity_id, activity_collection_for_select_options %>

-
-

<%= time_entry.text_field :comments, :size => 60 %>

- <% @time_entry.custom_field_values.each do |value| %> -

<%= custom_field_tag_with_label :time_entry, value %>

- <% end %> - <% end %> -
- <% end %>
<%= l(:field_notes) %> <%= f.text_area :notes, :cols => 60, :rows => 10, :class => 'wiki-edit', :no_label => true %> diff --git a/app/views/issues/new.html.erb b/app/views/issues/new.html.erb index 82b3f6f9..9f0743a1 100644 --- a/app/views/issues/new.html.erb +++ b/app/views/issues/new.html.erb @@ -22,8 +22,9 @@

<% end %> +

<%= render :partial => 'attachments/form', :locals => {:container => @issue} %>

- + <% if @issue.safe_attribute? 'watcher_user_ids' -%>

diff --git a/config/routes.rb b/config/routes.rb index f0e692fe..c9548918 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -65,6 +65,7 @@ RedmineApp::Application.routes.draw do match '/journals/diff/:id', :to => 'journals#diff', :id => /\d+/, :via => :get match '/journals/edit/:id', :to => 'journals#edit', :id => /\d+/, :via => [:get, :post] + match '/journals/destroy/:id', :to => 'journals#destroy', :id => /\d+/, :via => [:get, :post] get '/projects/:project_id/issues/gantt', :to => 'gantts#show', :as => 'project_gantt'