Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
This commit is contained in:
commit
046757fbd3
|
@ -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 = visable_attachemnts @result
|
||||
@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,17 +77,24 @@ class FilesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def find_course_attache keywords,course
|
||||
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("created_on DESC")
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
@ -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}")
|
||||
|
|
|
@ -118,6 +118,9 @@
|
|||
<div class="box tabular">
|
||||
<%#= render :partial => 'homework_form', :locals => { :f => f } %>
|
||||
<%= render :partial => 'homework_form', :locals => { :f => f } %>
|
||||
<input type="button" onclick="submitHomework(<%= @bid.id%>);" value="<%= l(:button_create)%>" class="enterprise">
|
||||
<!--<input type="button" onclick="submitHomework(<%#= @bid.id%>);" value="<%#= l(:button_create)%>" class="enterprise">-->
|
||||
<a href="#" onclick="submitHomework(<%= @bid.id%>);" class="ButtonColor m3p10" >
|
||||
<%= l(:button_create)%>
|
||||
</a>
|
||||
<% end %>
|
||||
</div>
|
|
@ -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} %>
|
||||
<p>
|
||||
<!--<input type="button" onclick="submitCoursesBoard();" class = "ButtonColor m3p10 h30" value="<%= l(:button_submit)%>">-->
|
||||
<!--<input type="button" onclick="submitCoursesBoard();" class = "ButtonColor m3p10 h30" value="<%#= l(:button_submit)%>">-->
|
||||
<a href="#" onclick="submitCoursesBoard();"class="ButtonColor m3p10"><%= l(:button_submit)%></a>
|
||||
<%= link_to l(:button_cancel), "#", :onclick => '$("#add-message").hide(); return false;' ,:class => 'ButtonColor m3p10' %>
|
||||
</p>
|
||||
|
|
|
@ -14,11 +14,13 @@
|
|||
<div style="width: 80%; margin-left:10%;">
|
||||
<%= 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;"%>
|
||||
<!--<%#= submit_tag l(:button_leave_meassge), :name => nil , :class => "enterprise" , :style => "display: block; float: right; margin-right: 1%; margin-top: 1px;"%>-->
|
||||
<a href="#" onclick='$("#leave_meassge").parent().submit();' class="ButtonColor m3p10" style ="display: block; float: right; margin-right: 1%; margin-top: 1px;"> <%= l(:button_leave_meassge)%>
|
||||
</a>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -106,7 +106,8 @@
|
|||
<%= labelled_form_for @homework, :url => {:controller => 'bids', :action => 'create_homework',:course_id => "#{params[:id] || params[:course_id]}"} do |f| %>
|
||||
<div class="box tabular">
|
||||
<%= render :partial => 'homework_form', :locals => { :f => f } %>
|
||||
<input type="button" onclick="submitHomework();" value="<%= l(:button_create)%>" class="enterprise">
|
||||
<!--<input type="button" onclick="submitHomework();" value="<%#= l(:button_create)%>" class="enterprise">-->
|
||||
<a href="#" onclick="submitHomework();"class="ButtonColor m3p10"><%= l(:button_create)%></a>
|
||||
<%= javascript_tag "$('#bid_name').focus();" %>
|
||||
<% end %>
|
||||
</div>
|
|
@ -2,16 +2,15 @@
|
|||
<div class="re_con_top">
|
||||
<p class="f_l c_blue f_b f_14">共有 <%= all_attachments.count%> 个资源</p>
|
||||
<p class="f_r" style="color: #808080">
|
||||
<!--<#% if @order == "asc" %>
|
||||
按 <#%= link_to "时间",course_files_path(course,:sort=>"created_on:desc"),:class => "f_b c_grey" %><#%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"created_on"} %> /
|
||||
<#%= link_to "下载次数",course_files_path(course,:sort=>"downloads:desc"),:class => "f_b c_grey" %><#%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"downloads"} %> /
|
||||
<a href="#" class="f_b c_grey">引用次数</a> 排序
|
||||
<#%else%>
|
||||
按 <#%= link_to "时间",course_files_path(course,:sort=>"created_on:asc"),:class => "f_b c_grey" %><#%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"created_on"} %> /
|
||||
<#%= link_to "下载次数",course_files_path(course,:sort=>"downloads:asc"),:class => "f_b c_grey" %><#%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"downloads"} %> /
|
||||
<a href="#" class="f_b c_grey">引用次数</a> 排序
|
||||
<#% end %>-->
|
||||
资源列表的多样化排序将在下周上线...
|
||||
<% 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"} %> <!-- /
|
||||
<a href="#" class="f_b c_grey">引用次数</a> -->排序
|
||||
<% 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"} %> <!-- /
|
||||
<a href="#" class="f_b c_grey">引用次数</a> -->排序
|
||||
<% end %>
|
||||
</p>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
@ -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" %>
|
||||
<span id="is_public_<%= file.id %>">
|
||||
|
@ -31,7 +30,7 @@
|
|||
<!-- <#%= link_to (file.is_public? ? "公开":"私有"),"javascript:void(0)",:class=>"f_l re_open" %> -->
|
||||
<% 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 %>
|
||||
|
|
|
@ -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})%>");
|
||||
$("#course_list").html("<%= escape_javascript(render :partial => 'course_list',:locals => {course: @course,all_attachments: @result,sort:@sort,order:@order,curse_attachments:@searched_attach})%>");
|
|
@ -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}"
|
||||
|
|
Loading…
Reference in New Issue