From 8cbc4eb938bb6173d1dd6a6d9b823d029a0cb835 Mon Sep 17 00:00:00 2001 From: z9hang Date: Tue, 28 Oct 2014 14:26:21 +0800 Subject: [PATCH 1/4] =?UTF-8?q?#1318=20=E8=AF=BE=E7=A8=8B/=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=EF=BC=8C=E7=82=B9=E5=87=BB=E6=89=93=E5=BC=80=E8=AF=A5?= =?UTF-8?q?=E6=A0=87=E7=AD=BE=EF=BC=8C=E4=B8=8D=E6=98=BE=E7=A4=BA=E5=AF=B9?= =?UTF-8?q?=E5=BA=94=E7=9A=84=E8=AF=BE=E7=A8=8B/=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=90=8D=E7=A7=B0,=E5=8E=9F=E5=AE=9E=E7=8E=B0=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=B8=8E=E7=8E=B0=E5=AD=98=E7=9A=84=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=9C=89=E5=86=B2=E7=AA=81=EF=BC=8C=E6=89=A9=E5=B1=95=E4=BA=86?= =?UTF-8?q?=E5=85=B6=E5=AE=9E=E7=8E=B0=E6=96=B9=E5=BC=8F=EF=BC=8C=E4=BD=BF?= =?UTF-8?q?=E4=B9=8B=E5=85=BC=E5=AE=B9=E7=8E=B0=E6=9C=89=E7=9A=84=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/tags_controller.rb | 70 +++++++++++++++------- app/helpers/attachments_helper.rb | 4 +- app/helpers/bids_helper.rb | 4 +- app/helpers/contests_helper.rb | 4 +- app/helpers/courses_helper.rb | 4 +- app/helpers/forums_helper.rb | 4 +- app/helpers/issues_helper.rb | 4 +- app/helpers/open_source_projects_helper.rb | 4 +- app/helpers/projects_helper.rb | 4 +- app/helpers/users_helper.rb | 4 +- app/views/projects/search.html.erb | 4 +- app/views/tags/_related_tags.html.erb | 6 +- app/views/tags/_selected_tags.html.erb | 6 +- app/views/tags/_sidebar_tags.html.erb | 12 ++-- app/views/tags/_tag_name.html.erb | 2 +- app/views/tags/index.html.erb | 6 +- 16 files changed, 83 insertions(+), 59 deletions(-) diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 1318e40a5..0a6f15020 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -38,24 +38,41 @@ class TagsController < ApplicationController @obj_id = params[:obj_id] @obj_flag = params[:object_flag] - @selected_tags = Array.new + @selected_tags = Array.new + @selected_tag_ids = Array.new + @selected_tag_objs = Array.new @related_tags = nil - - if params[:q] - @selected_tags << params[:q] + @related_tag_ids = Array.new + @related_tag_objs = Array.new + if params[:q] + @tag = ActsAsTaggableOn::Tag.find(params[:q]) + @selected_tags << @tag.name + @selected_tag_ids << @tag.id.to_s + @selected_tag_objs << @tag else @do_what = params[:do_what] - @tag = params[:tag] - @selected_tags = params[:current_selected_tags] - @selected_tags = @selected_tags.nil? ? Array.new : @selected_tags + @tag = ActsAsTaggableOn::Tag.find(params[:tag]) + #@selected_tags = params[:current_selected_tags] + @selected_tag_ids = params[:current_selected_tags] + @selected_tag_ids = @selected_tag_ids.nil? ? Array.new : @selected_tag_ids + @selected_tag_ids.each do |t| + ta = ActsAsTaggableOn::Tag.find(t) + @selected_tags << ta.name + @selected_tag_objs << ta + end + #@selected_tags = @selected_tags.nil? ? Array.new : @selected_tags case @do_what when '0' then - @selected_tags.delete @tag #数组中删除有多方式 可以改用shift,pop + @selected_tags.delete @tag.name #数组中删除有多方式 可以改用shift,pop + @selected_tag_ids.delete @tag.id.to_s + @selected_tag_objs.delete @tag when '1' then # 判断是否已存在该tag 主要用来处理分页的情况 - unless @selected_tags.include? @tag - @selected_tags << @tag + unless @selected_tags.include? @tag.name + @selected_tags << @tag.name + @selected_tag_ids << @tag.id.to_s + @selected_tag_objs << @tag end end end @@ -75,7 +92,7 @@ class TagsController < ApplicationController @attachments_results, @contests_results, @courses_results, - @open_source_projects_results= refresh_results(@obj_id,@obj_flag,@selected_tags) + @open_source_projects_results= refresh_results(@obj_id,@obj_flag,@selected_tags,@selected_tag_ids) # 这里是做tag推荐用的, 用来生产推荐的tags unless @obj.nil? @@ -85,6 +102,13 @@ class TagsController < ApplicationController # @tags.delete(i) # end @related_tags = @tags + @tag_objs = @obj.tags + @tag_objs.each do |t| + unless @selected_tags.include?(t.name) + @related_tag_ids << t.id.to_s + @related_tag_objs << t + end + end else return end @@ -162,8 +186,8 @@ class TagsController < ApplicationController if request.get? # 获取传过来的tag_id taggable_id 和 taggable_type,通过2者确定要删除tag的对象 - @tag_name = params[:tag_name] - @tag_id = (ActsAsTaggableOn::Tag.find_by_name(@tag_name)).id + @tag_id = params[:tag_name] + @tag_name = (ActsAsTaggableOn::Tag.find(@tag_id)).name @taggable_id = params[:taggable_id] # 当做参数传时对象会变成字符串 @taggable_type = numbers_to_object_type(params[:taggable_type]) @@ -192,7 +216,7 @@ class TagsController < ApplicationController private # 这里用来刷新搜索结果的区域 # 函数的返回值 前2字段用来处理获取其他tag和分页 ,另外4个返回值为过滤结果 - def refresh_results(obj_id,obj_flag,selected_tags) + def refresh_results(obj_id,obj_flag,selected_tags,selected_tag_ids = nil) @users_results = nil @projects_results = nil @issues_results = nil @@ -210,36 +234,36 @@ class TagsController < ApplicationController case obj_flag when '1' then @obj = User.find_by_id(obj_id) - @obj_pages,@users_results,@results_count = for_pagination(get_users_by_tag(selected_tags)) + @obj_pages,@users_results,@results_count = for_pagination(get_users_by_tag(selected_tags,selected_tag_ids)) when '2' then @obj = Project.find_by_id(obj_id) - @obj_pages,@projects_results,@results_count = for_pagination(get_projects_by_tag(selected_tags)) + @obj_pages,@projects_results,@results_count = for_pagination(get_projects_by_tag(selected_tags,selected_tag_ids)) when '3' then @obj = Issue.find_by_id(obj_id) - @obj_pages,@issues_results,@results_count = for_pagination(get_issues_by_tag(selected_tags)) + @obj_pages,@issues_results,@results_count = for_pagination(get_issues_by_tag(selected_tags,selected_tag_ids)) when '4' then - @obj_pages,@bids_results,@results_count = for_pagination(get_bids_by_tag(selected_tags)) + @obj_pages,@bids_results,@results_count = for_pagination(get_bids_by_tag(selected_tags,selected_tag_ids)) @obj = Bid.find_by_id(obj_id) when '5' @obj = Forum.find_by_id(obj_id) - @obj_pages,@forums_results,@results_count = for_pagination(get_forums_by_tag(selected_tags)) + @obj_pages,@forums_results,@results_count = for_pagination(get_forums_by_tag(selected_tags,selected_tag_ids)) when '6' @obj = Attachment.find_by_id(obj_id) # modifed by Long Jun # this is used to find the attachments that came from the same project and tagged with the same tag. #@result = get_attachments_by_project_tag(selected_tags, @obj) - @result = get_attachments_by_tag(selected_tags) + @result = get_attachments_by_tag(selected_tags,selected_tag_ids) @obj_pages, @attachments_results, @results_count = for_pagination(@result) when '7' @obj = Contest.find_by_id(obj_id) - @obj_pages,@contests_results,@results_count = for_pagination(get_contests_by_tag(selected_tags)) + @obj_pages,@contests_results,@results_count = for_pagination(get_contests_by_tag(selected_tags,selected_tag_ids)) when '8' @obj = OpenSourceProject.find_by_id(obj_id) - @obj_pages, @open_source_projects_results, @results_count = for_pagination(get_open_source_projects_by_tag(selected_tags)) + @obj_pages, @open_source_projects_results, @results_count = for_pagination(get_open_source_projects_by_tag(selected_tags,selected_tag_ids)) when '9' then @obj = Course.find_by_id(obj_id) - @obj_pages, @courses_results, @results_count = for_pagination(get_courses_by_tag(selected_tags)) + @obj_pages, @courses_results, @results_count = for_pagination(get_courses_by_tag(selected_tags,selected_tag_ids)) else @obj = nil end diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb index 7ea49dad2..70a2e40e7 100644 --- a/app/helpers/attachments_helper.rb +++ b/app/helpers/attachments_helper.rb @@ -75,8 +75,8 @@ module AttachmentsHelper # this method is used to get all projects that tagged one tag # added by william - def get_attachments_by_tag(tag_name) - Attachment.tagged_with(tag_name).order('created_on desc') + def get_attachments_by_tag(tag_name,selected_tag_ids = nil) + Attachment.tagged_with(tag_name,{},selected_tag_ids).order('created_on desc') end # this method is used to get all attachments that from one project and tagged one tag diff --git a/app/helpers/bids_helper.rb b/app/helpers/bids_helper.rb index a5c25ecb5..118e0ccb1 100644 --- a/app/helpers/bids_helper.rb +++ b/app/helpers/bids_helper.rb @@ -35,8 +35,8 @@ module BidsHelper # this method is used to get all projects that tagged one tag # added by william - def get_bids_by_tag(tag_name) - Bid.tagged_with(tag_name).order('updated_on desc') + def get_bids_by_tag(tag_name,selected_tag_ids = nil) + Bid.tagged_with(tag_name,{},selected_tag_ids).order('updated_on desc') end #added by huang diff --git a/app/helpers/contests_helper.rb b/app/helpers/contests_helper.rb index 0bc3e5e73..983cf68bd 100644 --- a/app/helpers/contests_helper.rb +++ b/app/helpers/contests_helper.rb @@ -35,8 +35,8 @@ module ContestsHelper # this method is used to get all projects that tagged one tag # added by william - def get_contests_by_tag(tag_name) - Contest.tagged_with(tag_name).order('updated_on desc') + def get_contests_by_tag(tag_name,selected_tag_ids = nil) + Contest.tagged_with(tag_name,{},selected_tag_ids).order('updated_on desc') end #added by huang diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 1afb94220..77445532b 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -449,8 +449,8 @@ module CoursesHelper return homework_users end - def get_courses_by_tag(tag_name) - Course.tagged_with(tag_name).order('updated_at desc') + def get_courses_by_tag(tag_name,selected_tag_ids = nil) + Course.tagged_with(tag_name,{},selected_tag_ids).order('updated_at desc') end #课程实践年份下拉框 diff --git a/app/helpers/forums_helper.rb b/app/helpers/forums_helper.rb index 47a059e04..2d7b4bbb8 100644 --- a/app/helpers/forums_helper.rb +++ b/app/helpers/forums_helper.rb @@ -22,7 +22,7 @@ module ForumsHelper # this method is used to get all projects that tagged one tag # added by william - def get_forums_by_tag(tag_name) - Forum.tagged_with(tag_name).order('updated_at desc') + def get_forums_by_tag(tag_name,selected_tag_ids = nil) + Forum.tagged_with(tag_name,{},selected_tag_ids).order('updated_at desc') end end diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 637c92db3..b5f49331f 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -382,8 +382,8 @@ module IssuesHelper # this method is used to get all projects that tagged one tag # added by william - def get_issues_by_tag(tag_name) - Issue.tagged_with(tag_name).order('updated_on desc') + def get_issues_by_tag(tag_name,selected_tag_ids = nil) + Issue.tagged_with(tag_name,{},selected_tag_ids).order('updated_on desc') end end diff --git a/app/helpers/open_source_projects_helper.rb b/app/helpers/open_source_projects_helper.rb index dfc7cc8d0..8f7d31e05 100644 --- a/app/helpers/open_source_projects_helper.rb +++ b/app/helpers/open_source_projects_helper.rb @@ -31,8 +31,8 @@ module OpenSourceProjectsHelper s = content_tag('div', s, :class => 'user_tags') end - def get_open_source_projects_by_tag(tag_name) - OpenSourceProject.tagged_with(tag_name).order('created_at desc') + def get_open_source_projects_by_tag(tag_name,selected_tag_ids = nil) + OpenSourceProject.tagged_with(tag_name,{},selected_tag_ids).order('created_at desc') end def show_origin(url) diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 5df3644ad..3beed444d 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -232,8 +232,8 @@ module ProjectsHelper # this method is used to get all projects that tagged one tag # added by william - def get_projects_by_tag(tag_name) - Project.tagged_with(tag_name).order('updated_on desc') + def get_projects_by_tag(tag_name,selected_tag_ids = nil) + Project.tagged_with(tag_name,{},selected_tag_ids).order('updated_on desc') end # added by fq diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 58935dd11..ac3d5ad57 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -57,8 +57,8 @@ module UsersHelper # this method is used to get all projects that tagged one tag # added by william - def get_users_by_tag(tag_name) - User.tagged_with(tag_name).order('updated_on desc') + def get_users_by_tag(tag_name,selected_tag_ids = nil) + User.tagged_with(tag_name,{},selected_tag_ids).order('updated_on desc') end # added by fq diff --git a/app/views/projects/search.html.erb b/app/views/projects/search.html.erb index 02bdb4f17..8e810b087 100644 --- a/app/views/projects/search.html.erb +++ b/app/views/projects/search.html.erb @@ -8,7 +8,7 @@ <% if params[:project_type] == "1" %> - +
<%= l(:label_course_practice) %><%= l(:label_course_practice) %> <%= l(:label_user_location) %> : <% if User.current.logged?%> @@ -33,7 +33,7 @@ <% else %> - +
<%= l(:label_project_deposit) %><%= l(:label_project_deposit) %> <%= l(:label_user_location) %> : <% if User.current.logged? %> diff --git a/app/views/tags/_related_tags.html.erb b/app/views/tags/_related_tags.html.erb index 04b356598..17e006da5 100644 --- a/app/views/tags/_related_tags.html.erb +++ b/app/views/tags/_related_tags.html.erb @@ -5,14 +5,14 @@ <% i += 1 %>
  • <%= link_to image_tag("/images/sidebar/add.png"),:action => "index", - :current_selected_tags => selected_tags,:tag => rt,:do_what => "1", + :current_selected_tags => selected_tags,:tag => rt.id,:do_what => "1", :obj_id => obj_id,:object_flag => obj_flag %> - <%= rt %> + <%= rt.name %> <% break if i >= 10 %> - <%= render :partial => 'sidebar_tags',:locals => {:show_flag => obj_flag,:sg => rt }%> + <%= render :partial => 'sidebar_tags',:locals => {:show_flag => obj_flag,:sg => rt,:selected_tag_ids => related_tag_ids }%>
  • <% end %> diff --git a/app/views/tags/_selected_tags.html.erb b/app/views/tags/_selected_tags.html.erb index 3081177bc..851770469 100644 --- a/app/views/tags/_selected_tags.html.erb +++ b/app/views/tags/_selected_tags.html.erb @@ -3,10 +3,10 @@ <% for sg in selected_tags %>
  • <%= link_to image_tag("/images/sidebar/minus.png"),:action => "index", - :current_selected_tags => selected_tags ,:tag => sg,:do_what => "0", + :current_selected_tags => selected_tags ,:tag => sg.id,:do_what => "0", :obj_id => obj_id,:object_flag => obj_flag %> - <%= sg %> - <%= render :partial => 'sidebar_tags',:locals => {:show_flag => obj_flag,:sg => sg }%> + <%= sg.name %> + <%= render :partial => 'sidebar_tags',:locals => {:show_flag => obj_flag,:sg => sg ,:selected_tag_ids => @selected_tag_ids}%>
  • <% end %> diff --git a/app/views/tags/_sidebar_tags.html.erb b/app/views/tags/_sidebar_tags.html.erb index 8db485d1f..cb1b416fc 100644 --- a/app/views/tags/_sidebar_tags.html.erb +++ b/app/views/tags/_sidebar_tags.html.erb @@ -1,14 +1,14 @@ <% case show_flag%> <% when '1' then %> -(<%= User.tagged_with("#{sg}").size %>) +(<%= User.tagged_with("#{sg.name}",{},selected_tag_ids).size %>) <%when '2' then %> -(<%= Project.tagged_with(sg).size %>) +(<%= Project.tagged_with(sg.name,{},selected_tag_ids).size %>) <% when '3' then %> -(<%= Issue.tagged_with("#{sg}").size %>) +(<%= Issue.tagged_with("#{sg.name}",{},selected_tag_ids).size %>) <% when '4' then %> -(<%= Bid.tagged_with("#{sg}").size %>) +(<%= Bid.tagged_with("#{sg.name}",{},selected_tag_ids).size %>) <% when '5' then %> -(<%= Forum.tagged_with("#{sg}").size %>) +(<%= Forum.tagged_with("#{sg.name}",{},selected_tag_ids).size %>) <% when '6' then %> -(<%= Attachment.tagged_with("#{sg}").size %>) +(<%= Attachment.tagged_with("#{sg.name}",{},selected_tag_ids).size %>) <% end %> diff --git a/app/views/tags/_tag_name.html.erb b/app/views/tags/_tag_name.html.erb index 6996e8891..698a3a868 100644 --- a/app/views/tags/_tag_name.html.erb +++ b/app/views/tags/_tag_name.html.erb @@ -8,7 +8,7 @@ // }) -<% @tags = obj.reload.tag_list %> +<% @tags = obj.reload.tags %> <% if non_list_all and (@tags.size > 0) %> diff --git a/app/views/tags/index.html.erb b/app/views/tags/index.html.erb index 47a2ba1d2..18bb2faf9 100644 --- a/app/views/tags/index.html.erb +++ b/app/views/tags/index.html.erb @@ -3,13 +3,13 @@

    <%= l(:label_tags_selected) %>

    <%= render :partial => "selected_tags",:locals => { - :selected_tags => @selected_tags,:obj_flag => @obj_flag,:obj_id => @obj_id }%> + :selected_tags => @selected_tag_objs,:obj_flag => @obj_flag,:obj_id => @obj_id }%>

    <%= l(:label_tags_related) %>

    <% end %> From 887a3cbe460c1b7e2b23a0d8c4f4ca2d10bc0c6a Mon Sep 17 00:00:00 2001 From: z9hang Date: Tue, 28 Oct 2014 14:46:55 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=B8=A4=E4=B8=AA=E8=8B=B1=E6=96=87?= =?UTF-8?q?=E5=9B=BD=E9=99=85=E5=8C=96=E4=B8=A2=E5=A4=B1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/locales/en.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index e7cf73511..e886683f0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1840,4 +1840,6 @@ en: label_my_school: My school label_all_schol: All school label_select_province: Please select the provinces - label_search_conditions_not_null: The search conditions can not be empty \ No newline at end of file + label_search_conditions_not_null: The search conditions can not be empty + lable_school_list: List of schools + button_delete_file: delete \ No newline at end of file From 65a89bb9a541a692fa5193bd44e09c941c716ea8 Mon Sep 17 00:00:00 2001 From: z9hang Date: Tue, 28 Oct 2014 16:27:13 +0800 Subject: [PATCH 3/4] =?UTF-8?q?#1412=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5--?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B--=E5=BD=93=E8=AF=A5=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=8A=A0=E5=85=A5=E5=A4=9A=E4=B8=AA=E8=AF=BE=E7=A8=8B=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E5=BB=BA=E8=AE=AE=E2=80=9C=E5=85=B3=E9=97=AD=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E2=80=9D=E5=AD=97=E6=A0=B7=E5=AF=B9=E9=BD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_course_form.html.erb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/users/_course_form.html.erb b/app/views/users/_course_form.html.erb index 892c2775e..6784faf89 100644 --- a/app/views/users/_course_form.html.erb +++ b/app/views/users/_course_form.html.erb @@ -15,11 +15,12 @@ <% if User.current == @user %> <% (membership.roles).each do |role| %> <% unless (role == Role.find(9) || role == Role.find(3)) %> - <%= join_in_course(membership.course, User.current) %>     + <%= join_in_course(membership.course, User.current) %> <% end %> <% end %> <% else %> <% end %> +      <%= l(:label_x_base_courses_member, :count => membership.course.members.count) %> (<%= "#{membership.course.members.count}" %>)   <%= l(:label_homework) %> From 0723643ca6fd6e142f454977bb3e14e5a12e1431 Mon Sep 17 00:00:00 2001 From: z9hang Date: Tue, 28 Oct 2014 16:49:05 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=20#1410=E6=96=B0=E5=BB=BA=E8=B4=B4?= =?UTF-8?q?=E5=90=A7=EF=BC=9A=E8=BE=93=E5=85=A5=E8=B4=B4=E5=90=A7=E6=8F=8F?= =?UTF-8?q?=E8=BF=B0=E4=B8=BA=E9=9D=9E=E6=B1=89=E5=AD=97=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=EF=BC=8C=E7=BC=96=E8=BE=91=E6=A1=86=E4=B8=8D=E4=BC=9A=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=8D=A2=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/ckeditor/contents.css | 1 + 1 file changed, 1 insertion(+) diff --git a/public/javascripts/ckeditor/contents.css b/public/javascripts/ckeditor/contents.css index 81e76d564..92a1b7ba1 100644 --- a/public/javascripts/ckeditor/contents.css +++ b/public/javascripts/ckeditor/contents.css @@ -22,6 +22,7 @@ body { font-size: 13px; line-height: 1.6em; + word-wrap: break-word; } blockquote