Merge branch 'dev_hjq' into szzh

This commit is contained in:
huang 2015-08-15 17:10:44 +08:00
commit 8d30bec8a4
30 changed files with 686 additions and 74 deletions

View File

@ -112,7 +112,19 @@ class IssuesController < ApplicationController
end
def show
# 当前用户查看指派给他的缺陷消息,则设置消息为已读
query = @issue.forge_messages
if User.current.id == @issue.assigned_to_id
query.update_all(:viewed => true)
end
# 缺陷状态更新
query_journals = @issue.journals
if User.current.id == @issue.author_id
query_journals.each do |query_journal|
query_journal.forge_messages.update_all(:viewed => true)
end
end
#
@journals = @issue.journals.includes(:user, :details).reorder("#{Journal.table_name}.id ASC").all
@journals.each_with_index {|j,i| j.indice = i+1}
@journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project)

View File

@ -28,6 +28,7 @@ class UsersController < ApplicationController
# menu_item :requirement_focus, :only => :watch_bids
menu_item :requirement_focus, :only => :watch_contests
menu_item :user_newfeedback, :only => :user_newfeedback
menu_item :user_messages, :only => :user_messages
#Ended by young
@ -40,14 +41,14 @@ class UsersController < ApplicationController
:user_watchlist, :user_fanslist,:update, :user_courses, :user_homeworks, :watch_projects, :show_score, :topic_score_index, :project_score_index,
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
:activity_new_score_index, :influence_new_score_index, :score_new_index,:update_score,:user_activities,:user_projects_index,
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist]
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages]
#edit has been deleted by huang, 2013-9-23
before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses,
:user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments,
:watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index,
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
:activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist]
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages]
before_filter :auth_user_extension, only: :show
#before_filter :rest_user_score, only: :show
#before_filter :select_entry, only: :user_projects
@ -95,6 +96,41 @@ class UsersController < ApplicationController
end
end
# 用户消息
def user_messages
unless User.current.logged?
render_403
return
end
# 当前用户查看消息,则设置消息为已读
querys = @user.course_messages
if User.current.id == @user.id
querys.update_all(:viewed => true)
end
if @user.course_messages
if params[:type].nil?
@user_course_messages = @user.course_messages
@user_project_messges = @user.forge_messages
else
case params[:type]
when 'homework'
@user_course_messages = @user.course_messages.select{|x| x.course_message_type == "HomeworkCommon"}
#@user_course_messages = ForgeMessage.find_by_sql("select * from course_messages where user_id='#{@user.id}' and course_message_type = 'HomeworkCommon' order by created_at desc;")
when 'message'
@user_course_messages = @user.course_messages.select{|x| x.course_message_type == "Message"}
when 'news'
@user_course_messages = @user.course_messages.select{|x| x.course_message_type == "News"}
when 'poll'
@user_course_messages = @user.course_messages.select{|x| x.course_message_type == "Poll"}
end
end
respond_to do |format|
format.html{render :layout=>'base_users_new'}
format.api
end
end
end
def user_projects_index
if User.current.admin?
memberships = @user.memberships.all(conditions: "projects.project_type = #{Project::ProjectType_project}").first

View File

@ -37,6 +37,7 @@ class Course < ActiveRecord::Base
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
has_many :course_activities
has_many :course_messages
acts_as_taggable
acts_as_nested_set :order => 'name', :dependent => :destroy

View File

@ -0,0 +1,12 @@
class CourseMessage < ActiveRecord::Base
attr_accessible :course_id, :course_message_id, :course_message_type, :user_id, :viewed
# 多态 虚拟关联
belongs_to :course_message ,:polymorphic => true
belongs_to :course
belongs_to :user
validates :user_id,presence: true
validates :course_id,presence: true
validates :course_message_id,presence: true
validates :course_message_type, presence: true
end

View File

@ -0,0 +1,20 @@
class ForgeMessage < ActiveRecord::Base
# 公共表中活动类型,命名规则:TYPE_OF_{类名}_ACT
TYPE_OF_ISSUE_ACT = "Issue"
TYPE_OF_MESSAGE_ACT = "Message"
TYPE_OF_ATTACHMENT_ACT = "Attachment"
TYPE_OF_DOCUMENT_ACT = "Document"
TYPE_OF_JOURNAL_ACT = "Journal"
TYPE_OF_WIKI_ACT = "Wiki"
TYPE_OF_NEWS_ACT = "News"
attr_accessible :forge_message_id, :forge_message_type, :project_id, :user_id, :viewed
belongs_to :forge_message ,:polymorphic => true
belongs_to :project
belongs_to :user
validates :user_id,presence: true
validates :project_id,presence: true
validates :forge_message_id,presence: true
validates :forge_message_type, presence: true
end

View File

@ -15,12 +15,14 @@ class HomeworkCommon < ActiveRecord::Base
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy #用户活动
# 课程动态
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
# 课程消息
has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy
acts_as_attachable
acts_as_event :title => Proc.new {|o| "#{l(:label_course_homework)} ##{o.id}: #{o.name}" },
:description => :description,
:author => :author,
:url => Proc.new {|o| {:controller => 'student_work', :action => 'index', :homework => o.id}}
after_create :act_as_activity, :send_mail, :act_as_course_activity
after_create :act_as_activity, :send_mail, :act_as_course_activity, :act_as_course_message
after_destroy :delete_kindeditor_assets
def act_as_activity
@ -34,6 +36,17 @@ class HomeworkCommon < ActiveRecord::Base
end
end
#课程作业消息记录
def act_as_course_message
if self.course
self.course.members.each do |m|
if m.user_id != self.user_id
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false)
end
end
end
end
#删除对应的图片
def delete_kindeditor_assets
delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::HOMEWORKCOMMON

