From 535145f8f2df191778805a3d410708a8b0815cf7 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 21 Aug 2015 16:35:52 +0800 Subject: [PATCH 1/7] 11 --- db/schema.rb | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 88e0cdd94..1c77ff04b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20150820004659) do +ActiveRecord::Schema.define(:version => 20150820025358) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -776,16 +776,6 @@ ActiveRecord::Schema.define(:version => 20150820004659) do add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" - create_table "journal_details_copy", :force => true do |t| - t.integer "journal_id", :default => 0, :null => false - t.string "property", :limit => 30, :default => "", :null => false - t.string "prop_key", :limit => 30, :default => "", :null => false - t.text "old_value" - t.text "value" - end - - add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id" - create_table "journal_replies", :id => false, :force => true do |t| t.integer "journal_id" t.integer "user_id" @@ -1414,6 +1404,15 @@ ActiveRecord::Schema.define(:version => 20150820004659) do t.integer "fields_bits", :default => 0 end + create_table "user_activities", :force => true do |t| + t.string "act_type" + t.integer "act_id" + t.string "container_type" + t.integer "container_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "user_extensions", :force => true do |t| t.integer "user_id", :null => false t.date "birthday" @@ -1509,15 +1508,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 +1525,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" From f6b01b300d0b9398f55c32e7bf6a547fcf27bb8f Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 21 Aug 2015 16:36:42 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=BA=93=20=E5=85=A8?= =?UTF-8?q?=E9=83=A8=E9=87=8C=E8=83=BD=E7=9C=8B=E5=88=B0=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E8=B5=84=E6=BA=90=EF=BC=8C=E4=BD=86=E6=98=AF=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E9=87=8C=E8=BE=B9=E5=8D=B4=E6=B2=A1=E6=9C=89=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 9 ++++++--- app/views/layouts/base_users_new.html.erb | 12 ++++++------ db/schema.rb | 10 ---------- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 8f69642f7..3c163fada 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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') "+ diff --git a/app/views/layouts/base_users_new.html.erb b/app/views/layouts/base_users_new.html.erb index be75f53f1..e9b7ddb12 100644 --- a/app/views/layouts/base_users_new.html.erb +++ b/app/views/layouts/base_users_new.html.erb @@ -166,12 +166,12 @@ (<%=@user.projects.visible.count%>) - + + + + + + <% end %>