From 535ec333c3d7370517aa2c4afff5be9cc2d45f48 Mon Sep 17 00:00:00 2001 From: zhuhao Date: Mon, 24 Nov 2014 15:36:58 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=AD=97=E6=A0=B7?= =?UTF-8?q?=E7=9A=84=E6=94=B9=E5=8A=A8=EF=BC=9A=E9=A1=B9=E7=9B=AE=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E8=AF=BE=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/locales/zh.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 7d6cc85b2..3037c5990 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1169,7 +1169,7 @@ zh: text_wiki_page_nullify_children: 将子页面保留为根页面 text_wiki_page_destroy_children: 删除子页面及其所有下级页面 text_wiki_page_reassign_children: 将子页面的上级页面设置为 - text_own_membership_delete_confirmation: 你正在删除你现有的某些或全部权限,如果这样做了你可能将会再也无法编辑该项目了。你确定要继续吗? + text_own_membership_delete_confirmation: 你正在删除你现有的某些或全部权限,如果这样做了你可能将会再也无法编辑该课程了。你确定要继续吗? text_zoom_in: 放大 text_zoom_out: 缩小 text_applied_project: "用户 %{id} 申请加入项目 %{project}" From 71e7d2c8725ce8ed98f1693e8ea2c70fe417286e Mon Sep 17 00:00:00 2001 From: z9hang Date: Thu, 27 Nov 2014 17:17:33 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=85=A8=E7=AB=99?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E7=BB=93=E6=9E=9C=E6=98=BE=E7=A4=BA=E7=AD=96?= =?UTF-8?q?=E7=95=A5=EF=BC=9A=E7=A7=81=E6=9C=89=E8=B5=84=E6=BA=90=E5=B1=9E?= =?UTF-8?q?=E4=BA=8E=E5=BD=93=E5=89=8D=E8=AF=BE=E7=A8=8B=EF=BC=8C=E4=B8=94?= =?UTF-8?q?=E5=BD=93=E5=89=8D=E7=94=A8=E6=88=B7=E4=B8=BA=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E7=9A=84=E6=88=90=E5=91=98=E6=97=B6=E5=8F=AF?= =?UTF-8?q?=E8=A7=81=EF=BC=8C=E5=85=B6=E4=BB=96=E6=83=85=E5=86=B5=E7=A7=81?= =?UTF-8?q?=E6=9C=89=E8=B5=84=E6=BA=90=E4=B8=8D=E5=8F=AF=E8=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 5 +++-- app/helpers/files_helper.rb | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index aa1c158e0..ac228e0d4 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -51,7 +51,7 @@ class FilesController < ApplicationController #(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank? if params[:insite] @result = find_public_attache q - @result = visable_attachemnts @result + @result = visable_attachemnts_insite @result,@course @searched_attach = paginateHelper @result,10 else @result = find_course_attache q,@course @@ -66,8 +66,9 @@ class FilesController < ApplicationController end def find_course_attache keywords,course - resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' AND filename LIKE :like ", like: "%#{keywords}%"). + resultSet = Attachment.where("(attachments.container_type = 'Course'And attachments.container_id = '#{course.id}') OR (attachments.container_type = 'HomeworkAttach' AND ) AND filename LIKE :like ", like: "%#{keywords}%"). reorder("created_on DESC") + #resultSet = Attachment.find_by_sql("SELECT `attachments`.* FROM `attachments` LEFT OUTER JOIN `homework_attaches` ON `attachments`.container_type = 'HomeworkAttach' AND `attachments`.container_id = `homework_attaches`.id LEFT OUTER JOIN `homework_for_courses` ON `homework_attaches`.bid_id = `homework_for_courses`.bid_id LEFT OUTER JOIN `homework_for_courses` AS H_C ON `attachments`.container_type = 'Bid' AND `attachments`.container_id = H_C.bid_id WHERE (`homework_for_courses`.course_id = 117 OR H_C.course_id = 117 OR (`attachments`.container_type = 'Course' AND `attachments`.container_id = 117)) AND `attachments`.filename LIKE '%#{keywords}%'").reorder("created_on DESC") end def find_public_attache keywords diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb index c3a6a7b3e..253ce34a5 100644 --- a/app/helpers/files_helper.rb +++ b/app/helpers/files_helper.rb @@ -93,6 +93,27 @@ module FilesHelper result end + def visable_attachemnts_incourse attachments + result = [] + attachments.each do |attachment| + if attachment.is_public? || (attachment.author.member_of_course?(Course.find(attachment.container_id)))|| attachment.author_id == User.current.id + result << attachment + end + end + result + end + + def visable_attachemnts_insite attachments,course + result = [] + attachments.each do |attachment| + if attachment.is_public? || (attachment.container_type == "Course" && attachment.container_id == course.id && attachment.author.member_of_course?(Course.find(attachment.container_id)))|| attachment.author_id == User.current.id + result << attachment + end + end + result + end + + def get_qute_number attachment if attachment.copy_from result = Attachment.find_by_sql("select count(*) as number from attachments where copy_from = #{attachment.copy_from}") From 21c1b63c6de5b15df489144c50f18e7f11f0c00a Mon Sep 17 00:00:00 2001 From: zhuhao Date: Thu, 27 Nov 2014 17:34:27 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E5=92=8C=E7=95=99=E8=A8=80=E4=B8=A4=E5=A4=84=E7=9A=84=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E6=8C=89=E9=92=AE=E6=A0=B7=E5=BC=8F=E7=BB=9F=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/_courses_jours.html.erb | 6 ++++-- app/views/courses/new_homework.html.erb | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/views/courses/_courses_jours.html.erb b/app/views/courses/_courses_jours.html.erb index e1efe4f58..68b92c00e 100644 --- a/app/views/courses/_courses_jours.html.erb +++ b/app/views/courses/_courses_jours.html.erb @@ -14,11 +14,13 @@
<%= form_for('new_form', :method => :post, :url => {:controller => 'words', :action => 'leave_course_message'}) do |f|%> - <%= f.text_area 'course_message', :rows => 3, :cols => 65, + <%= f.text_area 'course_message',:id => "leave_meassge", :rows => 3, :cols => 65, :placeholder => "#{l(:label_welcome_my_respond)}", :style => "resize: none; width: 98%", :class => 'noline',:maxlength => 250%> - <%= submit_tag l(:button_leave_meassge), :name => nil , :class => "enterprise" , :style => "display: block; float: right; margin-right: 1%; margin-top: 1px;"%> + + <%= l(:button_leave_meassge)%> + <% end %>
<% end %> diff --git a/app/views/courses/new_homework.html.erb b/app/views/courses/new_homework.html.erb index 7b6784243..e3121c6ad 100644 --- a/app/views/courses/new_homework.html.erb +++ b/app/views/courses/new_homework.html.erb @@ -106,7 +106,8 @@ <%= labelled_form_for @homework, :url => {:controller => 'bids', :action => 'create_homework',:course_id => "#{params[:id] || params[:course_id]}"} do |f| %>
<%= render :partial => 'homework_form', :locals => { :f => f } %> - + + <%= l(:button_create)%> <%= javascript_tag "$('#bid_name').focus();" %> <% end %>
\ No newline at end of file From a33084545f0edd9b177594e4d884f54e1295db76 Mon Sep 17 00:00:00 2001 From: zhuhao Date: Fri, 28 Nov 2014 09:27:43 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=AE=9E=E8=B7=B5?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E6=8C=89=E9=92=AE=E6=A0=B7=E5=BC=8F=E7=BB=9F?= =?UTF-8?q?=E4=B8=80=E7=9A=84=E6=94=B9=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/bids/edit.html.erb | 5 ++++- app/views/boards/_course_show.html.erb | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/views/bids/edit.html.erb b/app/views/bids/edit.html.erb index 0a2d17e7d..17e805fce 100644 --- a/app/views/bids/edit.html.erb +++ b/app/views/bids/edit.html.erb @@ -118,6 +118,9 @@
<%#= render :partial => 'homework_form', :locals => { :f => f } %> <%= render :partial => 'homework_form', :locals => { :f => f } %> - + + + <%= l(:button_create)%> + <% end %>
\ No newline at end of file diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index 7514b48f6..7a7d001ed 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -19,7 +19,7 @@ <%= form_for @message, :url => new_board_message_path(@board), :html => {:multipart => false, :id => 'message-form'} do |f| %> <%= render :partial => 'messages/form', :locals => {:f => f} %>

