diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 1ca3e2fcf..29350f0f7 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -23,7 +23,7 @@ class FilesController < ApplicationController before_filter :auth_login1, :only => [:index] before_filter :logged_user_by_apptoken,:only => [:index] before_filter :find_project_by_project_id#, :except => [:getattachtype] - before_filter :authorize, :except => [:getattachtype,:quote_resource_show,:search,:search_project,:quote_resource_show_project] + before_filter :authorize, :except => [:getattachtype,:quote_resource_show,:search,:search_project,:quote_resource_show_project,:search_tag_attachment] helper :sort include SortHelper @@ -51,6 +51,7 @@ class FilesController < ApplicationController @sort = "" @order = "" @is_remote = true + @q = params[:name].strip if params[:sort] order_by = params[:sort].split(":") @sort = order_by[0] @@ -60,19 +61,26 @@ class FilesController < ApplicationController 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] - @result = find_public_attache q,sort - @result = visable_attachemnts_insite @result,@course - @searched_attach = paginateHelper @result,10 + if q == "%%" + @result = [] + @searched_attach = paginateHelper @result,10 + else + @result = find_public_attache q,sort + @result = visable_attachemnts_insite @result,@course + @searched_attach = paginateHelper @result,10 + end else @result = find_course_attache q,@course,sort @result = visable_attachemnts @result @searched_attach = paginateHelper @result,10 + @tag_list = attachment_tag_list @result end - #rescue Exception => e # #render 'stores' # redirect_to search_course_files_url @@ -273,6 +281,8 @@ class FilesController < ApplicationController show_attachments @containers + @tag_list = attachment_tag_list @all_attachments + render :layout => 'base_courses' end @@ -346,6 +356,27 @@ class FilesController < ApplicationController Mailer.run.attachments_added(attachments[:files]) end + if params[:course_attachment_type] && params[:course_attachment_type] != "5" + case params[:course_attachment_type] + when "1" + tag_name = l(:label_courseware) + when "2" + tag_name = l(:label_software) + when "3" + tag_name = l(:label_media) + when "4" + tag_name = l(:label_code) + else + tag_name = "" + end + if !attachments.empty? && attachments[:files] && tag_name != "" + attachments[:files].each do |attachment| + attachment.tag_list.add(tag_name) + attachment.save + end + end + end + # TODO: 临时用 nyan sort_init 'created_on', 'desc' sort_update 'created_on' => "#{Attachment.table_name}.created_on", @@ -489,8 +520,31 @@ class FilesController < ApplicationController format.html end end + end + #查找指定TAG的按条件过滤的资源列表 + def search_tag_attachment + @q,@tag_name,@order = params[:q],params[:tag_name] + @is_remote = true + 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}" + end + q = "%#{@q.strip}%" + @result = find_course_attache q,@course,sort + @result = visable_attachemnts @result + @result = @result.select{|attachment| attachment.tag_list.include?(@tag_name)} + @searched_attach = paginateHelper @result,10 + @tag_list = attachment_tag_list @result + respond_to do |format| + format.js + # format.html + end end end diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb index 3c8ed63d4..0be59c0da 100644 --- a/app/helpers/files_helper.rb +++ b/app/helpers/files_helper.rb @@ -120,6 +120,20 @@ module FilesHelper result end + def attachment_tag_list attachments + tag_list = Hash.new + attachments.each do |attachment| + attachment.tag_list.map{|tag| tag_list.has_key?(tag) ? tag_list[tag] = tag_list[tag] + 1 : tag_list[tag] = 1} + end + tag_list.sort {|a,b| b[1]<=>a[1]} + end + + def get_attachments_by_tag attachments,tag + attachments.each do |attachment| + attachment.tag_list.include?(tag) + end + end + def visable_attachemnts_insite attachments,obj result = [] if obj.is_a?(Course) diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 577cd280f..a7e337a60 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -70,7 +70,7 @@

下载文件包太大,分成多个下载包

