Merge branch 'ouyangxuhua' into develop

This commit is contained in:
ouyangxuhua 2016-03-07 16:15:13 +08:00
commit 2ea553e988
7 changed files with 93 additions and 68 deletions

View File

@ -406,10 +406,14 @@ class FilesController < ApplicationController
@container_type = 2 @container_type = 2
@containers = [ OrgSubfield.includes(:attachments).reorder(sort).find(@org_subfield.id)] @containers = [ OrgSubfield.includes(:attachments).reorder(sort).find(@org_subfield.id)]
@organization = Organization.find(@containers.first.organization_id) @organization = Organization.find(@containers.first.organization_id)
show_attachments @containers if @organization.is_public? or User.current.admin? or User.current.member_of_org?(@organization)
@tag_list = attachment_tag_list @all_attachments show_attachments @containers
@page = params[:page] || 1 @tag_list = attachment_tag_list @all_attachments
render :layout => 'base_org' @page = params[:page] || 1
render :layout => 'base_org'
else
render_403
end
# @subfield = params[:org_subfield_id] # @subfield = params[:org_subfield_id]
end end
@ -859,7 +863,15 @@ class FilesController < ApplicationController
q = "%#{@q.strip}%" q = "%#{@q.strip}%"
@result = find_org_subfield_attache q,@org_subfield,sort @result = find_org_subfield_attache q,@org_subfield,sort
@result = visable_attachemnts @result @result = visable_attachemnts @result
@result = @result.select{|attachment| attachment.tag_list.include?(@tag_name)} unless @tag_name.blank? if params[:other]
@result = @result.select{|attachment|
attachment.tag_list.exclude?('软件') &&
attachment.tag_list.exclude?('媒体') &&
attachment.tag_list.exclude?('代码')
}
else
@result = @result.select{|attachment| attachment.tag_list.include?(@tag_name)} unless @tag_name.blank?
end
@searched_attach = paginateHelper @result,10 @searched_attach = paginateHelper @result,10
@tag_list = get_org_subfield_tag_list @org_subfield @tag_list = get_org_subfield_tag_list @org_subfield

View File

@ -33,61 +33,65 @@ class OrgSubfieldsController < ApplicationController
domain = Secdomain.where("subname=?", request.subdomain).first domain = Secdomain.where("subname=?", request.subdomain).first
@organization = Organization.find(domain.pid) @organization = Organization.find(domain.pid)
end end
@org_subfield = OrgSubfield.find_by_sql("select distinct org_subfields.* from org_subfields,"+ if @organization.is_public? or User.current.admin? or User.current.member_of_org?(@organization)
"subfield_subdomain_dirs where org_subfields.id = subfield_subdomain_dirs.org_subfield_id and "+ @org_subfield = OrgSubfield.find_by_sql("select distinct org_subfields.* from org_subfields,"+
" org_subfields.organization_id=#{@organization.id} and subfield_subdomain_dirs.name='#{params[:sub_dir_name]}'").first "subfield_subdomain_dirs where org_subfields.id = subfield_subdomain_dirs.org_subfield_id and "+
if @org_subfield.field_type == 'Post' " org_subfields.organization_id=#{@organization.id} and subfield_subdomain_dirs.name='#{params[:sub_dir_name]}'").first
if @org_subfield.field_type == 'Post'
@org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0 @org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0
@org_activities = OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{@org_subfield.id})").order('updated_at desc').page(params[:page] || 1).per(10) @org_activities = OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{@org_subfield.id})").order('updated_at desc').page(params[:page] || 1).per(10)
#redirect_to organization_path(@organization, :org_subfield_id => @org_subfield.id) #redirect_to organization_path(@organization, :org_subfield_id => @org_subfield.id)
else
if params[:sort]
params[:sort].split(",").each do |sort_type|
order_by = sort_type.split(":")
case order_by[0]
when "filename"
attribute = "filename"
when "size"
attribute = "filesize"
when "attach_type"
attribute = "attachtype"
when "content_type"
attribute = "created_on"
when "field_file_dense"
attribute = "is_public"
when "downloads"
attribute = "downloads"
when "created_on"
attribute = "created_on"
when "quotes"
attribute = "quotes"
else
attribute = "created_on"
end
@sort = order_by[0]
@order = order_by[1]
if order_by.count == 1 && attribute
sort += "#{Attachment.table_name}.#{attribute} asc "
if sort_type != params[:sort].split(",").last
sort += ","
end
elsif order_by.count == 2 && order_by[1]
sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} "
if sort_type != params[:sort].split(",").last
sort += ","
end
end
end
else else
sort = "#{Attachment.table_name}.created_on desc" if params[:sort]
params[:sort].split(",").each do |sort_type|
order_by = sort_type.split(":")
case order_by[0]
when "filename"
attribute = "filename"
when "size"
attribute = "filesize"
when "attach_type"
attribute = "attachtype"
when "content_type"
attribute = "created_on"
when "field_file_dense"
attribute = "is_public"
when "downloads"
attribute = "downloads"
when "created_on"
attribute = "created_on"
when "quotes"
attribute = "quotes"
else
attribute = "created_on"
end
@sort = order_by[0]
@order = order_by[1]
if order_by.count == 1 && attribute
sort += "#{Attachment.table_name}.#{attribute} asc "
if sort_type != params[:sort].split(",").last
sort += ","
end
elsif order_by.count == 2 && order_by[1]
sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} "
if sort_type != params[:sort].split(",").last
sort += ","
end
end
end
else
sort = "#{Attachment.table_name}.created_on desc"
end
@container_type = 2
@containers = [OrgSubfield.includes(:attachments).reorder(sort).find(@org_subfield.id)]
@organization = Organization.find(@containers.first.organization_id)
show_attachments @containers
@tag_list = attachment_tag_list @all_attachments
end end
@container_type = 2 @page = params[:page] || 1
@containers = [ OrgSubfield.includes(:attachments).reorder(sort).find(@org_subfield.id)] else
@organization = Organization.find(@containers.first.organization_id) render_403
show_attachments @containers
@tag_list = attachment_tag_list @all_attachments
end end
@page = params[:page] || 1
#render :layout => 'base_org' #render :layout => 'base_org'
end end