View File

@ -49,6 +49,8 @@ class Issue < ActiveRecord::Base
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
# end
has_many :praise_tread, as: :praise_tread_object, dependent: :destroy
# ForgeMessage虚拟关联(多态)
has_many :forge_messages, :class_name => 'ForgeMessage',:as =>:forge_message ,:dependent => :destroy
acts_as_nested_set :scope => 'root_id', :dependent => :destroy
@ -80,7 +82,7 @@ class Issue < ActiveRecord::Base
attr_reader :current_journal
# fq
after_create :act_as_activity,:be_user_score_new_issue,:act_as_forge_activity
after_create :act_as_activity,:be_user_score_new_issue,:act_as_forge_activity, :act_as_forge_message
after_update :be_user_score
after_destroy :down_user_score
# after_create :be_user_score
@ -138,6 +140,16 @@ class Issue < ActiveRecord::Base
:project_id => self.project_id)
end
# end
# 发布缺陷forge_messages中添加记录
def act_as_forge_message
# 指派给自己的缺陷不提示消息
unless self.author_id == self.assigned_to_id
self.forge_messages << ForgeMessage.new(:user_id => self.assigned_to_id,
:project_id => self.project_id,
:viewed => false)
end
end
# Returns a SQL conditions string used to find all issues visible by the specified user

View File

@ -29,6 +29,8 @@ class Journal < ActiveRecord::Base
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
# 被ForgeActivity虚拟关联
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
# 被ForgeMessage虚拟关联
has_many :forge_messages, :class_name => 'ForgeMessage',:as =>:forge_message ,:dependent => :destroy
# end
attr_accessor :indice
@ -48,7 +50,7 @@ class Journal < ActiveRecord::Base
before_create :split_private_notes
# fq
after_save :act_as_activity,:be_user_score,:act_as_forge_activity
after_save :act_as_activity,:be_user_score,:act_as_forge_activity, :act_as_forge_message
# end
#after_destroy :down_user_score
#before_save :be_user_score
@ -167,6 +169,13 @@ class Journal < ActiveRecord::Base
end
# 缺陷状态更改,消息提醒
def act_as_forge_message
self.forge_messages << ForgeMessage.new(:user_id => self.issue.author_id,
:project_id => self.issue.project_id,
:viewed => false)
end
# 更新用户分数 -by zjc
def be_user_score
#新建了缺陷留言且留言不为空,不为空白

View File

@ -35,6 +35,9 @@ class Message < ActiveRecord::Base
# 课程动态
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
# end
# 课程消息
has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy
#end
has_many :ActivityNotifies,:as => :activity, :dependent => :destroy
@ -70,7 +73,7 @@ class Message < ActiveRecord::Base
after_update :update_messages_board
after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets
after_create :act_as_activity,:act_as_course_activity,:be_user_score,:act_as_forge_activity, :send_mail
after_create :act_as_activity,:act_as_course_activity,:be_user_score,:act_as_forge_activity, :act_as_course_message, :send_mail
#before_save :be_user_score
scope :visible, lambda {|*args|
@ -194,6 +197,54 @@ class Message < ActiveRecord::Base
self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.board.course_id)
end
end
# 课程讨论区添加消息
# 老师发帖所有人都能收到消息
# 学生发帖,有人回复则给该学生消息,没回复则不给其它人发送消息
# 帖子被回复的可以收到消息通知
def act_as_course_message
if self.course
if self.parent_id.nil? #主贴
self.course.members.each do |m|
if self.author.allowed_to?(:as_teacher, self.course) # 老师
if m.user_id != self.author_id # 自己的帖子不给自己发送消息
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false)
end
end
end
else # 回帖
#if self.author.allowed_to?(:as_teacher, self.course) # 老师
self.course.members.each do |m|
if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false)
end
end
#end
end
end
# if self.author.allowed_to?(:as_teacher, self.course) # 如果发帖人是老师
# self.course.members.each do |m|
# if self.parent_id.nil? # 主贴
# if m.user_id != self.author_id # 自己的帖子不给自己发送消息
# self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false)
# end
# else # 回帖只针对主贴发送消息
# if m.user_id == Message.find(self.parent_id).author_id
# self.course_messages << CourseMessage.new(:user_id => self.parent_id, :course_id => self.board.course_id, :viewed => false)
# end
# end
# end
# else # 学生只针对主贴回复
# unless self.parent_id.nil?
# self.course.members.each do |m|
# if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息
# self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false)
# end
# end
# end
# end
#end
end
#更新用户分数 -by zjc
def be_user_score

View File