diff --git a/app/views/bids/_new_homework_form.html.erb b/app/views/bids/_new_homework_form.html.erb index 129bcec5e..aeb9a5c41 100644 --- a/app/views/bids/_new_homework_form.html.erb +++ b/app/views/bids/_new_homework_form.html.erb @@ -44,7 +44,7 @@
  • - <%= l(:button_create)%> + <%= l(:button_create)%> <%= link_to l(:button_cancel), homework_course_path(@course), :class => "blue_btn grey_btn fl c_white"%>
  • diff --git a/app/views/courses/_course_teacher.html.erb b/app/views/courses/_course_teacher.html.erb index 89a3eea7e..587d9d2da 100644 --- a/app/views/courses/_course_teacher.html.erb +++ b/app/views/courses/_course_teacher.html.erb @@ -1,6 +1,6 @@
    - 加入时间 + 加入时间
    <% members.each do |member| %> diff --git a/app/views/courses/_member_list.html.erb b/app/views/courses/_member_list.html.erb index 60c10dff6..a773b6147 100644 --- a/app/views/courses/_member_list.html.erb +++ b/app/views/courses/_member_list.html.erb @@ -26,9 +26,9 @@
  • <%= link_to '作业积分', member_score_sort_course_path(:sort_by => (@score_sort_by == "desc" ? "asc" : "desc"), :group_id => (@group ? @group.id : 0),:search_name => (@search_name ? @search_name : nil)) ,:result => members,method: 'get', remote: true%> <% if @score_sort_by == 'desc' %> - + <% else %> - + <% end %>
  • diff --git a/app/views/courses/_member_list_detail.html.erb b/app/views/courses/_member_list_detail.html.erb index bc6cbd242..1067f709d 100644 --- a/app/views/courses/_member_list_detail.html.erb +++ b/app/views/courses/_member_list_detail.html.erb @@ -4,7 +4,7 @@
    <% next if member.new_record? %> - <%= member.user.nil? ? '' : (image_tag(url_to_avatar(member.user), :width => 40, :height => 40)) %> + <%= member.user.nil? ? '' : (image_tag(url_to_avatar(member.user), :width => 40, :height => 40)) %>
      <% if @canShowCode %> <% if member.user.show_name == '' && member.user.user_extensions.student_id == '' %> diff --git a/app/views/courses/_new_member_list.html.erb b/app/views/courses/_new_member_list.html.erb index e7d282256..30b77ee50 100644 --- a/app/views/courses/_new_member_list.html.erb +++ b/app/views/courses/_new_member_list.html.erb @@ -32,7 +32,7 @@ <% end %> -
    • 加入时间
    • +
    • 加入时间
    diff --git a/app/views/files/_course_file.html.erb b/app/views/files/_course_file.html.erb index 44dd50c5e..7b2acd875 100644 --- a/app/views/files/_course_file.html.erb +++ b/app/views/files/_course_file.html.erb @@ -1,7 +1,23 @@
    @@ -44,7 +59,15 @@ <%= submit_tag "全站搜索", :class => "re_schbtn b_lblue",:name => "insite",:id => "insite",:onmouseover => "presscss('insite')",:onmouseout =>"buttoncss()" %> <% end %> <% if is_course_teacher(User.current,@course) %> - 上传资源 + +

    + 上传: + 课件 |  + 软件 |  + 媒体 |  + 代码 |  + 其他 +

    <% end %>
    diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb index 3946b1da1..5bbb8757d 100644 --- a/app/views/files/_course_list.html.erb +++ b/app/views/files/_course_list.html.erb @@ -14,6 +14,16 @@

    + +
    + <% unless @tag_list.nil?%> + <% @tag_list.each do |k,v|%> + <%= k%>(<%= v%> + <% end%> + <% end%> +
    +
    +
    <% curse_attachments.each do |file| %> <% if file.is_public? || User.current.member_of_course?(course) %> diff --git a/app/views/files/_upload_show.html.erb b/app/views/files/_upload_show.html.erb index 959fcb7bf..e11a4bf38 100644 --- a/app/views/files/_upload_show.html.erb +++ b/app/views/files/_upload_show.html.erb @@ -7,7 +7,7 @@ <%= form_tag(course_files_path(course), :multipart => true,:remote => !ie8?,:name=>"upload_form") do %> - + <%= render :partial => 'attachement_list',:locals => {:course => course} %>
    <%= l(:button_cancel)%> diff --git a/app/views/files/search_tag_attachment.js.erb b/app/views/files/search_tag_attachment.js.erb new file mode 100644 index 000000000..50f46d2f5 --- /dev/null +++ b/app/views/files/search_tag_attachment.js.erb @@ -0,0 +1 @@ +$("#course_list").html("<%= escape_javascript(render :partial => 'course_list',:locals => {course: @course,all_attachments: @result,sort:@sort,order:@order,curse_attachments:@searched_attach})%>"); \ No newline at end of file diff --git a/app/views/files/upload_file_show.js.erb b/app/views/files/upload_file_show.js.erb index 72fed67a9..71f8f831e 100644 --- a/app/views/files/upload_file_show.js.erb +++ b/app/views/files/upload_file_show.js.erb @@ -1,10 +1,10 @@ -$('#ajax-modal').html('<%= escape_javascript(render :partial => 'upload_show',:locals => {}) %>'); -showModal('ajax-modal', '513px'); -$('#ajax-modal').css('height','569px'); -$('#ajax-modal').siblings().remove(); -//$('#ajax-modal').before("" + -// ""); -$('#ajax-modal').parent().css("top","").css("left",""); -$('#ajax-modal').parent().addClass("alert_box"); \ No newline at end of file +//$('#ajax-modal').html('<%#= escape_javascript(render :partial => 'upload_show',:locals => {}) %>'); +//showModal('ajax-modal', '513px'); +//$('#ajax-modal').css('height','569px'); +//$('#ajax-modal').siblings().remove(); +////$('#ajax-modal').before("" + +//// ""); +//$('#ajax-modal').parent().css("top","").css("left",""); +//$('#ajax-modal').parent().addClass("alert_box"); \ No newline at end of file diff --git a/app/views/homework_attach/_history.erb b/app/views/homework_attach/_history.erb index 686cdffd2..e99160f22 100644 --- a/app/views/homework_attach/_history.erb +++ b/app/views/homework_attach/_history.erb @@ -5,7 +5,7 @@ <% if journals.size > 0 %> <% for journal in journals %>
    - +
    diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index f277cbaa6..dec4a5f4d 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -49,7 +49,7 @@