From 67ffc03feead83b26952e1873a45720db6cb25d5 Mon Sep 17 00:00:00 2001 From: z9han Date: Mon, 22 Dec 2014 16:16:33 +0800 Subject: [PATCH] =?UTF-8?q?#1708=20=E8=AF=BE=E7=A8=8B--=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E5=BA=93=EF=BC=9A=E9=9D=9E=E8=AF=BE=E7=A8=8B=E6=88=90=E5=91=98?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E5=BC=95=E7=94=A8=E7=A7=81=E6=9C=89=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E9=87=8C=E9=9D=A2=E7=9A=84=E5=85=AC=E5=BC=80=E8=B5=84?= =?UTF-8?q?=E6=BA=90,=E6=94=B9=E4=B8=BA=E6=8F=90=E7=A4=BA=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E6=9D=83=E9=99=90=E5=BC=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 1 + app/views/files/_show_quote_resource.html.erb | 29 ++++++++++++------- app/views/files/quote_resource_show.js.erb | 7 ++++- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 2f33ab554..d87992ec8 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -201,6 +201,7 @@ class FilesController < ApplicationController def quote_resource_show @file = Attachment.find(params[:id]) + @can_quote = attachment_candown @file end def new diff --git a/app/views/files/_show_quote_resource.html.erb b/app/views/files/_show_quote_resource.html.erb index 58b0edda0..eb1ed446e 100644 --- a/app/views/files/_show_quote_resource.html.erb +++ b/app/views/files/_show_quote_resource.html.erb @@ -1,17 +1,24 @@

将此课件引入我的课程资源库

-
-
- <%= form_tag course_attach_relations_path, - method: :post, - remote: true, - id: "relation_file_form" do %> - <%= hidden_field_tag(:file_id, file.id) %> - <%= content_tag('div', courses_check_box_tags('courses[course][]', User.current.courses,course,file), :id => 'courses')%> - 引  用取  消 - <% end -%> -
+ <% if error == '403' %> +
+
您没有权限引用此资源
+
+ <% else %> +
+
+ <%= form_tag course_attach_relations_path, + method: :post, + remote: true, + id: "relation_file_form" do %> + <%= hidden_field_tag(:file_id, file.id) %> + <%= content_tag('div', courses_check_box_tags('courses[course][]', User.current.courses,course,file), :id => 'courses')%> + 引  用取  消 + <% end -%> +
+ <% end %> +
diff --git a/app/views/files/quote_resource_show.js.erb b/app/views/files/quote_resource_show.js.erb index 3acfeb988..1d82479c5 100644 --- a/app/views/files/quote_resource_show.js.erb +++ b/app/views/files/quote_resource_show.js.erb @@ -1,4 +1,9 @@ -$('#ajax-modal').html('<%= escape_javascript(render :partial => 'show_quote_resource',:locals => {:course => @course,:file => @file}) %>'); +<% if @can_quote %> + $('#ajax-modal').html('<%= escape_javascript(render :partial => 'show_quote_resource',:locals => {:course => @course,:file => @file,:error => ''}) %>'); +<% else %> + $('#ajax-modal').html('<%= escape_javascript(render :partial => 'show_quote_resource',:locals => {:course => @course,:file => @file,:error => '403'}) %>'); +<% end %> + showModal('ajax-modal', '513px'); $('#ajax-modal').siblings().remove(); $('#ajax-modal').before("");