@ -31,6 +31,9 @@ class News < ActiveRecord::Base
# 课程动态
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
# end
# 课程消息
has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy
#end
has_many :ActivityNotifies,:as => :activity, :dependent => :destroy
@ -51,7 +54,7 @@ class News < ActiveRecord::Base
:author_key => :author_id
acts_as_watchable
after_create :act_as_activity,:act_as_forge_activity, :act_as_course_activity,:add_author_as_watcher, :send_mail
after_create :act_as_activity,:act_as_forge_activity, :act_as_course_activity,:act_as_course_messge, :add_author_as_watcher, :send_mail
after_destroy :delete_kindeditor_assets
@ -130,6 +133,18 @@ class News < ActiveRecord::Base
end
end
#课程通知 消息发送
#消息发送原则:除了消息的发布者,课程的其它成员都能收到消息提醒
def act_as_course_messge
if self.course
self.course.members.each do |m|
if m.user_id != self.author_id
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false)
end
end
end
end
# Time 2015-03-31 13:50:54
# Author lizanle
# Description 删除news后删除对应的资源
@ -141,4 +156,4 @@ class News < ActiveRecord::Base
Mailer.run.news_added(self) if Setting.notified_events.include?('news_added')
end
end
end

View File

@ -10,7 +10,10 @@ class Poll < ActiveRecord::Base
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
# 课程动态
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
before_save :act_as_activity, :act_as_course_activity
after_create :act_as_activity, :act_as_course_activity
# 课程消息
has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy
after_create :act_as_activity, :act_as_course_activity, :act_as_course_message
acts_as_event :title => Proc.new {|o| "#{l(:label_course_poll)}: #{o.polls_name}" },
:description => :polls_description,
@ -39,4 +42,16 @@ class Poll < ActiveRecord::Base
end
end
end
# 发布问卷,出了发布者外,其他人都能收到消息通知
def act_as_course_message
if self.polls_type == "Course"
Course.find(self.polls_group_id).members.each do |m|
if m.user_id != self.user_id
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.polls_group_id, :viewed => false)
end
end
end
end
end

View File

@ -91,6 +91,8 @@ class Project < ActiveRecord::Base
has_many :tags, :through => :project_tags, :class_name => 'Tag'
has_many :project_tags, :class_name => 'ProjectTags'
# 关联虚拟表
has_many :forge_messages
belongs_to :organization

View File

@ -109,7 +109,6 @@ class User < Principal
has_many :contests, :foreign_key => 'author_id', :dependent => :destroy
has_many :softapplications, :foreign_key => 'user_id', :dependent => :destroy
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
has_many :new_jours, :as => :jour, :class_name => 'JournalsForMessage', :conditions => "status=1"
has_many :journal_replies, :dependent => :destroy
has_many :activities, :dependent => :destroy
has_many :students_for_courses
@ -128,8 +127,15 @@ class User < Principal
has_many :messages, :foreign_key => 'author_id'
has_one :user_score, :dependent => :destroy
has_many :documents # 项目中关联的文档再次与人关联
# 关联虚拟表
has_many :forge_messages
has_many :course_messages
# end
# 虚拟转换
has_many :new_jours, :as => :jour, :class_name => 'JournalsForMessage', :conditions => "status=1"
has_many :issue_assigns, :class_name => 'ForgeMessage', :conditions => 'viewed=0 and forge_message_type="Issue"'
has_many :status_updates, :class_name => 'ForgeMessage', :conditions => 'viewed=0 and forge_message_type="Journal"'
# 邮件邀请状态
# has_many :invite_lists
# end
@ -235,6 +241,28 @@ class User < Principal
# ======================================================================
# 查询用户未读过的记录
# 用户留言记录
def count_new_jour
count = self.new_jours.count
# count = self.journals_for_messages(:conditions => ["status=? and is_readed = ? " ,1, 0]).count
end
# 查询指派给我的缺陷记录
def count_new_issue_assign_to
self.issue_assigns
end
# 新消息统计
def count_new_message
count = CourseMessage.where("user_id =? and viewed =?", User.current.id, 0).count
end
# 查询指派给我的缺陷记录
def issue_status_update
self.status_updates
end
# end
def extensions
self.user_extensions ||= UserExtensions.new
end
@ -292,11 +320,6 @@ class User < Principal
end
## end
# 查询用户未读过的记录
def count_new_jour
count = self.journals_for_messages.where("status=? and is_readed = ? " ,1, 0).count
end
#added by nie
def count_new_journal_reply
count = self.journal_reply.count

View File

@ -37,6 +37,7 @@
{:controller=> 'users', :action => 'user_newfeedback', id: User.current.id, host: Setting.host_user},
{:class => 'my-message'} if User.current.logged?%>
</li>
</ul>
</div>
<% end -%>

View File

