diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 026a12e9a..36dd61105 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -174,7 +174,9 @@ class AttachmentsController < ApplicationController respond_to do |format| # modify by nwb if !@attachment.container.nil? && (@attachment.container.is_a?(Course) || @attachment.container.course) - if @course.nil? + if @attachment.container.is_a?(News) + format.html { redirect_to_referer_or news_path(@attachment.container) } + elsif @course.nil? format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) } else format.html { redirect_to_referer_or course_path(@course) } diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b6cd47924..77741e5e5 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -68,6 +68,10 @@ module ApplicationHelper link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller] || params[:controller], options[:action]) end + def link_to_if_authorized_course(name, options = {}, html_options = nil, *parameters_for_method_reference) + link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for_course(options[:controller] || params[:controller], options[:action]) + end + def link_to_if_authorized_contest(name, options = {}, html_options = nil, *parameters_for_method_reference) link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for_contest(options[:controller] || params[:controller], options[:action]) end diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 4debe668f..c79004794 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -68,6 +68,7 @@ class JournalsForMessage < ActiveRecord::Base return true end end + def self.remove_by_user? user if( self.user == user || @@ -87,6 +88,15 @@ class JournalsForMessage < ActiveRecord::Base def reference_user User.find(reply_id) end + + def delete_by_user?user + # 用户可删除自己的留言 + if self.user.id == user.id || user.admin? + return true + else + return false + end + end def self.reference_message(user_id) @user = User.find(user_id) diff --git a/app/views/attachments/_links.html.erb b/app/views/attachments/_links.html.erb index 52b090bd8..99ecab35d 100644 --- a/app/views/attachments/_links.html.erb +++ b/app/views/attachments/_links.html.erb @@ -15,7 +15,7 @@ :method => :delete, :class => 'delete', :title => l(:button_delete) %> - <% else %> + <% else %> <%= link_to image_tag('delete.png'), attachment_path(attachment), :data => {:confirm => l(:text_are_you_sure)}, :method => :delete, diff --git a/app/views/courses/feedback.html.erb b/app/views/courses/feedback.html.erb index 90803fdd0..903b0b5fc 100644 --- a/app/views/courses/feedback.html.erb +++ b/app/views/courses/feedback.html.erb @@ -78,6 +78,9 @@ function checkMaxLength() { '#{l(:label_reply_plural)} #{journal.user.name}: '); return false;"} %> <% end %> + <% if journal.delete_by_user?(User.current) %> + <%= link_to(l(:button_delete), {:controller => 'words', :action => 'destroy', :object_id => journal, :user_id => journal.user}, :method => :delete,:remote => true)%> + <% end %>
diff --git a/app/views/news/_course_show.html.erb b/app/views/news/_course_show.html.erb index 7b5d17e43..727c9eb7a 100644 --- a/app/views/news/_course_show.html.erb +++ b/app/views/news/_course_show.html.erb @@ -75,7 +75,7 @@- <%= textilizable(project.short_description, :project => project) %> + <%= textilizable(project.short_description.strip, :project => project) %>