diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb
index 7ec796b61..1c05399c4 100644
--- a/app/controllers/files_controller.rb
+++ b/app/controllers/files_controller.rb
@@ -26,7 +26,7 @@ class FilesController < ApplicationController
before_filter :authorize, :except => [:create,:getattachtype,:quote_resource_show,:search,:searchone4reload,:search_project,:quote_resource_show_project,
:search_tag_attachment,:subfield_upload_file,:search_org_subfield_tag_attachment,
:search_tag_attachment,:quote_resource_show_org_subfield,:find_org_subfield_attache,
- :search_files_in_subfield,:upload_files_menu,:file_hidden,:republish_file]
+ :search_files_in_subfield,:upload_files_menu,:file_hidden,:republish_file,:update_file_description]
helper :sort
include SortHelper
@@ -911,5 +911,10 @@ class FilesController < ApplicationController
def upload_files_menu
-end
+ end
+ def update_file_description
+ @attachment = Attachment.find(params[:id])
+ @attachment.description = params[:description]
+ @attachment.save
+ end
end
diff --git a/app/views/files/_file_description.html.erb b/app/views/files/_file_description.html.erb
new file mode 100644
index 000000000..5d46eaaeb
--- /dev/null
+++ b/app/views/files/_file_description.html.erb
@@ -0,0 +1,5 @@
+
')>
+ 资源描述:<% if file.description.blank? %>点击添加描述<% else %><%= file.description %><% end %>
+ <%#= file.description.blank? ? "该资源暂无描述" : file.description %>
+ <%= link_to image_tag("../images/signature_edit.png",width:"12px", height: "12px"), "javascript:void(0);", :onclick => "show_edit_file_description("+file.id.to_s+");"%>
+
\ No newline at end of file
diff --git a/app/views/files/_resource_detail.html.erb b/app/views/files/_resource_detail.html.erb
index 2a03723ca..e7d43a9d4 100644
--- a/app/views/files/_resource_detail.html.erb
+++ b/app/views/files/_resource_detail.html.erb
@@ -35,10 +35,25 @@
文件大小:<%= number_to_human_size(file.filesize) %>
下载<%= file.downloads%> | 引用<%= file.quotes.nil? ? 0:file.quotes %>
- <% unless file.description.blank? %>
+ <%# unless file.description.blank? %>
- 资源描述:<%= file.description %>
- <% end %>
+ <% if User.current.logged? && ((is_course_teacher(User.current,@course) || file.author_id == User.current.id) && course_contains_attachment?(@course,file)) && ((delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course") %>
+
+
+ <%= render :partial => 'files/file_description', :locals => {:file => file} %>
+
+
+
+ <% else %>
+
+ <% unless file.description.blank? %>
+
+
资源描述:<%= file.description %>
+ <% end %>
+
+ <% end %>
+ <%# end %>
diff --git a/app/views/files/update_file_description.js.erb b/app/views/files/update_file_description.js.erb
new file mode 100644
index 000000000..2954fb567
--- /dev/null
+++ b/app/views/files/update_file_description.js.erb
@@ -0,0 +1,3 @@
+$("#file_description_show_<%= @attachment.id %>").html("<%= escape_javascript render(:partial => "files/file_description", :locals => {:file => @attachment}) %>");
+$("#file_description_show_<%= @attachment.id %>").show();
+$("#file_description_edit_<%= @attachment.id %>").hide();
diff --git a/config/routes.rb b/config/routes.rb
index e4b462d93..a778a8016 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -975,7 +975,6 @@ RedmineApp::Application.routes.draw do
match 'delete_softapplications', :via => [:get, :post]
end
end
-
resources :groups do
member do
get 'autocomplete_for_user'
@@ -1114,6 +1113,7 @@ RedmineApp::Application.routes.draw do
match "quote_resource_show", :via => [:get]
get "file_hidden"
post "republish_file"
+ get "update_file_description"
end
end
resources :memberships, :shallow => true, :controller => 'members', :only => [:index, :show, :new, :create, :update, :destroy] do
diff --git a/public/javascripts/application.js b/public/javascripts/application.js
index 73b667740..0437125e8 100644
--- a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -1480,3 +1480,21 @@ function autoUrl(id){
}
}
+//编辑资源描述
+function show_edit_file_description(id) {
+ $("#file_description_show_"+id).hide();
+ $("#file_description_edit_"+id).show();
+ $("#file_description_edit_"+id).focus();
+}
+
+//编辑资源描述之后提交
+function edit_file_description(url,id){
+ $.get(
+ url,
+ {id: id ,description: $("#file_description_edit_"+id).val() },
+ function (data) {
+
+ }
+ );
+}
+