View File

@ -1693,17 +1693,17 @@ class UsersController < ApplicationController
@flag = true @flag = true
if params[:send_id].present? if params[:send_id].present?
send_id = params[:send_id] send_id = params[:send_id]
ori = Attachment.find_by_id(send_id) @ori = Attachment.find_by_id(send_id)
course_ids = params[:course_ids] course_ids = params[:course_ids]
if course_ids.nil? if course_ids.nil?
@flag = false @flag = false
end end
unless course_ids.nil? unless course_ids.nil?
course_ids.each do |id| course_ids.each do |id|
next if ori.blank? next if @ori.blank?
@exist = false @exist = false
Course.find(id).attachments.each do |att| #如果课程中包含该资源 Course.find(id).attachments.each do |att| #如果课程中包含该资源
if att.id == ori.id || (!att.copy_from.nil? && !ori.copy_from.nil? && att.copy_from == ori.copy_from) || att.copy_from == ori.id || att.id == ori.copy_from if att.id == @ori.id || (!att.copy_from.nil? && !@ori.copy_from.nil? && att.copy_from == @ori.copy_from) || att.copy_from == @ori.id || att.id == @ori.copy_from
att.created_on = Time.now att.created_on = Time.now
att.save att.save
@exist = true @exist = true
@ -1711,21 +1711,21 @@ class UsersController < ApplicationController
end end
end end
next if @exist next if @exist
attach_copied_obj = ori.copy attach_copied_obj = @ori.copy
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联 attach_copied_obj.tag_list.add(@ori.tag_list) # tag关联
attach_copied_obj.container = Course.find(id) attach_copied_obj.container = Course.find(id)
attach_copied_obj.created_on = Time.now attach_copied_obj.created_on = Time.now
attach_copied_obj.author_id = User.current.id attach_copied_obj.author_id = User.current.id
attach_copied_obj.is_public = 0 attach_copied_obj.is_public = 0
attach_copied_obj.copy_from = ori.copy_from.nil? ? ori.id : ori.copy_from #发送要添加copy_from attach_copied_obj.copy_from = @ori.copy_from.nil? ? @ori.id : @ori.copy_from #发送要添加copy_from
if attach_copied_obj.attachtype == nil if attach_copied_obj.attachtype == nil
attach_copied_obj.attachtype = 4 attach_copied_obj.attachtype = 4
end end
if attach_copied_obj.save if attach_copied_obj.save
# 更新引用次数 # 更新引用次数
quotes = ori.quotes.to_i + 1 quotes = @ori.quotes.to_i + 1
ori.update_attribute(:quotes, quotes) unless ori.nil? @ori.update_attribute(:quotes, quotes) unless @ori.nil?
ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now) @ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now)
end end
@save_message = attach_copied_obj.errors.full_messages @save_message = attach_copied_obj.errors.full_messages
end end
@ -1837,6 +1837,7 @@ class UsersController < ApplicationController
Project.find(project_id).project_score.attach_num + 1) Project.find(project_id).project_score.attach_num + 1)
end end
end end
@ori = ori
end end
elsif params[:send_ids].present? elsif params[:send_ids].present?
send_ids = params[:send_ids].split(" ") send_ids = params[:send_ids].split(" ")
@ -1941,6 +1942,7 @@ class UsersController < ApplicationController
end end
end end
end end
@ori = ori
elsif params[:send_ids].present? elsif params[:send_ids].present?
send_ids = params[:send_ids].split(" ") send_ids = params[:send_ids].split(" ")
subfield_id = params[:subfield] subfield_id = params[:subfield]