@ -9,69 +9,60 @@
<div id="menu">
<ul class="menu">
<% if User.current.logged? %>
<li>
<%=link_to_user(User.current)%><!--<a href="javascript:void(0);" class="parent">用户名称</a>-->
<ul>
<% hidden_non_project = Setting.find_by_name("hidden_non_project")
visiable = hidden_non_project && hidden_non_project.value == "0"%>
<% if @show_course == 1 && !visiable %>
<%# if User.current.user_extensions && [UserExtensions::TEACHER, UserExtensions::STUDENT].include?(User.current.user_extensions.identity) -%>
<% hasCourse=false %>
<% User.current.courses.each do |course| %>
<% if !course_endTime_timeout?(course) %>
<% hasCourse=true %>
<li>
<%=link_to_user(User.current)%><!--<a href="javascript:void(0);" class="parent">用户名称</a>-->
<ul>
<% hidden_non_project = Setting.find_by_name("hidden_non_project")
visiable = hidden_non_project && hidden_non_project.value == "0"%>
<% if @show_course == 1 && !visiable %>
<%# if User.current.user_extensions && [UserExtensions::TEACHER, UserExtensions::STUDENT].include?(User.current.user_extensions.identity) -%>
<% hasCourse=false %>
<% User.current.courses.each do |course| %>
<% if !course_endTime_timeout?(course) %>
<% hasCourse=true %>
<% end %>
<% end %>
<% end %>
<% if hasCourse %>
<% if hasCourse %>
<li>
<a href="<%= url_for(:controller => 'users', :action => 'user_courses', :id=>User.current.id, :host=>Setting.host_user) %>" class="parent">我的课程</a>
<ul>
<% User.current.courses.select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").each do |course| %>
<% if !course_endTime_timeout?(course) %>
<li title="<%=course.name%>"><a href="<%= url_for(:controller => 'courses', :action=>"show", :id=>course.id, :host=>Setting.host_course) %>"><%= course.name %></a>
<% end %>
<% end %>
</ul>
</li>
<% end %>
<%# end -%>
<% end %>
<% if User.current.projects.count>0 %>
<li>
<a href="<%= url_for(:controller => 'users', :action => 'user_courses', :id=>User.current.id, :host=>Setting.host_user) %>" class="parent">我的课程</a>
<a href="<%= url_for(:controller => 'users', :action => 'user_projects', :id=>User.current.id, :host=>Setting.host_user) %>" class="parent">我的项目</a>
<ul>
<% User.current.courses.select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").each do |course| %>
<% if !course_endTime_timeout?(course) %>
<li title="<%=course.name%>"><a href="<%= url_for(:controller => 'courses', :action=>"show", :id=>course.id, :host=>Setting.host_course) %>"><%= course.name %></a>
<% end %>
<% User.current.projects.select("projects.*,(SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").each do |project| %>
<li title="<%=project.name%>">
<a href="<%= url_for(:controller => 'projects', :action=>"show", :id=>project.id, :host=>Setting.host_name) %>">
<%=project.name%>
</a>
</li>
<% end %>
</ul>
</li>
<% end %>
<%# end -%>
<% end %>
<li><a href="<%= url_for(:controller => 'my', :action => 'account') %>">编辑资料</a></li>
</ul>
</li><!---level1 end--->
<!--消息提醒-->
<div class="navHomepageNews">
<%= link_to image_tag("/images/news_icon_small.png" , :width => "21", :height => "24"), {:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user} %>
<% if User.current.count_new_message >0 %>
<div class="newsActive"></div>
<% end %>
<% if User.current.projects.count>0 %>
<li>
<a href="<%= url_for(:controller => 'users', :action => 'user_projects', :id=>User.current.id, :host=>Setting.host_user) %>" class="parent">我的项目</a>
<ul>
<% User.current.projects.select("projects.*,(SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").each do |project| %>
<li title="<%=project.name%>">
<a href="<%= url_for(:controller => 'projects', :action=>"show", :id=>project.id, :host=>Setting.host_name) %>">
<%=project.name%>
</a>
</li>
<% end %>
</ul>
</li>
<% end %>
<li><a href="<%= url_for(:controller => 'my', :action => 'account') %>">编辑资料</a></li>
<!--<li><a href="javascript:void(0);" class="parent">我的课程</a>-->
<!--<ul>-->
<!--<li><a href="javascript:void(0);">新建课程</a></li>-->
<!--<li><a href="javascript:void(0);">我的课程0我的课程我的课程01我的课程011</a></li>-->
<!--<li><a href="javascript:void(0);">我的课程02</a></li>-->
<!--<li><a href="javascript:void(0);">我的课程02</a></li>-->
<!--</ul>&lt;!&ndash;-level3 end-&ndash;&gt;-->
<!--</li>&lt;!&ndash;-level2 end-&ndash;&gt;-->
<!--<li><a href="javascript:void(0);" class="parent">我的项目</a>-->
<!--<ul>-->
<!--<li><a href="javascript:void(0);">新建项目</a></li>-->
<!--<li><a href="javascript:void(0);">我的项目01</a></li>-->
<!--<li><a href="javascript:void(0);">我的项目0</a></li>-->
<!--<li><a href="javascript:void(0);">我的项目02</a></li>-->
<!--</ul>&lt;!&ndash;-level3 end-&ndash;&gt;-->
<!--</li>&lt;!&ndash;-level2 end-&ndash;&gt;-->
<!--<li><a href="javascript:void(0);">我的主页</a></li>-->
</ul>
</li><!---level1 end--->
<!--<li ><a href="javascript:void(0);">退出</a></li>-->
</div>
<!--消息提醒end-->
<!--<li ><a href="javascript:void(0);">退出</a></li>-->
<% end %>
</ul>
<%= render_menu :account_menu -%>

View File

@ -53,6 +53,9 @@
</li>
</ul>
</li>
<% end -%>
<%= header_render_menu :account_menu -%>
</ul>

View File

