diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb
index 7ec532d79..f149ad9b2 100644
--- a/app/controllers/attachments_controller.rb
+++ b/app/controllers/attachments_controller.rb
@@ -1,3 +1,4 @@
+#encoding: utf-8
# Redmine - project management software
# Copyright (C) 2006-2013 Jean-Philippe Lang
#
@@ -203,16 +204,49 @@ class AttachmentsController < ApplicationController
@attachment.save
@newfiledense = filedense
end
- if @project
+ tip_attachment_update
- elsif @course
-
- end
respond_to do |format|
format.js
end
end
+ def tip_attachment_update
+ if params[:course_id]
+ @tip_all_attachments = Attachment.where(:container_type => "Course", :container_id => params[:project_id])
+ @tip_all_public_attachments = Attachment.where(:container_type => "Course", :container_id => params[:project_id], :is_public => 1)
+ @tip_all_private_attachments = Attachment.where(:container_type => "Course", :container_id => params[:project_id], :is_public => 0)
+ @course = Course.find(params[:course_id])
+ elsif params[:project_id]
+ @tip_all_attachments = Attachment.where(:container_type => "Project", :container_id => params[:project_id])
+ @tip_all_public_attachments = Attachment.where(:container_type => "Project", :container_id => params[:project_id], :is_public => 1)
+ @tip_all_private_attachments = Attachment.where(:container_type => "Project", :container_id => params[:project_id], :is_public => 0)
+ @project = Project.find(params[:project_id])
+ end
+ @tag_name = params[:tag_name]
+ @other = params[:other]
+ unless @tag_name.blank?
+ if @other
+ if @project
+ @tip_all_attachments = @tip_all_attachments.select{|attachment| !attachment.tag_list.include?('软件版本') && !attachment.tag_list.include?('文档') && !attachment.tag_list.include?('代码') && !attachment.tag_list.include?('媒体') && !attachment.tag_list.include?('论文') }
+ @tip_all_public_attachments = @tip_all_public_attachments.select{|attachment| !attachment.tag_list.include?('软件版本') && !attachment.tag_list.include?('文档') && !attachment.tag_list.include?('代码') && !attachment.tag_list.include?('媒体') && !attachment.tag_list.include?('论文') }
+ @tip_all_private_attachments = @tip_all_private_attachments.select{|attachment| !attachment.tag_list.include?('软件版本') && !attachment.tag_list.include?('文档') && !attachment.tag_list.include?('代码') && !attachment.tag_list.include?('媒体') && !attachment.tag_list.include?('论文') }
+ elsif @course
+ @tip_all_attachments = @tip_all_attachments.select{|attachment| !attachment.tag_list.include?('课件') && !attachment.tag_list.include?('软件') && !attachment.tag_list.include?('媒体') && !attachment.tag_list.include?('代码') && !attachment.tag_list.include?('论文') }
+ @tip_all_public_attachments = @tip_all_public_attachments.select{|attachment| !attachment.tag_list.include?('课件') && !attachment.tag_list.include?('软件') && !attachment.tag_list.include?('媒体') && !attachment.tag_list.include?('代码') && !attachment.tag_list.include?('论文') }
+ @tip_all_private_attachments = @tip_all_private_attachments.select{|attachment| !attachment.tag_list.include?('课件') && !attachment.tag_list.include?('软件') && !attachment.tag_list.include?('媒体') && !attachment.tag_list.include?('代码') && !attachment.tag_list.include?('论文') }
+ end
+ else
+ @tip_all_attachments = @tip_all_attachments.select{|attachment| attachment.tag_list.include?(@tag_name)}
+ @tip_all_public_attachments = @tip_all_public_attachments.select{|attachment| attachment.tag_list.include?(@tag_name)}
+ @tip_all_private_attachments = @tip_all_private_attachments.select{|attachment| attachment.tag_list.include?(@tag_name)}
+ end
+ end
+ @tip_all_attachments = @tip_all_attachments.count
+ @tip_all_public_attachments = @tip_all_public_attachments.count
+ @tip_all_private_attachments = @tip_all_private_attachments.count
+ end
+
def thumbnail
if @attachment.thumbnailable? && thumbnail = @attachment.thumbnail(:size => params[:size])
if stale?(:etag => thumbnail)
@@ -281,6 +315,7 @@ class AttachmentsController < ApplicationController
@attachment.delete
@flag = true
end
+ # tip_attachment_update
respond_to do |format|
format.js
@@ -591,6 +626,7 @@ class AttachmentsController < ApplicationController
def attachment_versions
@attachment = Attachment.find(params[:id])
@attachment_histories = @attachment.attachment_histories
+ @container_tip = Project.find(params[:project_id])
respond_to do |format|
format.js
end
diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb
index 988768414..2ed17a76f 100644
--- a/app/controllers/files_controller.rb
+++ b/app/controllers/files_controller.rb
@@ -86,7 +86,7 @@ class FilesController < ApplicationController
else
@result = find_course_attache q,@course,sort
@result = visable_attachemnts @result
- # @searched_attach = paginateHelper @result,10
+ # @searched_attach = paginateHelper @result,10
@tag_list = get_course_tag_list @course
end
@all_attachments = @result
@@ -96,9 +96,9 @@ class FilesController < ApplicationController
@offset ||= @feedback_pages.offset
#@curse_attachments_all = @all_attachments[@offset, @limit]
@obj_attachments = paginateHelper @all_attachments,10
- #rescue Exception => e
- # #render 'stores'
- # redirect_to search_course_files_url
+ #rescue Exception => e
+ # #render 'stores'
+ # redirect_to search_course_files_url
end
end
@@ -176,52 +176,52 @@ class FilesController < ApplicationController
end
end
- def search_files_in_subfield
- sort = ""
- @sort = ""
- @order = ""
- @is_remote = true
- @q = params[:name].strip
- if params[:sort]
- order_by = params[:sort].split(":")
- @sort = order_by[0]
- if order_by.count > 1
- @order = order_by[1]
- end
- sort = "#{@sort} #{@order}"
+ def search_files_in_subfield
+ sort = ""
+ @sort = ""
+ @order = ""
+ @is_remote = true
+ @q = params[:name].strip
+ if params[:sort]
+ order_by = params[:sort].split(":")
+ @sort = order_by[0]
+ if order_by.count > 1
+ @order = order_by[1]
end
- # show_attachments [@course]
- begin
- q = "%#{params[:name].strip}%"
- #(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
- if params[:insite]
- if q == "%%"
- @result = []
- @searched_attach = paginateHelper @result,10
- else
- @result = find_public_attache q,sort
- @result = visable_attachemnts_insite @result,@org_subfield
- @searched_attach = paginateHelper @result,10
- end
+ sort = "#{@sort} #{@order}"
+ end
+ # show_attachments [@course]
+ begin
+ q = "%#{params[:name].strip}%"
+ #(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
+ if params[:insite]
+ if q == "%%"
+ @result = []
+ @searched_attach = paginateHelper @result,10
else
- @result = find_org_subfield_attache q,@org_subfield,sort
- @result = visable_attachemnts @result
+ @result = find_public_attache q,sort
+ @result = visable_attachemnts_insite @result,@org_subfield
@searched_attach = paginateHelper @result,10
- @tag_list = attachment_tag_list @result
end
- #rescue Exception => e
- # #render 'stores'
- # redirect_to search_course_files_url
+ else
+ @result = find_org_subfield_attache q,@org_subfield,sort
+ @result = visable_attachemnts @result
+ @searched_attach = paginateHelper @result,10
+ @tag_list = attachment_tag_list @result
end
- @page = params[:page] || 1
+ #rescue Exception => e
+ # #render 'stores'
+ # redirect_to search_course_files_url
end
+ @page = params[:page] || 1
+ end
def find_course_attache keywords,course,sort = ""
if sort == ""
sort = "created_on DESC"
end
if keywords != "%%"
- resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' AND filename LIKE :like ", like: "%#{keywords}%").reorder(sort)
+ resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' AND filename LIKE :like ", like: "%#{keywords}%").reorder(sort)
else
resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' "). reorder(sort)
end
@@ -250,7 +250,7 @@ class FilesController < ApplicationController
else
resultSet = Attachment.where("attachments.container_type = 'Project' And attachments.container_id = '#{project.id}' "). reorder(sort)
end
- end
+ end
def find_public_attache keywords,sort = ""
# StoresController#search 将每条文件都查出来,再次进行判断过滤。---> resultSet.to_a.map
@@ -260,7 +260,7 @@ class FilesController < ApplicationController
sort = "created_on DESC"
end
resultSet = Attachment.where("attachments.container_type IS NOT NULL AND attachments.copy_from IS NULL AND filename LIKE :like ", like: "%#{keywords}%").
- reorder(sort)
+ reorder(sort)
end
def index
@@ -325,7 +325,7 @@ class FilesController < ApplicationController
@containers = [ Project.includes(:attachments).reorder(sort).find(@project.id)]
show_attachments @containers
- # get_attachment_for_tip(@all_attachments)
+ get_attachment_for_tip(@all_attachments)
@tag_list = attachment_tag_list @all_attachments
@@ -355,7 +355,7 @@ class FilesController < ApplicationController
when "quotes"
attribute = "quotes"
else
- attribute = "created_on"
+ attribute = "created_on"
end
@sort = order_by[0]
@order = order_by[1]
@@ -378,7 +378,7 @@ class FilesController < ApplicationController
@containers = [ Course.includes(:attachments).reorder(sort).find(@course.id)]
show_attachments @containers
- # get_attachment_for_tip(@all_attachments)
+ get_attachment_for_tip(@all_attachments)
@tag_list = attachment_tag_list @all_attachments
@@ -501,228 +501,228 @@ class FilesController < ApplicationController
end
def create
- if params[:add_tag]
- @addTag=true
- #render :back
+ if params[:add_tag]
+ @addTag=true
+ #render :back
tag_saveEx
#render :text =>"success"
respond_to do |format|
- format.js
- end
- else
- #modify by nwb
- if @project
- @addTag=false
- if params[:in_project_toolbar]
- @in_project_toolbar = params[:in_project_toolbar]
- end
- attachments = Attachment.attach_filesex(@project, params[:attachments], params[:attachment_type])
- if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
- # 发送邮件
- Mailer.run.attachments_added(attachments[:files])
- # 生成动态
- attachments[:files].each do |file|
- ForgeActivity.create(:user_id => User.current.id, :project_id => @project.id, :forge_act_id => file.id, :forge_act_type => "Attachment")
- end
- # 更新资源总数, 根据上传的附件数累加
- @project.project_score.update_attribute(:attach_num, @project.project_score.attach_num + attachments[:files].count) unless @project.project_score.nil?
- end
- # end
- if params[:project_attachment_type] && params[:project_attachment_type].is_a?(Array)
- params[:project_attachment_type].each do |type|
- tag_name = get_project_tag_name_by_type_nmuber type
- if !attachments.empty? && attachments[:files] && tag_name != ""
- attachments[:files].each do |attachment|
- attachment.tag_list.add(tag_name)
- attachment.description = params[:description]
- attachment.save
- end
- end
- end
- else
- if params[:project_attachment_type] && params[:project_attachment_type] != "6"
- tag_name = get_project_tag_name_by_type_nmuber params[:project_attachment_type]
- if !attachments.empty? && attachments[:files] && tag_name != ""
- attachments[:files].each do |attachment|
- attachment.tag_list.add(tag_name)
- attachment.description = params[:description]
- attachment.save
- end
- end
- end
- end
- # TODO: 临时用 nyan
- sort_init 'created_on', 'desc'
- sort_update 'created_on' => "#{Attachment.table_name}.created_on",
- 'filename' => "#{Attachment.table_name}.filename",
- 'size' => "#{Attachment.table_name}.filesize",
- 'downloads' => "#{Attachment.table_name}.downloads"
-
- @containers = [Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)]
- show_attachments @containers
- @tag_list = attachment_tag_list @all_attachments
- @attachtype = 0
- @contenttype = 0
- respond_to do |format|
- format.js
- format.html {
- redirect_to project_files_url(@project)
- }
- end
- elsif @course
- @addTag=false
- if params[:in_course_toolbar]
- @in_course_toolbar = params[:in_course_toolbar]
- end
- attachments = Attachment.attach_filesex(@course, params[:attachments], params[:attachment_type])
-
- if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
- Mailer.run.attachments_added(attachments[:files])
- end
- if !attachments.empty? && attachments[:files]
- attachments[:files].each do |attachment|
- if params[:publish_time]
- if params[:publish_time] == ""
- attachment.publish_time = Date.today
- else
- attachment.publish_time = params[:publish_time]
- end
- else
- attachment.publish_time = Date.today
- end
- if attachment.publish_time > Date.today
- attachment.is_publish = 0
- end
- attachment.description = params[:description]
- attachment.save
- end
- end
- if params[:course_attachment_type] && params[:course_attachment_type].is_a?(Array)
- params[:course_attachment_type].each do |type|
- tag_name = get_tag_name_by_type_number type
- if !attachments.empty? && attachments[:files] && tag_name != ""
- attachments[:files].each do |attachment|
- attachment.tag_list.add(tag_name)
- attachment.save
- end
- end
- end
- else
- if params[:course_attachment_type] && params[:course_attachment_type] != "5"
- tag_name = get_tag_name_by_type_number params[:course_attachment_type]
- if !attachments.empty? && attachments[:files] && tag_name != ""
- attachments[:files].each do |attachment|
- attachment.tag_list.add(tag_name)
- attachment.save
- end
- end
- end
- end
- # 更新课程英雄榜得分
- course_member_score(@course.id, attachments[:files].first.author_id, "Attachment")
- # end
- # end
- # TODO: 临时用 nyan
- sort_init 'created_on', 'desc'
- sort_update 'created_on' => "#{Attachment.table_name}.created_on",
- 'filename' => "#{Attachment.table_name}.filename",
- 'size' => "#{Attachment.table_name}.filesize",
- 'downloads' => "#{Attachment.table_name}.downloads"
-
- @containers = [Course.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@course.id)]
-
- show_attachments @containers
- @tag_list = attachment_tag_list @all_attachments
-
- @attachtype = 0
- @contenttype = 0
-
- respond_to do |format|
- format.js
- format.html {
- redirect_to course_files_url(@course)
- }
- end
- elsif @org_subfield
- @addTag=false
- attachments = Attachment.attach_filesex(@org_subfield, params[:attachments], params[:org_subfield_attachment_type])
-
- if params[:org_subfield_attachment_type] && params[:org_subfield_attachment_type].is_a?(Array)
- params[:org_subfield_attachment_type].each do |type|
- tag_name = get_tag_name_by_type_number type
- if !attachments.empty? && attachments[:files] && tag_name != ""
- attachments[:files].each do |attachment|
- attachment.tag_list.add(tag_name)
- attachment.description = params[:description]
- attachment.save
- end
- end
- end
- else
- if params[:org_subfield_attachment_type] && params[:org_subfield_attachment_type] != "5"
- tag_name = get_tag_name_by_type_number params[:org_subfield_attachment_type]
- if !attachments.empty? && attachments[:files] && tag_name != ""
- attachments[:files].each do |attachment|
- attachment.tag_list.add(tag_name)
- attachment.description = params[:description]
- attachment.save
- end
- end
- end
- end
-
- # TODO: 临时用 nyan
- sort_init 'created_on', 'desc'
- sort_update 'created_on' => "#{Attachment.table_name}.created_on",
- 'filename' => "#{Attachment.table_name}.filename",
- 'size' => "#{Attachment.table_name}.filesize",
- 'downloads' => "#{Attachment.table_name}.downloads"
-
- @containers = [OrgSubfield.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@org_subfield.id)]
-
- show_attachments @containers
- @tag_list = attachment_tag_list @all_attachments
- @attachtype = 0
- @contenttype = 0
-
- respond_to do |format|
- format.js
- # format.html {
- # redirect_to org_subfield_files_url(@org_subfield)
- # }
- end
- # 组织添加附件,为了修改图片
- elsif params[:organization_id]
- @organization = Organization.find(params[:organization_id])
- @addTag=false
- # atttchment_type = 0为logo 1为banner
- if params[:logo]
- attachments = Attachment.attach_filesex(@organization, params[:attachments], false)
- else
- attachments = Attachment.attach_filesex(@organization, params[:attachments], true)
- end
- # TODO: 临时用 nyan
- sort_init 'created_on', 'desc'
- sort_update 'created_on' => "#{Attachment.table_name}.created_on",
- 'filename' => "#{Attachment.table_name}.filename",
- 'size' => "#{Attachment.table_name}.filesize",
- 'downloads' => "#{Attachment.table_name}.downloads"
-
- @containers = [Organization.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@organization.id)]
-
- show_attachments @containers
- @tag_list = attachment_tag_list @all_attachments
- @attachtype = 0
- @contenttype = 0
-
- respond_to do |format|
- format.js
- # format.html {
- # redirect_to org_subfield_files_url(@org_subfield)
- # }
- end
- end
- end
+ format.js
+ end
+ else
+ #modify by nwb
+ if @project
+ @addTag=false
+ if params[:in_project_toolbar]
+ @in_project_toolbar = params[:in_project_toolbar]
+ end
+ attachments = Attachment.attach_filesex(@project, params[:attachments], params[:attachment_type])
+ if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
+ # 发送邮件
+ Mailer.run.attachments_added(attachments[:files])
+ # 生成动态
+ attachments[:files].each do |file|
+ ForgeActivity.create(:user_id => User.current.id, :project_id => @project.id, :forge_act_id => file.id, :forge_act_type => "Attachment")
+ end
+ # 更新资源总数, 根据上传的附件数累加
+ @project.project_score.update_attribute(:attach_num, @project.project_score.attach_num + attachments[:files].count) unless @project.project_score.nil?
+ end
+ # end
+ if params[:project_attachment_type] && params[:project_attachment_type].is_a?(Array)
+ params[:project_attachment_type].each do |type|
+ tag_name = get_project_tag_name_by_type_nmuber type
+ if !attachments.empty? && attachments[:files] && tag_name != ""
+ attachments[:files].each do |attachment|
+ attachment.tag_list.add(tag_name)
+ attachment.description = params[:description]
+ attachment.save
+ end
+ end
+ end
+ else
+ if params[:project_attachment_type] && params[:project_attachment_type] != "6"
+ tag_name = get_project_tag_name_by_type_nmuber params[:project_attachment_type]
+ if !attachments.empty? && attachments[:files] && tag_name != ""
+ attachments[:files].each do |attachment|
+ attachment.tag_list.add(tag_name)
+ attachment.description = params[:description]
+ attachment.save
+ end
+ end
+ end
+ end
+ # TODO: 临时用 nyan
+ sort_init 'created_on', 'desc'
+ sort_update 'created_on' => "#{Attachment.table_name}.created_on",
+ 'filename' => "#{Attachment.table_name}.filename",
+ 'size' => "#{Attachment.table_name}.filesize",
+ 'downloads' => "#{Attachment.table_name}.downloads"
+
+ @containers = [Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)]
+ show_attachments @containers
+ @tag_list = attachment_tag_list @all_attachments
+ @attachtype = 0
+ @contenttype = 0
+ respond_to do |format|
+ format.js
+ format.html {
+ redirect_to project_files_url(@project)
+ }
+ end
+ elsif @course
+ @addTag=false
+ if params[:in_course_toolbar]
+ @in_course_toolbar = params[:in_course_toolbar]
+ end
+ attachments = Attachment.attach_filesex(@course, params[:attachments], params[:attachment_type])
+
+ if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
+ Mailer.run.attachments_added(attachments[:files])
+ end
+ if !attachments.empty? && attachments[:files]
+ attachments[:files].each do |attachment|
+ if params[:publish_time]
+ if params[:publish_time] == ""
+ attachment.publish_time = Date.today
+ else
+ attachment.publish_time = params[:publish_time]
+ end
+ else
+ attachment.publish_time = Date.today
+ end
+ if attachment.publish_time > Date.today
+ attachment.is_publish = 0
+ end
+ attachment.description = params[:description]
+ attachment.save
+ end
+ end
+ if params[:course_attachment_type] && params[:course_attachment_type].is_a?(Array)
+ params[:course_attachment_type].each do |type|
+ tag_name = get_tag_name_by_type_number type
+ if !attachments.empty? && attachments[:files] && tag_name != ""
+ attachments[:files].each do |attachment|
+ attachment.tag_list.add(tag_name)
+ attachment.save
+ end
+ end
+ end
+ else
+ if params[:course_attachment_type] && params[:course_attachment_type] != "5"
+ tag_name = get_tag_name_by_type_number params[:course_attachment_type]
+ if !attachments.empty? && attachments[:files] && tag_name != ""
+ attachments[:files].each do |attachment|
+ attachment.tag_list.add(tag_name)
+ attachment.save
+ end
+ end
+ end
+ end
+ # 更新课程英雄榜得分
+ course_member_score(@course.id, attachments[:files].first.author_id, "Attachment")
+ # end
+ # end
+ # TODO: 临时用 nyan
+ sort_init 'created_on', 'desc'
+ sort_update 'created_on' => "#{Attachment.table_name}.created_on",
+ 'filename' => "#{Attachment.table_name}.filename",
+ 'size' => "#{Attachment.table_name}.filesize",
+ 'downloads' => "#{Attachment.table_name}.downloads"
+
+ @containers = [Course.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@course.id)]
+
+ show_attachments @containers
+ @tag_list = attachment_tag_list @all_attachments
+
+ @attachtype = 0
+ @contenttype = 0
+
+ respond_to do |format|
+ format.js
+ format.html {
+ redirect_to course_files_url(@course)
+ }
+ end
+ elsif @org_subfield
+ @addTag=false
+ attachments = Attachment.attach_filesex(@org_subfield, params[:attachments], params[:org_subfield_attachment_type])
+
+ if params[:org_subfield_attachment_type] && params[:org_subfield_attachment_type].is_a?(Array)
+ params[:org_subfield_attachment_type].each do |type|
+ tag_name = get_tag_name_by_type_number type
+ if !attachments.empty? && attachments[:files] && tag_name != ""
+ attachments[:files].each do |attachment|
+ attachment.tag_list.add(tag_name)
+ attachment.description = params[:description]
+ attachment.save
+ end
+ end
+ end
+ else
+ if params[:org_subfield_attachment_type] && params[:org_subfield_attachment_type] != "5"
+ tag_name = get_tag_name_by_type_number params[:org_subfield_attachment_type]
+ if !attachments.empty? && attachments[:files] && tag_name != ""
+ attachments[:files].each do |attachment|
+ attachment.tag_list.add(tag_name)
+ attachment.description = params[:description]
+ attachment.save
+ end
+ end
+ end
+ end
+
+ # TODO: 临时用 nyan
+ sort_init 'created_on', 'desc'
+ sort_update 'created_on' => "#{Attachment.table_name}.created_on",
+ 'filename' => "#{Attachment.table_name}.filename",
+ 'size' => "#{Attachment.table_name}.filesize",
+ 'downloads' => "#{Attachment.table_name}.downloads"
+
+ @containers = [OrgSubfield.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@org_subfield.id)]
+
+ show_attachments @containers
+ @tag_list = attachment_tag_list @all_attachments
+ @attachtype = 0
+ @contenttype = 0
+
+ respond_to do |format|
+ format.js
+ # format.html {
+ # redirect_to org_subfield_files_url(@org_subfield)
+ # }
+ end
+ # 组织添加附件,为了修改图片
+ elsif params[:organization_id]
+ @organization = Organization.find(params[:organization_id])
+ @addTag=false
+ # atttchment_type = 0为logo 1为banner
+ if params[:logo]
+ attachments = Attachment.attach_filesex(@organization, params[:attachments], false)
+ else
+ attachments = Attachment.attach_filesex(@organization, params[:attachments], true)
+ end
+ # TODO: 临时用 nyan
+ sort_init 'created_on', 'desc'
+ sort_update 'created_on' => "#{Attachment.table_name}.created_on",
+ 'filename' => "#{Attachment.table_name}.filename",
+ 'size' => "#{Attachment.table_name}.filesize",
+ 'downloads' => "#{Attachment.table_name}.downloads"
+
+ @containers = [Organization.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@organization.id)]
+
+ show_attachments @containers
+ @tag_list = attachment_tag_list @all_attachments
+ @attachtype = 0
+ @contenttype = 0
+
+ respond_to do |format|
+ format.js
+ # format.html {
+ # redirect_to org_subfield_files_url(@org_subfield)
+ # }
+ end
+ end
+ end
end
def get_project_tag_name_by_type_nmuber type
@@ -798,13 +798,13 @@ class FilesController < ApplicationController
else
#捕获异常
end
- end
+ end
# 返回指定资源类型的资源列表
# added by nwb
def getattachtype
- sort_init 'created_on', 'desc'
- sort_update 'created_on' => "#{Attachment.table_name}.created_on",
+ sort_init 'created_on', 'desc'
+ sort_update 'created_on' => "#{Attachment.table_name}.created_on",
'filename' => "#{Attachment.table_name}.filename",
'size' => "#{Attachment.table_name}.filesize",
'downloads' => "#{Attachment.table_name}.downloads"
@@ -842,27 +842,27 @@ class FilesController < ApplicationController
end
end
- if @project
- @isproject = true
- @containers = [ Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)]
- @containers += @project.versions.includes(:attachments).reorder(sort).all
- show_attachments @containers
- @attachtype = params[:type].to_i
- @contenttype = params[:contentType].to_s
+ if @project
+ @isproject = true
+ @containers = [ Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)]
+ @containers += @project.versions.includes(:attachments).reorder(sort).all
+ show_attachments @containers
+ @attachtype = params[:type].to_i
+ @contenttype = params[:contentType].to_s
respond_to do |format|
format.js
- format.html {
- render :layout => 'base_projects'
- }
+ format.html {
+ render :layout => 'base_projects'
+ }
end
- elsif @course
+ elsif @course
@isproject = false
@containers = [ Course.includes(:attachments).reorder(sort).find(@course.id)]
show_attachments @containers
@attachtype = params[:type].to_i
@contenttype = params[:contentType].to_s
- # render layout: 'base_courses'
+ # render layout: 'base_courses'
@left_nav_type = 5
respond_to do |format|
format.js
@@ -870,19 +870,19 @@ class FilesController < ApplicationController
render :layout => 'base_courses'
}
end
- else
- show_attachments @containers
- @attachtype = params[:type].to_i
- @contenttype = params[:contentType].to_s
+ else
+ show_attachments @containers
+ @attachtype = params[:type].to_i
+ @contenttype = params[:contentType].to_s
- respond_to do |format|
+ respond_to do |format|
format.js
format.html
- end
- end
+ end
+ end
end
- #查找指定TAG的按条件过滤的资源列表,只有课程内搜索有此功能
+ #查找指定TAG的按条件过滤的资源列表,只有课程内搜索有此功能
def search_tag_attachment
@q,@tag_name,@order = params[:q],params[:tag_name]
@is_remote = true
diff --git a/app/views/attachments/update_file_dense.js.erb b/app/views/attachments/update_file_dense.js.erb
index 7709ee288..635fbe8bf 100644
--- a/app/views/attachments/update_file_dense.js.erb
+++ b/app/views/attachments/update_file_dense.js.erb
@@ -1,16 +1,18 @@
<% if @attachment.container_type == 'Course' %>
-$("#is_public_<%= @attachment.id %>").html("<%= escape_javascript(link_to (@attachment.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid=>@attachment.id,:newtype=>(@attachment.is_public? ? 0:1)),
+ $("#is_public_<%= @attachment.id %>").html("<%= escape_javascript(link_to (@attachment.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid=>@attachment.id, :course_id => @attachment.container_id, :tag_name => @tag_name, :other => @other,:newtype=>(@attachment.is_public? ? 0:1)),
:remote=>true,:class=>"postOptionLink",:method => :post) %>");
+ $("#tip_attachment_count").html("<%= escape_javascript( render :partial => 'files/tip_attachment_count') %>");
<% elsif @attachment.container_type == 'Project' %>
- $("#is_public_<%= @attachment.id %>").html("<%= escape_javascript(link_to (@attachment.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid => @attachment.id, :newtype => (@attachment.is_public? ? 0:1)),
+ $("#is_public_<%= @attachment.id %>").html("<%= escape_javascript(link_to (@attachment.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid => @attachment.id, :project_id => @attachment.container_id, :tag_name => @tag_name, :other => @other ,:newtype => (@attachment.is_public? ? 0:1)),
:remote => true, :class => "postOptionLink", :method => :post) %>");
+ $("#tip_attachment_count").html("<%= escape_javascript( render :partial => 'files/tip_attachment_count') %>");
<% else %>
-$("#is_public_<%= @attachment.id %>").html("<%= escape_javascript(link_to (@attachment.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid=>@attachment.id,:newtype=>(@attachment.is_public? ? 0:1)),
+ $("#is_public_<%= @attachment.id %>").html("<%= escape_javascript(link_to (@attachment.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid=>@attachment.id,:newtype=>(@attachment.is_public? ? 0:1)),
:remote=>true,:class=>"postOptionLink",:method => :post) %>");
<% end %>
<% if @attachment.is_public? %>
$("#image_private_<%= @attachment.id%>").html('')
<%else%>
-$("#image_private_<%= @attachment.id%>").html('私有')
+ $("#image_private_<%= @attachment.id%>").html('私有')
<% 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 b5a15bc1f..d3cc58c71 100644
--- a/app/views/files/_course_file.html.erb
+++ b/app/views/files/_course_file.html.erb
@@ -1,9 +1,9 @@