- + <%= l(:button_submit)%> <%= link_to l(:button_cancel), "#", :onclick => '$("#add-message").hide(); return false;' ,:class => 'ButtonColor m3p10' %>

From 514dcb97a0afedd84e105786374e562e1897002d Mon Sep 17 00:00:00 2001 From: z9hang Date: Fri, 28 Nov 2014 11:33:51 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E5=AE=8C=E6=88=90=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E6=8C=89=E6=97=B6=E9=97=B4=E3=80=81=E4=B8=8B=E8=BD=BD=E6=AC=A1?= =?UTF-8?q?=E6=95=B0=E6=8E=92=E5=BA=8F=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 34 ++++++++++++++++++++------- app/helpers/files_helper.rb | 6 ++--- app/views/files/_course_list.html.erb | 23 +++++++++--------- app/views/files/search.js.erb | 2 +- 4 files changed, 41 insertions(+), 24 deletions(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index ac228e0d4..c20b5a0de 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -45,16 +45,28 @@ class FilesController < ApplicationController end def search + sort = "" + @sort = "" + @order = "" + @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 + begin - @is_remote = true 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 + @result = find_public_attache q,sort @result = visable_attachemnts_insite @result,@course @searched_attach = paginateHelper @result,10 else - @result = find_course_attache q,@course + @result = find_course_attache q,@course,sort @result = visable_attachemnts @result @searched_attach = paginateHelper @result,10 end @@ -65,18 +77,24 @@ class FilesController < ApplicationController end end - def find_course_attache keywords,course - resultSet = Attachment.where("(attachments.container_type = 'Course'And attachments.container_id = '#{course.id}') OR (attachments.container_type = 'HomeworkAttach' AND ) AND filename LIKE :like ", like: "%#{keywords}%"). - reorder("created_on DESC") + def find_course_attache keywords,course,sort = "" + if sort == "" + sort = "created_on DESC" + end + resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' AND filename LIKE :like ", like: "%#{keywords}%"). + reorder(sort) #resultSet = Attachment.find_by_sql("SELECT `attachments`.* FROM `attachments` LEFT OUTER JOIN `homework_attaches` ON `attachments`.container_type = 'HomeworkAttach' AND `attachments`.container_id = `homework_attaches`.id LEFT OUTER JOIN `homework_for_courses` ON `homework_attaches`.bid_id = `homework_for_courses`.bid_id LEFT OUTER JOIN `homework_for_courses` AS H_C ON `attachments`.container_type = 'Bid' AND `attachments`.container_id = H_C.bid_id WHERE (`homework_for_courses`.course_id = 117 OR H_C.course_id = 117 OR (`attachments`.container_type = 'Course' AND `attachments`.container_id = 117)) AND `attachments`.filename LIKE '%#{keywords}%'").reorder("created_on DESC") end - def find_public_attache keywords + def find_public_attache keywords,sort = "" # StoresController#search 将每条文件都查出来,再次进行判断过滤。---> resultSet.to_a.map # 此时内容不多速度还可,但文件增长,每条判断多则进行3-4次表连接。 # 现在还木有思路 药丸 + if sort == "" + sort = "created_on DESC" + end resultSet = Attachment.where("attachments.container_type IS NOT NULL AND filename LIKE :like ", like: "%#{keywords}%"). - reorder("created_on DESC") + reorder(sort) end def index diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb index 253ce34a5..c9a232c36 100644 --- a/app/helpers/files_helper.rb +++ b/app/helpers/files_helper.rb @@ -54,11 +54,11 @@ module FilesHelper s.html_safe end - #判断用户是否拥有课程,需用户在该课程中角色为教师且该课程属于当前学期或下一学期 - def has_course? user + #判断用户是否拥有除current_course以外的课程,需用户在该课程中角色为教师且该课程属于当前学期或下一学期 + def has_course? user,current_course result = false user.courses.each do |course| - if is_course_teacher(User.current,course) && course_in_current_or_next_term(course) + if current_course.id != course.id && is_course_teacher(User.current,course) && course_in_current_or_next_term(course) return true end end diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb index 93e39f73f..02dc816b2 100644 --- a/app/views/files/_course_list.html.erb +++ b/app/views/files/_course_list.html.erb @@ -2,16 +2,15 @@

共有 <%= all_attachments.count%> 个资源

- - 资源列表的多样化排序将在下周上线... + <% if order == "asc" %> + 按 <%= link_to "时间",params.merge(:sort=>"created_on:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"created_on"} %> /  + <%= link_to "下载次数",params.merge(:sort=>"downloads:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"downloads"} %> 排序 + <% else %> + 按 <%= link_to "时间",params.merge(:sort=>"created_on:asc"),:class => "f_b c_grey" ,:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"created_on"} %> /  + <%= link_to "下载次数",params.merge(:sort=>"downloads:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"downloads"} %> 排序 + <% end %>

@@ -21,7 +20,7 @@ <%= link_to_attachment file, :download => true,:text => truncate(file.filename,length: 35, omission: '...'), :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %> <% if User.current.logged? %> <% if is_course_teacher(User.current,@course) && file.author_id == User.current.id %> - <%= link_to("选入我的其他课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true) if has_course?(User.current) %> + <%= link_to("选入我的其他课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true) if has_course?(User.current,@course) %> <% if delete_allowed && file.container_id == @course.id && file.container_type == "Course" %> @@ -31,7 +30,7 @@ <% end %> <% else %> - <%= link_to("选入我的课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true) if has_course?(User.current) %> + <%= link_to("选入我的课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true) if has_course?(User.current,@course) %> <% end %> <% else %> <% end %> diff --git a/app/views/files/search.js.erb b/app/views/files/search.js.erb index 84c9a4707..50f46d2f5 100644 --- a/app/views/files/search.js.erb +++ b/app/views/files/search.js.erb @@ -1 +1 @@ -$("#course_list").html("<%= escape_javascript(render :partial => 'course_list',:locals => {course: @course,all_attachments: @result,sort:"create_on",order:"",curse_attachments:@searched_attach})%>"); \ No newline at end of file +$("#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