@ -0,0 +1,79 @@
<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>
<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>
<!--<li><a href="javascript:void(0);" class="resourcesGrey">@我</a></li>-->
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "作业消息",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'homework'} %></a></li>
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "讨论区",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'message'} %></a></li>
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "课程通知",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'news'} %></a></li>
<!--<li><a href="javascript:void(0);" class="resourcesGrey">指派给我</a></li>-->
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "问卷调查",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'poll'} %></a></li>
</ul>
</li>
</ul>
</div>
<div>
<% if !@user_course_messages.blank? %>
<% @user_course_messages.each do |ucm| %>
<% if ucm.course_message_type == "News" %>
<ul class="homepageNewsList fl">
<li class="homepageNewsPortrait fl"><a href="javascript:void(0);"><%= image_tag(url_to_avatar(ucm.course_message.author), :width => "30", :height => "30") %></a></li>
<li class="homepageNewsPublisher fl"><a href="javascript:void(0);" class="newsBlue"><%= ucm.course_message.author %></a></li>
<li class="homepageNewsType fl">发布通知</li>
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
<%= link_to format_activity_title(" #{ucm.course_message.title}"), {:controller => 'news', :action => 'show', :id => ucm.course_message.id} %></a></li>
<li class="homepageNewsTime fl"><%= time_tag(ucm.course_message.created_on).html_safe %> </li>
</ul>
<% end %>
<% if ucm.course_message_type == "HomeworkCommon" %>
<ul class="homepageNewsList fl">
<li class="homepageNewsPortrait fl"><a href="javascript:void(0);"><%= image_tag(url_to_avatar(ucm.course_message.user), :width => "30", :height => "30") %></a></li>
<li class="homepageNewsPublisher fl"><a href="javascript:void(0);" class="newsBlue"><%= ucm.course_message.user %></a></li>
<li class="homepageNewsType fl">发布作业</li>
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
<%= link_to ("#{ucm.course_message.name}"), student_work_index_path(:homework => ucm.course_message.id) %></a></li>
<li class="homepageNewsTime fl"><%= time_tag(ucm.course_message.created_at).html_safe %> </li>
</ul>
<% end %>
<% if ucm.course_message_type == "Poll" %>
<ul class="homepageNewsList fl">
<li class="homepageNewsPortrait fl"><a href="javascript:void(0);"><%= image_tag(url_to_avatar(ucm.course_message.user), :width => "30", :height => "30") %></a></li>
<li class="homepageNewsPublisher fl"><a href="javascript:void(0);" class="newsBlue"><%= ucm.course_message.user %></a></li>
<li class="homepageNewsType fl">发布问卷</li>
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
<%= link_to format_activity_title(" #{ucm.course_message.polls_name}"), poll_index_path(:polls_type => "Course", :polls_group_id => ucm.course_id) %></a></li>
<li class="homepageNewsTime fl"><%= time_tag(ucm.course_message.created_at).html_safe %> </li>
</ul>
<% end %>
<% if ucm.course_message_type == "Message" %>
<ul class="homepageNewsList fl">
<li class="homepageNewsPortrait fl"><a href="javascript:void(0);"><%= image_tag(url_to_avatar(ucm.course_message.author), :width => "30", :height => "30") %></a></li>
<li class="homepageNewsPublisher fl"><a href="javascript:void(0);" class="newsBlue"><%= ucm.course_message.author %></a></li>
<% if ucm.course_message.parent_id.nil? %>
<li class="homepageNewsType fl">发布帖子</li>
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
<%=link_to ucm.course_message.subject, course_boards_path(ucm.course_message.course,:parent_id => ucm.course_message.parent_id ? ucm.course_message.parent_id : ucm.course_message.id, :topic_id => ucm.course_message.id) %></a></li>
<li class="homepageNewsTime fl"><%= time_tag(ucm.course_message.created_on).html_safe %> </li>
<% else %>
<li class="homepageNewsType fl">回复帖子</li>
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
<%=link_to ucm.course_message.subject, course_boards_path(ucm.course_message.course,:parent_id => ucm.course_message.parent_id ? ucm.course_message.parent_id : ucm.course_message.id, :topic_id => ucm.course_message.id) %> </a></li>
<li class="homepageNewsTime fl"><%= time_tag(ucm.course_message.created_on).html_safe %> </li>
<% end %>
</ul>
<% end %>
<div class="cl"></div>
<% end %>
<% else %>
<div class="flash notice">暂无消息!</div>
<% end %>
</div>
</div>
</div>
</div>

View File

@ -67,6 +67,13 @@ zh:
label_project_mail_upload: 上传了资源
label_invite: 邀请
# 项目消息通知
label_forge_message: 消息
label_issue_message: 问题
label_course_message: 课程消息
label_project_message: 项目消息
label_issue_tracking: 问题跟踪
label_release_issue: 发布问题

View File

@ -322,6 +322,7 @@ RedmineApp::Application.routes.draw do
match 'user_visitorlist', :to => 'users#user_visitorlist', :via => :get
match 'user_homeworks', :to => 'users#user_homeworks', :via => :get
match 'watch_projects', :to => 'users#watch_projects', :via => :get
# added by bai
match 'show_score', :to => 'users#show_score', :via => :get
match 'topic_score_index', :to => 'users#topic_score_index', :via => [:get, :post]
@ -349,6 +350,7 @@ RedmineApp::Application.routes.draw do
end
match 'users/:id/user_newfeedback', :to => 'users#user_newfeedback', :via => :get, :as => "feedback"
match 'users/:id/user_projects', :to => 'users#user_projects', :via => :get
match 'users/:id/user_messages', :to => 'users#user_messages', :via => :get
#end
match 'my/account', :via => [:get, :post]

View File

