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%>)
-
<%= link_to "留言",feedback_path(@user),:class => "f14 c_blue02"%>
diff --git a/db/schema.rb b/db/schema.rb
index 88e0cdd94..3ca31a7d2 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -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"
From 2589179fcac39875f9a7085586359a362f2cb469 Mon Sep 17 00:00:00 2001
From: lizanle <491823689@qq.com>
Date: Fri, 21 Aug 2015 16:57:44 +0800
Subject: [PATCH 3/7] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E7=99=BB?=
=?UTF-8?q?=E9=99=86=E6=8A=A5=E9=94=99?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/layouts/base_users_new.html.erb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/layouts/base_users_new.html.erb b/app/views/layouts/base_users_new.html.erb
index e9b7ddb12..e4fe188d2 100644
--- a/app/views/layouts/base_users_new.html.erb
+++ b/app/views/layouts/base_users_new.html.erb
@@ -149,7 +149,7 @@
我的资源库
- (<%=Attachment.where("(author_id = #{@user.id} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) or (container_type = 'Course' and container_id in (#{@user.courses.map{|c| c.id}.join(',')}))").count%>)
+ (<%=Attachment.where("(author_id = #{@user.id} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) or (container_type = 'Course' and container_id in (#{@user.courses.map{|c| c.id}.empty? ? '0' : @user.courses.map{|c| c.id}.join(',')}))").count%>)
From 0489b02e54e53175bdedf4f849c47497e41651cf Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Fri, 21 Aug 2015 17:00:17 +0800
Subject: [PATCH 4/7] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E7=95=99=E8=A8=80?=
=?UTF-8?q?=E6=97=A0=E6=B3=95=E5=88=A0=E9=99=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/words_controller.rb | 30 +++++++++++++++--------------
app/models/journals_for_message.rb | 2 +-
2 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb
index fc723d5d5..5158a99c4 100644
--- a/app/controllers/words_controller.rb
+++ b/app/controllers/words_controller.rb
@@ -70,20 +70,22 @@ class WordsController < ApplicationController
end
def destroy
- @journal_destroyed = JournalsForMessage.delete_message(params[:object_id])
- if @journal_destroyed.jour_type == "Bid"
- @bid = Bid.find(@journal_destroyed.jour_id)
- @jours_count = @bid.journals_for_messages.where('m_parent_id IS NULL').count
- elsif @journal_destroyed.jour_type == "Course"
- @course = Course.find @journal_destroyed.jour_id
- @jours_count = @course.journals_for_messages.where('m_parent_id IS NULL').count
- elsif @journal_destroyed.jour_type == "Principal"
- @user = User.find(@journal_destroyed.jour_id)
- @jours_count = @user.journals_for_messages.where('m_parent_id IS NULL').count
- @is_user = true
- end
- respond_to do |format|
- format.js
+ @journal_destroyed = JournalsForMessage.find params[:object_id]
+ if @journal_destroyed.destroy
+ if @journal_destroyed.jour_type == "Bid"
+ @bid = Bid.find(@journal_destroyed.jour_id)
+ @jours_count = @bid.journals_for_messages.where('m_parent_id IS NULL').count
+ elsif @journal_destroyed.jour_type == "Course"
+ @course = Course.find @journal_destroyed.jour_id
+ @jours_count = @course.journals_for_messages.where('m_parent_id IS NULL').count
+ elsif @journal_destroyed.jour_type == "Principal"
+ @user = User.find(@journal_destroyed.jour_id)
+ @jours_count = @user.journals_for_messages.where('m_parent_id IS NULL').count
+ @is_user = true
+ end
+ respond_to do |format|
+ format.js
+ end
end
end
diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb
index 853376f6a..2c56dc035 100644
--- a/app/models/journals_for_message.rb
+++ b/app/models/journals_for_message.rb
@@ -60,7 +60,7 @@ class JournalsForMessage < ActiveRecord::Base
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
# 消息关联
has_many :course_messages, :class_name => 'CourseMessage',:as =>:course_message ,:dependent => :destroy
- has_many :user_feedback_messages, :class_name => 'UserFeedbackMessage', :as =>:user_feeback_message, :dependent => :destroy
+ has_many :user_feedback_messages, :class_name => 'UserFeedbackMessage', :as =>:journals_for_message, :dependent => :destroy
validates :notes, presence: true, if: :is_homework_jour?
after_create :act_as_activity, :act_as_course_activity, :act_as_course_message, :act_as_user_feedback_message
From 033aea28c57b71037d91ca1bf27abc7abdf0bc16 Mon Sep 17 00:00:00 2001
From: lizanle <491823689@qq.com>
Date: Fri, 21 Aug 2015 17:05:54 +0800
Subject: [PATCH 5/7] =?UTF-8?q?=E6=96=B0=E6=88=90=E5=91=98=E6=B3=A8?=
=?UTF-8?q?=E5=86=8C=E7=9A=84=E6=97=B6=E5=80=99=E6=8A=A5=E9=94=99?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/users_controller.rb | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 3c163fada..9e5886f3d 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -1374,21 +1374,21 @@ class UsersController < ApplicationController
if User.current.id.to_i == params[:id].to_i
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
- "or (container_type = 'Course' and container_id in (#{user_course_ids.join(',')}))").order("created_on desc")
+ "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc")
else
user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #Ta的资源库的话,应该是他上传的公开资源 加上 他加入的所有我可见课程里的公开资源
@attachments = Attachment.where("(author_id = #{params[: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_course_ids.join(',')}))").order("created_on desc")
+ "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc")
end
elsif params[:type] == "2" #课程资源
if User.current.id.to_i == params[:id].to_i
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")
+ @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': 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')"+
- "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.join(',')}))").order("created_on desc")
+ "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc")
end
elsif params[:type] == "3" #项目资源
if User.current.id.to_i == params[:id].to_i
@@ -1424,22 +1424,22 @@ class UsersController < ApplicationController
if User.current.id.to_i == params[:id].to_i
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 取交集并查询
@attachments = Attachment.where("((author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
- " or (container_type = 'Course' and container_id in (#{user_course_ids.join(',')}))) and (filename like '%#{search}%') ").order("created_on desc")
+ " or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))) and (filename like '%#{search}%') ").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 in" +
" ('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon'))"+
- " or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.join(',')})) )" +
+ " or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )" +
" and (filename like '%#{search}%') ").order("created_on desc")
end
elsif params[:type] == "2" #课程资源
if User.current.id.to_i == params[:id].to_i
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")
+ @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': 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') "+
- "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.join(',')})) )"+
+ "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )"+
" and (filename like '%#{search}%') ").order("created_on desc")
end
elsif params[:type] == "3" #项目资源
From 53c28a9b3929a3a174c2f4d85800d90a22efcbd0 Mon Sep 17 00:00:00 2001
From: lizanle <491823689@qq.com>
Date: Fri, 21 Aug 2015 17:13:42 +0800
Subject: [PATCH 6/7] =?UTF-8?q?=E6=96=B0=E6=88=90=E5=91=98=E6=B3=A8?=
=?UTF-8?q?=E5=86=8C=E7=9A=84=E6=97=B6=E5=80=99=E6=8A=A5=E9=94=99?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/users_controller.rb | 17 +++++++++--------
app/views/users/_resources_list.html.erb | 2 +-
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 9e5886f3d..ddd167272 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -903,20 +903,21 @@ class UsersController < ApplicationController
if User.current.id.to_i == params[:id].to_i
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
- "or (container_type = 'Course' and container_id in (#{user_course_ids.join(',')}))").order("created_on desc")
+ "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc")
else
user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #Ta的资源库的话,应该是他上传的公开资源 加上 他加入的所有我可见课程里的公开资源
@attachments = Attachment.where("(author_id = #{params[: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_course_ids.join(',')}))").order("created_on desc")
+ "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc")
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.empty? ? '0': 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')"+
- "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.join(',')}))").order("created_on desc")
+ "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc")
end
elsif params[:type] == "3" #项目资源
if User.current.id.to_i == params[:id].to_i
@@ -958,21 +959,21 @@ class UsersController < ApplicationController
if User.current.id.to_i == params[:id].to_i
user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
- "or (container_type = 'Course' and container_id in (#{user_course_ids.join(',')}))").order("created_on desc")
+ "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc")
else
user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #Ta的资源库的话,应该是他上传的公开资源 加上 他加入的所有我可见课程里的公开资源
@attachments = Attachment.where("(author_id = #{params[: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_course_ids.join(',')}))").order("created_on desc")
+ "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc")
end
elsif params[:type] == "2" #课程资源
if User.current.id.to_i == params[:id].to_i
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")
+ @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': 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')"+
- "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.join(',')}))").order("created_on desc")
+ "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc")
end
elsif params[:type] == "3" #项目资源
if User.current.id.to_i == params[:id].to_i
diff --git a/app/views/users/_resources_list.html.erb b/app/views/users/_resources_list.html.erb
index fd72c99e4..b41b9f28f 100644
--- a/app/views/users/_resources_list.html.erb
+++ b/app/views/users/_resources_list.html.erb
@@ -13,7 +13,7 @@
<%= number_to_human_size(attach.filesize) %>
<%= get_resource_type(attach.container_type)%>
-
<%=User.find(attach.author_id).realname %>
+
<%=User.find(attach.author_id).realname.blank? ? User.find(attach.author_id).nickname : User.find(attach.author_id).realname %>
<%= attach.author_id %>
<%= format_date(attach.created_on) %>
<%= attach.id %>
From 17aae7c79db22f4455b14bc0c668326e3c7ee0d8 Mon Sep 17 00:00:00 2001
From: huang
Date: Fri, 21 Aug 2015 17:40:28 +0800
Subject: [PATCH 7/7] =?UTF-8?q?=E8=A7=A3=E5=86=B3CSS=E5=86=B2=E7=AA=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/users/user_messages.html.erb | 6 +++---
public/stylesheets/public_new.css | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb
index c1b57aabb..a74e1800f 100644
--- a/app/views/users/user_messages.html.erb
+++ b/app/views/users/user_messages.html.erb
@@ -1,10 +1,10 @@
+
diff --git a/public/stylesheets/public_new.css b/public/stylesheets/public_new.css
index bccac7da0..ec7ec26a1 100644
--- a/public/stylesheets/public_new.css
+++ b/public/stylesheets/public_new.css
@@ -592,9 +592,9 @@ input.sendSourceText {font-size:14px;color:#ffffff;background-color:#64bdd9;}
/*.resourcesBanner {width:730px; height:40px; background-color:#eaeaea; margin-bottom:10px;}*/
/*.bannerName {background:#64bdd9; color:#ffffff; height:40px; line-height:40px; width:90px; text-align:center; font-weight:normal; vertical-align:middle; font-size: 16px; float:left;}*/
/*.resourcesSelect {width:40px; height:40px; float:right; position:relative;}*/
-/*.resourcesSelected {width:25px; height:20px;}*/
-/*.resourcesIcon {margin-top:15px; display:block; position:relative; background:url(images/resource_icon_list.png) 0px 0px no-repeat; width:25px; height:20px;}*/
-/*.resourcesIcon:hover { background:url(images/resource_icon_list.png) 0px -25px no-repeat;}*/
+.resourcesSelected2 {width:25px; height:20px;}
+.resourcesIcon2 {margin-top:20px; display:block; position:relative; background:url(images/resource_icon_list.png) 0px 0px no-repeat; width:25px; height:20px;}
+.resourcesIcon2:hover { background:url(images/resource_icon_list.png) 0px -25px no-repeat;}
/*.resourcesType {width:50px; background-color:#ffffff; float:left; list-style:none; position:absolute; border:1px solid #eaeaea; border-radius:5px; top:35px; padding:5px 10px; left:-30px; font-size:12px; color:#888888; display:none;}*/
/*a.resourcesGrey {font-size:12px; color:#888888;}*/
/*a.resourcesGrey:hover {font-size:12px; color:#15bccf;}*/