From dfdc58719a6519dd227bd2bc1af5b0829e1e440d Mon Sep 17 00:00:00 2001 From: nwb Date: Mon, 28 Jul 2014 10:46:05 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E4=B8=BB=E7=95=99?= =?UTF-8?q?=E8=A8=80=E6=B7=BB=E5=8A=A0=E5=88=A0=E9=99=A4=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/journals_for_message.rb | 10 ++++++++++ app/views/courses/feedback.html.erb | 3 +++ 2 files changed, 13 insertions(+) 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/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 %>
From a8ed4272cc936f6d32cd535f0b7bc9c5d9f664e7 Mon Sep 17 00:00:00 2001 From: yanxd Date: Mon, 28 Jul 2014 11:03:24 +0800 Subject: [PATCH 2/3] =?UTF-8?q?ckeditor:=20=E6=8F=8F=E8=BF=B0=E4=B8=AD?= =?UTF-8?q?=E7=BD=91=E5=9D=80=E5=90=8E=E9=9D=A2=E5=B8=A6=E6=9C=89=E6=8D=A2?= =?UTF-8?q?=E8=A1=8C=EF=BC=8Cprojects=E5=88=97=E8=A1=A8=E5=87=BA=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/projects/_project.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/projects/_project.html.erb b/app/views/projects/_project.html.erb index c057202f8..3c858cce6 100644 --- a/app/views/projects/_project.html.erb +++ b/app/views/projects/_project.html.erb @@ -12,7 +12,7 @@

- <%= textilizable(project.short_description, :project => project) %> + <%= textilizable(project.short_description.strip, :project => project) %>

From 74de064cca5bc69cace56578f83d45a95839eb9e Mon Sep 17 00:00:00 2001 From: nwb Date: Mon, 28 Jul 2014 11:29:55 +0800 Subject: [PATCH 3/3] =?UTF-8?q?1.=E6=96=87=E4=BB=B6=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=9D=83=E9=99=90=E5=88=A4=E6=96=AD=E4=BC=98=E5=8C=96=202.?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E9=80=9A=E7=9F=A5=E9=99=84=E4=BB=B6=E5=88=A0?= =?UTF-8?q?=E9=99=A4BUG=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 4 +++- app/helpers/application_helper.rb | 4 ++++ app/views/attachments/_links.html.erb | 2 +- app/views/news/_course_show.html.erb | 2 +- lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb | 9 +++++++-- 5 files changed, 16 insertions(+), 5 deletions(-) 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/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/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 @@ <%= format_time(comment.created_on) %> - <%= link_to_if_authorized image_tag('delete.png'), {:controller => 'comments', :action => 'destroy', :id => @news, :comment_id => comment}, + <%= link_to_if_authorized_course image_tag('delete.png'), {:controller => 'comments', :action => 'destroy', :id => @news, :comment_id => comment}, :data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %> diff --git a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb index b9e6174ae..9f85dc49f 100644 --- a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb +++ b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb @@ -48,8 +48,13 @@ module Redmine end def attachments_deletable?(user=User.current) - (respond_to?(:visible?) ? visible?(user) : true) && - user.allowed_to?(self.class.attachable_options[:delete_permission], self.project) + if (self.has_attribute?(:course) ||self.has_attribute?(:course_id)) && self.course + (respond_to?(:visible?) ? visible?(user) : true) && + user.allowed_to?(self.class.attachable_options[:delete_permission], self.course) + else + (respond_to?(:visible?) ? visible?(user) : true) && + user.allowed_to?(self.class.attachable_options[:delete_permission], self.project) + end end def saved_attachments