@ -0,0 +1,13 @@
class CreateForgeMessages < ActiveRecord::Migration
def change
create_table :forge_messages do |t|
t.integer :user_id
t.integer :project_id
t.integer :forge_message_id
t.string :forge_message_type
t.integer :viewed
t.timestamps
end
end
end

View File

@ -0,0 +1,13 @@
class CreateCourseMessages < ActiveRecord::Migration
def change
create_table :course_messages do |t|
t.integer :user_id
t.integer :course_id
t.integer :course_message_id
t.string :course_message_type
t.integer :viewed
t.timestamps
end
end
end

BIN
public/images/nav_icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -46,6 +46,54 @@ $(document).ready(function () {
addCourseSlipMenu();
});
//消息提醒
function MessageAddSlipMenu () {
var loggedas = $('#current_message_li a:first');
var sub_menu = $('#message_sub_menu');
loggedas.mouseenter(function() {
sub_menu.show();
$('#my_projects_message_ul').hide();
$('#my_courses_message_ul').hide();
});
sub_menu.mouseleave(function() {
sub_menu.hide();
$('#my_projects_message_ul').hide();
$('#my_courses_message_ul').hide();
});
}
function MessageAddProjectSlipMenu () {
var loggedas = $('#my_projects_message_li');
var project_sub_menu = $('#my_projects_message_ul');
var course_sub_menu = $('#my_courses_message_ul');
loggedas.mouseenter(function() {
course_sub_menu.hide();
project_sub_menu.show();
});
loggedas.mouseleave(function() {
project_sub_menu.hide();
course_sub_menu.hide();
});
}
function MessageAddCourseSlipMenu () {
var loggedas = $('#my_courses_message_li');
var project_sub_menu = $('#my_projects_message_ul');
var course_sub_menu = $('#my_courses_message_ul');
loggedas.mouseenter(function() {
project_sub_menu.hide();
course_sub_menu.show();
});
loggedas.mouseleave(function() {
course_sub_menu.hide();
project_sub_menu.hide();
});
}
$(document).ready(function () {
MessageAddSlipMenu();
MessageAddProjectSlipMenu ();
MessageAddCourseSlipMenu();
});
//将右侧的最小高度设置成左侧高度,美化界面
$(document).ready(function () {
$("#RSide").css("min-height",$("#LSide").height()-30);

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -6,8 +6,8 @@ div,img,tr,td,table{ border:0;}
table,tr,td{border:0;cellspacing:0; cellpadding:0;}
ol,ul,li{ list-style-type:none}
a:link,a:visited{color:#7f7f7f;text-decoration:none;}
a:hover,a:active{color:#000;}
img{max-width: 100%;}
a:hover,a:active{color:#15bccf;}
/*img{max-width: 100%;}*/
/*常用*/
select,input,textarea{ border:1px solid #64bdd9; background:#fff; color:#000; padding-left:5px; }
@ -445,3 +445,207 @@ div.ke-statusbar{height:1px; border-top:none;}
/*a.f_grey {color:#666666;}*/
/*a.f_grey:hover {color:#000000;}*/
/*主类容左右分栏*/
#LSide{ width:240px; }
#RSide{ width:730px; margin-left:10px; background:#fff; padding:10px; margin-bottom:10px;}
/*资源库*/
.resources {width:730px; background-color:#ffffff;}
.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;}
.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;}
.resourcesBanner ul li:hover ul.resourcesType {display:block;}
ul li:hover ul {display:block;}
.resourcesUploadBox {float:right; width:103px; height:34px; background-color:#64bdd9; line-height:34px; vertical-align:middle; text-align:center; margin-left:12px;}
.uploadIcon {background:url(images/resource_icon_list.png) -35px 10px no-repeat; float:left; display:block; width:30px; height:30px; margin-left:-3px;}
a.uploadText {color:#ffffff; font-size:14px;}
.resourcesSearchloadBox {border:1px solid #e6e6e6; width:225px; float:right; background-color:#ffffff;}
.searchResource {border:none; outline:none; background-color:#ffffff; width:184px; height:32px; padding-left:10px; display:block; float:left;}
.searchIcon{width:31px; height:32px; background-color:#ffffff; background:url(images/resource_icon_list.png) -40px -15px no-repeat; display:block; float:left;}
.resourcesSearchBanner {height:34px; margin-bottom:10px;}
.resourcesListTab {width:730px; height:40px; background-color:#f6f6f6; border-bottom:1px solid #eaeaea; font-size:14px; color:#7a7a7a;}
.resourcesListCheckbox {width:40px; height:40px; line-height:40px; text-align:center; vertical-align:middle;}
.resourcesCheckbox {padding:0px; margin:0px; margin-top:14px; width:12px; height:12px;}
.resourcesListName {width:135px; height:40px; line-height:40px; text-align:left;}
.resourcesListSize {width:110px; height:40px; line-height:40px; text-align:center;}
.resourcesListType {width:150px; height:40px; line-height:40px; text-align:center;}
.resourcesListUploader {width:130px; height:40px; line-height:40px; text-align:center;}
.resourcesListTime {width:165px; height:40px; line-height:40px; text-align:center;}
.resourcesList {width:730px; height:39px; background-color:#ffffff; border-bottom:1px dashed #eaeaea; color:#9a9a9a; font-size:12px;}
a.resourcesBlack {font-size:12px; color:#4c4c4c;}
a.resourcesBlack:hover {font-size:12px; color:#000000;}
.dropdown-menu {
position: absolute;
top: 100%;
left: 0;
z-index: 1000;
display: none;
float: left;
min-width: 80px;
padding: 5px 0;
margin: 2px 0 0;
font-size: 12px;
text-align: left;
background-color: #fff;
-webkit-background-clip: padding-box;
background-clip: padding-box;
border: 1px solid #ccc;
border-radius: 4px;
-webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, .175);
box-shadow: 0 6px 12px rgba(0, 0, 0, .175);
}
.dropdown-menu > li > a {
display: block;
padding: 3px 20px;
clear: both;
font-weight: normal;
line-height: 1.5;
color:#616060;
white-space: nowrap;
}
.dropdown-menu > li > a:hover{
color: #ffffff;
text-decoration: none;
background-color: #64bdd9;
outline:none;
}
/*发送资源弹窗*/
/*.resourceShareContainer {width:100%; height:100%; background:#666; filter:alpha(opacity=50); opacity:0.5; -moz-opacity:0.5; position:absolute; left:0; top:0; z-index:-999;}*/
.resourceSharePopup {width:300px; height:auto; border:3px solid #15bccf; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-150px; z-index:1000;}
.sendText {font-size:16px; color:#15bccf; line-height:16px; padding-top:20px; width:140px; display:inline-block;}
.resourcePopupClose {width:20px; height:20px; display:inline-block; float:right;}
.resourceClose {background:url(images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block;}
.resourcesSearchBox {border:1px solid #e6e6e6; width:225px; height:25px; background-color:#ffffff; margin-top:12px; margin-bottom:15px;}
.searchResourcePopup {border:none; outline:none; background-color:#ffffff; width:184px; height:25px; padding-left:10px; display:inline-block; float:left;}
.searchIconPopup{width:31px; height:25px; background-color:#ffffff; background:url(images/resource_icon_list.png) -40px -18px no-repeat; display:inline-block; float:left;}
.courseSend {width:260px; height:15px; line-height:15px; margin-bottom:10px;}
.courseSendCheckbox {padding:0px; margin:0px; width:12px; height:12px; margin-right:10px; display:inline-block; margin-top:2px;}
.sendCourseName {font-size:12px; color:#5f6060;}
.courseSendSubmit {width:50px; height:25px; line-height:25px; text-align:center; vertical-align:middle; background-color:#64bdd9; margin-right:25px; float:left;}
.courseSendCancel {width:50px; height:25px; line-height:25px; text-align:center; vertical-align:middle; background-color:#c1c1c1; float:left}
a.sendSourceText {font-size:14px; color:#ffffff;}
/*上传资源弹窗*/
.resourceUploadPopup {width:400px; height:auto; border:3px solid #15bccf; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-200px; z-index:1000;}
.uploadText {font-size:16px; color:#15bccf; line-height:16px; padding-top:20px; width:140px; display:inline-block;}
.uploadBoxContainer {height:33px; line-height:33px; margin-top:10px; position:relative;}
.uploadBox {width:100px; height:33px; line-height:33px; text-align:center; vertical-align:middle; background-color:#64bdd9; border-radius:3px; float:left; margin-right:12px;}
a.uploadIcon {background:url(images/resource_icon_list.png) 8px -60px no-repeat; width:100px; height:33px;}
.chooseFile {color:#ffffff; display:block; margin-left:32px;}
.uploadResourceIntr {width:250px; height:33px; float:left; line-height:33px; font-size:12px;}
.uploadResourceName {width:250px; display:inline-block; line-height:15px; font-size:12px; color:#444444; margin-bottom:2px;}
.uploadResourceIntr2 {width:250px; display:inline-block; line-height:15px; font-size:12px; color:#444444;}
.uploadType {margin:10px 0; border:1px solid #e6e6e6; width:100px; height:30px; outline:none; font-size:12px; color:#888888;}
.uploadKeyword {margin-bottom:10px; outline:none; border:1px solid #e6e6e6; height:30px; width:280px;}
/*新个人主页框架css*/
.navContainer {width:100%; margin:0 auto; background-color:#15bccf;}
.homepageContentContainer {width:100%; margin:0 auto; background-color:#eaebed;}
.homepageContent {width:1000px; background-color:#eaebed; margin:0 auto;}
.navHomepage {width:1000px; height:54px; background-color:#15bccf; margin:0 auto;}
.navHomepageLogo {width:60px; height:54px; line-height:54px; vertical-align:middle; margin-left:2px; margin-right:40px;}
.navHomepageMenu {margin-right:40px;display:inline-block;height:54px; line-height:54px; vertical-align:middle;}
.navHomepageSearchBox {width:380px; border:none; outline:none; height:32px; margin-top:11px; background-color:#ffffff;}
.navHomepageSearchInput {width:345px; height:32px; outline:none; border:none; float:left; padding-left:5px;; margin:0;}
.homepageSearchIcon {width:30px; height:32px; background:url(../images/nav_icon.png) -8px 3px no-repeat; float:left;}
a.homepageSearchIcon:hover {background:url(../images/nav_icon.png) -49px 3px no-repeat;}
.navHomepageNews {width:30px; display:block; float:right; margin-top:12px; position:relative;}
.homepageNewsIcon {background:url(../images/nav_icon.png) -5px -85px no-repeat; width:30px; height:29px; display:block;}
.newsActive {width:10px; height:10px; border-radius:50%; border:2px solid #ffffff; background-color:#ff0000; position:absolute; left:17px; top:5px;}
.navHomepageProfile {width:65px; display:block; float:right; margin-top:8px; margin-left:33px;}
.homepageProfileMenuIcon {background:url(../images/nav_icon.png) -8px -175px no-repeat; width:20px; height:25px; float:left; margin-top:15px;}
a.homepageProfileMenuIcon:hover {background:url(../images/nav_icon.png) -8px -175px no-repeat; width:12px; height:12px; float:left;}
.homepageLeft {width:240px; float:left; margin-right:10px;}
.homepageRight {width:750px; float:left;}
.homepagePortraitContainer {width:238px; height:348px; border:1px solid #dddddd; background-color:#ffffff; margin-top:15px;}
.homepagePortraitImage {width:208px; height:208px; margin:15px 16px 14px 16px;}
.homepageFollow {}
.homepageEditProfile {}
.homepageImageName {font-size:16px; color:#484848; margin-left:15px; display:inline-block; margin-right:8px;}
.homepageImageSex {float:left; top:116px; left:5px; width:14px; height:14px; display:inline-block;}
.homepageSignature {font-size:12px; color:#888888; margin-left:15px; margin-top:5px; margin-bottom:15px;}
.homepageImageBlock {margin:0 26px; float:left; text-align:center; display:inline-block;}
.homepageImageNumber {font-size:12px; color:#484848;}
.homepageImageText {width:26px; font-size:12px; color:#888888;}
.homepageVerDiv {height:28px; vertical-align:middle; width:1px; float:left; display:inline-block; background-color:#d1d1d1; margin-top:3px;}
.homepageLeftMenuContainer {width:238px; border:1px solid #dddddd; border-bottom:none; background-color:#ffffff; margin-top:10px;}
.homepageLeftMenuBlock {border-bottom:1px solid #dddddd; height:50px; line-height:50px; vertical-align:middle;}
a.homepageMenuText {color:#484848; font-size:16px; margin-left:20px;}
.homepageLeftLabelContainer {width:238px; border:1px solid #dddddd; background-color:#ffffff; margin-top:10px;}
.homepageRightBanner {}
.newsType {width:60px; background-color:#ffffff; float:left; list-style:none; position:absolute; border:1px solid #eaeaea; border-radius:5px; top:35px; padding:5px 10px; left:-40px; font-size:12px; color:#888888; display:none; line-height:2;}
.homepageRightBlock {}
.homepageNewsList {width:710px; height:39px; line-height:39px; vertical-align:middle; border-bottom:1px dashed #eaeaea; margin:0 auto;}
.homepageNewsPortrait {width:40px; display:block; margin-top:7px;}
.homepageNewsPublisher {width:95px; font-size:12px; color:#15bccf; display:block;}
.homepageNewsType {width:95px; font-size:12px; color:#888888; display:block;}
.homepageNewsContent {width:405px; font-size:12px; color:#4b4b4b; display:block;}
.homepageNewsTime {width:75px; font-size:12px; color:#888888; display:block; text-align:right;}
a.homepageWhite {color:#ffffff;}
a.homepageWhite:hover {color:#a1ebff}
a.newsGrey {color:#4b4b4b;}
a.newsGrey:hover {color:#000000;}
a.newsBlue {color:#15bccf;}
a.newsBlue:hover {color:#0781b4;}
a.resourcesGrey {font-size:12px; color:#888888;}
a.resourcesGrey:hover {font-size:12px; color:#15bccf;}
/***** Flash & error messages ****/
#errorExplanation, div.flash, .nodata, .warning, .conflict {
padding: 4px 4px 4px 30px;
margin-bottom: 12px;
font-size: 1.1em;
border: 2px solid;
}
div.flash {margin-top: 8px;}
div.flash.error, #errorExplanation {
background: url(../images/exclamation.png) 8px 50% no-repeat;
background-color: #ffe3e3;
border-color: #dd0000;
color: #880000;
}
div.flash.notice {
background: url(../images/true.png) 8px 5px no-repeat;
background-color: #dfffdf;
border-color: #9fcf9f;
color: #005f00;
}
div.flash.warning, .conflict {
background: url(../images/warning.png) 8px 5px no-repeat;
background-color: #FFEBC1;
border-color: #FDBF3B;
color: #A6750C;
text-align: left;
}
.nodata, .warning {
text-align: center;
background-color: #FFEBC1;
border-color: #FDBF3B;
color: #A6750C;
}
#errorExplanation ul { font-size: 0.9em;}
#errorExplanation h2, #errorExplanation p { display: none; }
.conflict-details {font-size:80%;}
/***** end Flash & error messages ****/
/*消息铃铛样式*/
.navHomepageNews {width:30px; display:block; float:right; margin-top:4px; position:relative; margin-right: 8px;}
.newsActive {width:6px; height:6px; border-radius:50%; border:2px solid #ffffff; background-color:#ff0000; position:absolute; left:20px; top:8px;z-index:999}

View File

@ -0,0 +1,10 @@
FactoryGirl.define do
factory :course_message do
user_id 1
course_id 1
course_message_id 1
course_message_type "MyString"
viewed 1
end
end

View File

@ -0,0 +1,10 @@
FactoryGirl.define do
factory :forge_message do
user_id 1
project_id 1
forge_message_id 1
forge_message_type "MyString"
viewed 1
end
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe CourseMessage, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe ForgeMessage, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end