diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb
index 5385956c1..83bba0d52 100644
--- a/app/controllers/attachments_controller.rb
+++ b/app/controllers/attachments_controller.rb
@@ -343,6 +343,35 @@ class AttachmentsController < ApplicationController
end
end
+ def add_exist_file_to_courses
+ file = Attachment.find(params[:file_id])
+ courses = params[:courses][:course]
+ courses.each do |course|
+ c = Course.find(course);
+ attach_copied_obj = file.copy
+ attach_copied_obj.tag_list.add(file.tag_list) # tag关联
+ attach_copied_obj.container = c
+ attach_copied_obj.created_on = Time.now
+ attach_copied_obj.author_id = User.current.id
+ attach_copied_obj.copy_from = file.copy_from.nil? ? file.id:file.copy_from
+ if attach_copied_obj.attachtype == nil
+ attach_copied_obj.attachtype = 4
+ end
+ @obj = c
+ @save_flag = attach_copied_obj.save
+ @save_message = attach_copied_obj.errors.full_messages
+ end
+ respond_to do |format|
+ format.js
+ end
+ rescue NoMethodError
+ @save_flag = false
+ @save_message = [] << l(:error_attachment_empty)
+ respond_to do |format|
+ format.js
+ end
+ end
+
private
def find_project
@attachment = Attachment.find(params[:id])
diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb
index 2b65c1d78..57fc44f5c 100644
--- a/app/controllers/files_controller.rb
+++ b/app/controllers/files_controller.rb
@@ -22,7 +22,7 @@ class FilesController < ApplicationController
menu_item :files
before_filter :find_project_by_project_id#, :except => [:getattachtype]
- before_filter :authorize, :except => [:getattachtype]
+ before_filter :authorize, :except => [:getattachtype,:quote_resource_show]
helper :sort
include SortHelper
@@ -74,8 +74,7 @@ class FilesController < ApplicationController
when "created_on"
attribute = "created_on"
end
- @sort = order_by[0]
- @order = order_by[1]
+
if order_by.count == 1
sort += "#{Attachment.table_name}.#{attribute} asc "
elsif order_by.count == 2
@@ -116,7 +115,8 @@ class FilesController < ApplicationController
when "created_on"
attribute = "created_on"
end
-
+ @sort = order_by[0]
+ @order = order_by[1]
if order_by.count == 1
sort += "#{Attachment.table_name}.#{attribute} asc "
elsif order_by.count == 2
@@ -137,8 +137,8 @@ class FilesController < ApplicationController
end
- def upload_file_show
-
+ def quote_resource_show
+ @file = Attachment.find(params[:id])
end
def new
diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb
index 7ea49dad2..3c882d393 100644
--- a/app/helpers/attachments_helper.rb
+++ b/app/helpers/attachments_helper.rb
@@ -177,6 +177,8 @@ module AttachmentsHelper
s.html_safe
end
+
+
# Modified by Longjun
# 有参数的方法要加()
def private_filter(resultSet)
diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb
index 052aae468..9a0a1127f 100644
--- a/app/helpers/files_helper.rb
+++ b/app/helpers/files_helper.rb
@@ -44,6 +44,16 @@ module FilesHelper
File.new(zipfile_name,'w+')
end
+ def courses_check_box_tags(name,courses,current_course)
+ s = ''
+ courses.each do |course|
+ if course.id != current_course.id && is_course_teacher(User.current,course)
+ s << "
"
+ end
+ end
+ s.html_safe
+ end
+
# 判断指定的资源时候符合类型
def isTypeOk(attachment, type, contentType)
result = false
diff --git a/app/views/attachments/add_exist_file_to_courses.js.erb b/app/views/attachments/add_exist_file_to_courses.js.erb
new file mode 100644
index 000000000..23761647f
--- /dev/null
+++ b/app/views/attachments/add_exist_file_to_courses.js.erb
@@ -0,0 +1,5 @@
+<% if !@save_flag%>
+ $("#error_show").html("<%= @save_message.join(', ') %>");
+<% else %>
+ closeModal();
+<% end %>
diff --git a/app/views/files/_arrow_show.erb b/app/views/files/_arrow_show.erb
index 0fed13e60..d8f094719 100644
--- a/app/views/files/_arrow_show.erb
+++ b/app/views/files/_arrow_show.erb
@@ -1,8 +1,10 @@
<% if sort == current %>
- <% if order = "" || order =="asc" %>
- ↑
+ <% if order =="asc" %>
+ ↑
+ <% elsif order == "desc" %>
+ ↓
<% else %>
- ↓
+
<% end %>
<% end %>
\ No newline at end of file
diff --git a/app/views/files/_course_file.html.erb b/app/views/files/_course_file.html.erb
index d9546ce4e..78fdd3fc5 100644
--- a/app/views/files/_course_file.html.erb
+++ b/app/views/files/_course_file.html.erb
@@ -1,17 +1,18 @@
<% attachmenttypes = @course.attachmenttypes %>
<% sufixtypes = @course.contenttypes %>
<% delete_allowed = User.current.allowed_to?(:manage_files, @course) %>
+
<%= stylesheet_link_tag 'resource', :media => 'all' %>
\ No newline at end of file
diff --git a/app/views/files/quote_resource_show.js.erb b/app/views/files/quote_resource_show.js.erb
new file mode 100644
index 000000000..3acfeb988
--- /dev/null
+++ b/app/views/files/quote_resource_show.js.erb
@@ -0,0 +1,5 @@
+$('#ajax-modal').html('<%= escape_javascript(render :partial => 'show_quote_resource',:locals => {:course => @course,:file => @file}) %>');
+showModal('ajax-modal', '513px');
+$('#ajax-modal').siblings().remove();
+$('#ajax-modal').before("
");
+$('#ajax-modal').parent().css("top","5").css("left","511");
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 510872316..5784185d6 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -558,6 +558,7 @@ RedmineApp::Application.routes.draw do
match 'attachments/autocomplete', :to => 'attachments#autocomplete', :via => [:post]
post 'attachments/relationfile', to: 'attachments#add_exist_file_to_project', as: 'attach_relation'
post 'attachments/courserelationfile', to: 'attachments#add_exist_file_to_course', as: 'course_attach_relation'
+ post 'attachments/courserelationfiles', to: 'attachments#add_exist_file_to_courses', as: 'course_attach_relations'
get 'attachments/renderTag/:attchmentId', :to => 'attachments#renderTag', :attchmentId => /\d+/
resources :attachments, :only => [:show, :destroy] do
collection do
@@ -654,6 +655,9 @@ RedmineApp::Application.routes.draw do
collection do
match "getattachtype", :via => [:get, :post]
end
+ member do
+ match "quote_resource_show", :via => [:get]
+ end
end
resources :memberships, :shallow => true, :controller => 'members', :only => [:index, :show, :new, :create, :update, :destroy] do
collection do
diff --git a/db/schema.rb b/db/schema.rb
index f6fc138af..54ef46a70 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20141105012624) do
+ActiveRecord::Schema.define(:version => 20141120091234) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@@ -52,6 +52,7 @@ ActiveRecord::Schema.define(:version => 20141105012624) do
t.string "disk_directory"
t.integer "attachtype", :default => 1
t.integer "is_public", :default => 1
+ t.integer "copy_from"
end
add_index "attachments", ["author_id"], :name => "index_attachments_on_author_id"