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/controllers/org_subfields_controller.rb b/app/controllers/org_subfields_controller.rb
index 34e996494..2b41983cc 100644
--- a/app/controllers/org_subfields_controller.rb
+++ b/app/controllers/org_subfields_controller.rb
@@ -9,14 +9,15 @@ class OrgSubfieldsController < ApplicationController
@subfield = OrgSubfield.create(:name => params[:name], :organization_id => params[:organization_id], :priority => @organization.org_subfields.order("priority").last.priority + 1)
if !params[:sub_dir].blank?
sql = "select subfield_subdomain_dirs.* from subfield_subdomain_dirs, org_subfields where subfield_subdomain_dirs.org_subfield_id = org_subfields.id "+
- "and org_subfields.organization_id=#{@organization.id} and subfield_subdomain_dirs.name='#{params[:sub_dir]}'"
+ "and org_subfields.organization_id=#{@organization.id} and subfield_subdomain_dirs.name='#{params[:sub_dir]}'"
if SubfieldSubdomainDir.find_by_sql(sql).count == 0
SubfieldSubdomainDir.create(:org_subfield_id => @subfield.id, :name => params[:sub_dir].downcase)
end
end
- @subfield.update_attributes(:field_type => params[:field_type])
+ #默认类型为帖子
+ @subfield.update_attributes(:field_type => params[:field_type]||"Post")
# admin配置的类型
- update_status_by_type(@subfield, params[:field_type])
+ update_status_by_type(@subfield, params[:field_type]||"Post")
else
@res = false
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/app/views/forums/create.js.erb b/app/views/forums/create.js.erb
index 88e535e72..8323ec6d7 100644
--- a/app/views/forums/create.js.erb
+++ b/app/views/forums/create.js.erb
@@ -1,6 +1,7 @@
<%if @save_flag%>
-$('#new_forum_div').slideToggle();$('#create_btn').parent().slideToggle();
-$('#reorder_time').click();
+//$('#new_forum_div').slideToggle();$('#create_btn').parent().slideToggle();
+//$('#reorder_time').click();
+window.location.href= "http://"+"<%= Setting.host_name%>"+"/forums/" + "<%= @forum.id%>"
<%else%>
$("#error").html("<%= @forum.errors.full_messages[0]%>").show();
<%end %>
\ No newline at end of file
diff --git a/app/views/org_subfields/create.js.erb b/app/views/org_subfields/create.js.erb
index 952ed7b2c..2149f6dcd 100644
--- a/app/views/org_subfields/create.js.erb
+++ b/app/views/org_subfields/create.js.erb
@@ -4,6 +4,8 @@
$("#sub_field_left_lists").html("");
$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>");
$("#org_custom_admin").html("<%= escape_javascript(render :partial => 'organizations/org_custom_admin') %>");
+ //默认选中第一个
+ $("input[name='field_type']").get(0).checked=true;
<% end %>
-$("#subfield_name").val("");
-$("#sub_dir").val("");
\ No newline at end of file
+ $("#subfield_name").val("");
+ $("#sub_dir").val("");
\ No newline at end of file
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) {
+
+ }
+ );
+}
+