Merge branch 'szzh' into develop
This commit is contained in:
commit
cc4661a9b8
|
@ -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,20 +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
|
||||
@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
|
||||
|
@ -1373,20 +1375,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
|
||||
|
@ -1422,21 +1425,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
|
||||
@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.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" #项目资源
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -149,7 +149,7 @@
|
|||
<div class="subNav">
|
||||
<a href="<%=url_for(:controller => 'users', :action => 'user_resource',:id=>@user.id,:type=>1)%>" class=" f14 c_blue02">
|
||||
我的资源库
|
||||
<span style="font-weight:normal;font-size:12px;color:#FF5722;">(<%=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%>)</span>
|
||||
<span style="font-weight:normal;font-size:12px;color:#FF5722;">(<%=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%>)</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
@ -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"%>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
</li>
|
||||
<li class="resourcesListSize fl"><%= number_to_human_size(attach.filesize) %></li>
|
||||
<li class="resourcesListType fl"><%= get_resource_type(attach.container_type)%></li>
|
||||
<li class="resourcesListUploader fl"><%=User.find(attach.author_id).realname %></li>
|
||||
<li class="resourcesListUploader fl"><%=User.find(attach.author_id).realname.blank? ? User.find(attach.author_id).nickname : User.find(attach.author_id).realname %></li>
|
||||
<li style="display: none"><%= attach.author_id %></li>
|
||||
<li class="resourcesListTime fl"><%= format_date(attach.created_on) %></li>
|
||||
<li style="display: none"><%= attach.id %></li>
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<div id="RSide" class="fl">
|
||||
<div class="homepageRight">
|
||||
<div class="resources">
|
||||
|
||||
<div class="resourcesBanner">
|
||||
<div class="bannerName">消息</div>
|
||||
<ul class="resourcesSelect">
|
||||
<li class="resourcesSelected"><a href="javascript:void(0);" class="resourcesIcon"></a>
|
||||
<li class="resourcesSelected2"><a href="javascript:void(0);" class="resourcesIcon2"></a>
|
||||
<ul class="newsType">
|
||||
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "全部",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user} %></a></li>
|
||||
<%# 课程相关消息 %>
|
||||
|
@ -250,5 +250,5 @@
|
|||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
31
db/schema.rb
31
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"
|
||||
|
|
|
@ -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;}*/
|
||||
|
|
Loading…
Reference in New Issue