diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 15d731634..52fdad2e7 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2705,7 +2705,7 @@ class UsersController < ApplicationController # 获取公共资源搜索 def get_public_resources_search user_course_ids, user_project_ids, order, score, search - attachments = Attachment.where("is_publish = 1 and is_public = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course') and (filename like :p)" ,:p => search).order("#{order.nil? ? 'created_on' : order} #{score}") + attachments = Attachment.where("is_publish = 1 and is_public = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course') and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}") end # 获取我的资源 @@ -2816,7 +2816,7 @@ class UsersController < ApplicationController # 获取我的用户类型资源 def get_principal_resources_public order, score - attchments = Attachment.where("container_type = 'Principal'and container_id is not null").order("#{order.nil? ? 'created_on' : order} #{score}") + attchments = Attachment.where("container_type = 'Principal' and container_id is not null").order("#{order.nil? ? 'created_on' : order} #{score}") end # 获取我的用户类型资源 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6e0f70313..8d9c9733e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -49,6 +49,21 @@ module ApplicationHelper return result end + # 判断某个资源是否可以申请 + def attach_show_allow attach_id + attachment = Attachment.find(attach_id) + case attachment.container_type + when "Project" + User.current.member_of?(attachment.container) ? true : false + when "Course" + User.current.member_of_course?(attachment.container) ? true : false + when "OrgSubfield" + User.current.member_of_org?(attachment.container) ? true : false + when "Principal" + User.current.id == attachment.author_id ? true : false + end + end + # Time 2015-03-24 15:27:29 # Author lizanle # Description 从硬盘上删除对应的资源文件 diff --git a/app/views/organizations/_show_home_page.html.erb b/app/views/organizations/_show_home_page.html.erb index 7d8f7963f..ecb5ebb25 100644 --- a/app/views/organizations/_show_home_page.html.erb +++ b/app/views/organizations/_show_home_page.html.erb @@ -59,7 +59,7 @@ postContent=postContent.replace(/ /g," "); $(this).html(postContent); }); - autoUrl('intro_content_<%= @document.id %>'); + autoUrl('intro_content_<%= document.id %>'); function expand_reply(container, btnid) { var target = $(container); var btn = $(btnid); diff --git a/app/views/users/_apply_resource_course_message_reply.html.erb b/app/views/users/_apply_resource_course_message_reply.html.erb index 617ee53c3..2aff99c17 100644 --- a/app/views/users/_apply_resource_course_message_reply.html.erb +++ b/app/views/users/_apply_resource_course_message_reply.html.erb @@ -7,10 +7,10 @@