View File

@ -8,7 +8,7 @@
</div> </div>
<div class="homepagePostDes"> <div class="homepagePostDes">
<div class="homepagePostTitle break_word mt-4"> <div class="homepagePostTitle break_word mt-4">
<%= link_to truncate(file.filename,length: 35, omission: '...'), <%= link_to file.is_public? ? truncate(file.filename, length: 70) : truncate(file.filename,length: 50, omission: '...'),
download_named_attachment_path(file.id, file.filename), download_named_attachment_path(file.id, file.filename),
:title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14 f_l" %> :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14 f_l" %>
<%= file_preview_eye(file, class: 'preview') %> <%= file_preview_eye(file, class: 'preview') %>
@ -25,7 +25,7 @@
<span class="fontGrey2 fl mr15">上传类型:<%= file.tag_list[0] %></span> <span class="fontGrey2 fl mr15">上传类型:<%= file.tag_list[0] %></span>
<% end %> <% end %>
<p class="f_l mb5 fontGrey2">文件大小:<%= number_to_human_size(file.filesize) %></p> <p class="f_l mb5 fontGrey2">文件大小:<%= number_to_human_size(file.filesize) %></p>
<p class="fl ml15 fontGrey2">下载<%= file.downloads%>&nbsp;&nbsp;|&nbsp;&nbsp;引用<%= file.quotes.nil? ? 0:file.quotes %> </p> <p class="fl ml15 fontGrey2">下载<%= file.downloads%>&nbsp;&nbsp;|&nbsp;&nbsp;引用<span id="reference_number_<%= file.id %>"><%= file.quotes.nil? ? 0:file.quotes %></span></p>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<div class="tag_h"> <div class="tag_h">

View File

@ -4,7 +4,8 @@ $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_
$("#res_count").html(0); $("#res_count").html(0);
$("#checkboxAll").attr('checked',false); $("#checkboxAll").attr('checked',false);
$("#res_all_count").html(<%= @atta_count%>); $("#res_all_count").html(<%= @atta_count%>);
$("#reference_number_<%= @ori.id %>").text("<%= @ori.quotes %>");
hideModal(); hideModal();
alert("发送成功") alert("发送成功");
<% else%> <% else%>
<% end %> <% end %>

View File

@ -4,7 +4,10 @@ $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_
$("#res_count").html(0); $("#res_count").html(0);
$("#checkboxAll").attr('checked',false); $("#checkboxAll").attr('checked',false);
$("#res_all_count").html(<%= @atta_count%>); $("#res_all_count").html(<%= @atta_count%>);
<% if @ori.present? and @ori.quotes.present? %>
$("#reference_number_<%= @ori.id %>").text("<%= @ori.quotes %>");
<% end %>
hideModal(); hideModal();
alert("发送成功") alert("发送成功");
<% else%> <% else%>
<% end %> <% end %>

View File

@ -4,7 +4,10 @@ $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_
$("#res_count").html(0); $("#res_count").html(0);
$("#checkboxAll").attr('checked',false); $("#checkboxAll").attr('checked',false);
$("#res_all_count").html(<%= @atta_count%>); $("#res_all_count").html(<%= @atta_count%>);
<% if @ori and @ori.quotes.present? %>
$("#reference_number_<%= @ori.id %>").text("<%= @ori.quotes %>");
<% end %>
hideModal(); hideModal();
alert("发送成功") alert("发送成功");
<% else%> <% else%>
<% end %> <% end %>