|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
class OrgSubfieldsController < ApplicationController
|
|
|
|
|
layout 'base_org'
|
|
|
|
|
def create
|
|
|
|
|
if OrgSubfield.where("organization_id=#{params[:organization_id]} and name=?",params[:name]).count == 0
|
|
|
|
|
@res = true
|
|
|
|
@ -20,13 +21,12 @@ class OrgSubfieldsController < ApplicationController
|
|
|
|
|
|
|
|
|
|
def show
|
|
|
|
|
@organization = Organization.find(params[:id])
|
|
|
|
|
@subfield = @organization.org_subfields.first
|
|
|
|
|
if @subfield.field_type == 'Post'
|
|
|
|
|
redirect_to organization_path(@organization, :org_subfield_id => @subfield.id)
|
|
|
|
|
end
|
|
|
|
|
@org_subfield = OrgSubfield.find_by_sql("select distinct org_subfields.* from org_subfields,"+
|
|
|
|
|
"subfield_subdomain_dirs where org_subfields.id = subfield_subdomain_dirs.org_subfield_id and "+
|
|
|
|
|
" org_subfields.organization_id=#{@organization.id} and subfield_subdomain_dirs.name=#{params[:name]}").first
|
|
|
|
|
" org_subfields.organization_id=#{@organization.id} and subfield_subdomain_dirs.name='#{params[:name]}'").first
|
|
|
|
|
if @org_subfield.field_type == 'Post'
|
|
|
|
|
redirect_to organization_path(@organization, :org_subfield_id => @org_subfield.id)
|
|
|
|
|
end
|
|
|
|
|
if params[:sort]
|
|
|
|
|
params[:sort].split(",").each do |sort_type|
|
|
|
|
|
order_by = sort_type.split(":")
|
|
|
|
@ -74,17 +74,9 @@ class OrgSubfieldsController < ApplicationController
|
|
|
|
|
show_attachments @containers
|
|
|
|
|
@tag_list = attachment_tag_list @all_attachments
|
|
|
|
|
@page = params[:page] || 1
|
|
|
|
|
render :layout => 'base_org'
|
|
|
|
|
# @org_subfield = OrgSubfield.find(params[:id])
|
|
|
|
|
# @organization = @org_subfield.organization.id
|
|
|
|
|
# @messages = []
|
|
|
|
|
# @messages << @org_subfield.org_document_comments
|
|
|
|
|
# @messages << @org_subfield.messages
|
|
|
|
|
# @messages.sort{|a, b| b.updated_at <=> a.updated_at}
|
|
|
|
|
# respond_to do |format|
|
|
|
|
|
# format.html{render :layout => 'base_org'}
|
|
|
|
|
# end
|
|
|
|
|
#render :layout => 'base_org'
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
|
@subfield = OrgSubfield.find(params[:id])
|
|
|
|
|
@organization = Organization.find(@subfield.organization_id)
|
|
|
|
@ -97,4 +89,43 @@ class OrgSubfieldsController < ApplicationController
|
|
|
|
|
@subfield.update_attributes(:name => params[:name])
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def update_sub_dir
|
|
|
|
|
@org_subfield = OrgSubfield.find(params[:id])
|
|
|
|
|
sql = "select subfield_subdomain_dirs.* from subfield_subdomain_dirs, org_subfields where subfield_subdomain_dirs.org_subfield_id = org_subfields.id "+
|
|
|
|
|
"and org_subfields.organization_id=#{@org_subfield.organization.id} and subfield_subdomain_dirs.name='#{params[:sub_dir_name]}'"
|
|
|
|
|
if SubfieldSubdomainDir.find_by_sql(sql).count == 0
|
|
|
|
|
if @org_subfield.subfield_subdomain_dir
|
|
|
|
|
@sub_dir = @org_subfield.subfield_subdomain_dir
|
|
|
|
|
@sub_dir.update_attribute(:name, params[:sub_dir_name])
|
|
|
|
|
else
|
|
|
|
|
@sub_dir = SubfieldSubdomainDir.create(:org_subfield_id => @org_subfield.id, :name => params[:sub_dir_name])
|
|
|
|
|
end
|
|
|
|
|
@exist = false
|
|
|
|
|
else
|
|
|
|
|
@exist = true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def show_attachments obj
|
|
|
|
|
@attachments = []
|
|
|
|
|
obj.each do |container|
|
|
|
|
|
@attachments += container.attachments
|
|
|
|
|
end
|
|
|
|
|
@all_attachments = User.current.admin? ? @attachments : visable_attachemnts(@attachments)
|
|
|
|
|
@limit = 10
|
|
|
|
|
@feedback_count = @all_attachments.count
|
|
|
|
|
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
|
|
|
|
|
@offset ||= @feedback_pages.offset
|
|
|
|
|
#@curse_attachments_all = @all_attachments[@offset, @limit]
|
|
|
|
|
@obj_attachments = paginateHelper @all_attachments,10
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#获取指定资源列表的TAG的集合以及每个TAG的数量,降序排序
|
|
|
|
|
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
|
|
|
|
|
end
|
|
|
|
|