资源库 全部里能看到课程资源,但是分类里边却没有。

This commit is contained in:
lizanle 2015-08-21 16:36:42 +08:00
parent 1aa61acd79
commit f6b01b300d
3 changed files with 12 additions and 19 deletions

View File

@ -967,7 +967,8 @@ class UsersController < ApplicationController
end
elsif params[:type] == "2" #课程资源
if User.current.id.to_i == params[:id].to_i
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') ").order("created_on desc")
user_course_ids = User.current.courses.map { |c| c.id}
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.join(',')})) ").order("created_on desc")
else
user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中
@attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 and container_type = 'Course')"+
@ -1382,7 +1383,8 @@ class UsersController < ApplicationController
end
elsif params[:type] == "2" #课程资源
if User.current.id.to_i == params[:id].to_i
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') ").order("created_on desc")
user_course_ids = User.current.courses.map { |c| c.id}
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.join(',')})) ").order("created_on desc")
else
user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中
@attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 and container_type = 'Course')"+
@ -1432,7 +1434,8 @@ class UsersController < ApplicationController
end
elsif params[:type] == "2" #课程资源
if User.current.id.to_i == params[:id].to_i
@attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Course' and (filename like '%#{search}%')").order("created_on desc")
user_course_ids = User.current.courses.map { |c| c.id}
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.join(',')})) ").order("created_on desc")
else
user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中
@attachments = Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type = 'Course') "+

View File

@ -166,12 +166,12 @@
<span style="font-weight:normal;font-size:12px;color:#FF5722;">(<%=@user.projects.visible.count%>)</span>
</a>
</div>
<div class="subNav">
<a href="<%=url_for(:controller => 'users', :action => 'user_resource',:id=>@user.id,:type=>1)%>" class=" f14 c_blue02">
TA的资源库
<span style="font-weight:normal;font-size:12px;color:#FF5722;">(<%=Attachment.where("(author_id = #{@user.id} and is_public = 1 and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) or (container_type = 'Course' and is_public = 1 and container_id in (#{@user.courses.visible.map{|c| c.id}.join(',')}))").count%>)</span>
</a>
</div>
<!--<div class="subNav">-->
<!--<a href="<%#=url_for(:controller => 'users', :action => 'user_resource',:id=>@user.id,:type=>1)%>" class=" f14 c_blue02">-->
<!--TA的资源库-->
<!--<span style="font-weight:normal;font-size:12px;color:#FF5722;">(<%#=Attachment.where("(author_id = #{@user.id} and is_public = 1 and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) or (container_type = 'Course' and is_public = 1 and container_id in (#{@user.courses.visible.map{|c| c.id}.join(',')}))").count%>)</span>-->
<!--</a>-->
<!--</div>-->
<% end %>
<div class="subNav ">
<%= link_to "留言",feedback_path(@user),:class => "f14 c_blue02"%>

View File

@ -1509,15 +1509,6 @@ ActiveRecord::Schema.define(:version => 20150820004659) do
add_index "user_statuses", ["grade"], :name => "index_user_statuses_on_grade"
add_index "user_statuses", ["watchers_count"], :name => "index_user_statuses_on_watchers_count"
create_table "userfeedback_messages", :force => true do |t|
t.integer "user_id"
t.integer "user_message_id"
t.string "user_message_type"
t.integer "viewed"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "users", :force => true do |t|
t.string "login", :default => "", :null => false
t.string "hashed_password", :limit => 40, :default => "", :null => false
@ -1535,7 +1526,6 @@ ActiveRecord::Schema.define(:version => 20150820004659) do
t.string "identity_url"
t.string "mail_notification", :default => "", :null => false
t.string "salt", :limit => 64
t.integer "gid"
end
add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id"