Merge branch 'dev_hjq' of http://repository.trustie.net/xianbo/trustie2 into dev_hjq

This commit is contained in:
ouyangxuhua 2015-08-25 10:20:39 +08:00
commit 354cb52339
12 changed files with 359 additions and 49 deletions

View File

@ -45,14 +45,14 @@ class UsersController < ApplicationController
: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_resource,:user_resource_create,:user_resource_delete,:rename_resource,:search_user_course,:add_exist_file_to_course,
:search_user_project,:resource_preview,:resource_search,:add_exist_file_to_project,:user_messages]
:search_user_project,:resource_preview,:resource_search,:add_exist_file_to_project,:user_messages, :user_messages_new]
#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_resource,
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction]
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction, :user_messages_new]
before_filter :auth_user_extension, only: :show
#before_filter :rest_user_score, only: :show
#before_filter :select_entry, only: :user_projects
@ -122,6 +122,7 @@ class UsersController < ApplicationController
@new_message_count = @user.forge_messages.count + @user.memo_messages.count + @user.course_messages.count + @user.user_feedback_messages.count
case params[:type]
when nil
@all_message = MessageAll.where("user_id =?",@user).order("created_at desc")
@user_course_messages = CourseMessage.where("user_id =?",@user).order("created_at desc")
@user_forge_messages = ForgeMessage.where("user_id =?",@user).order("created_at desc")
@user_memo_messages = MemoMessage.where("user_id =?",@user).order("created_at desc")
@ -181,6 +182,78 @@ class UsersController < ApplicationController
end
end
def user_messages_new
unless User.current.logged?
render_403
return
end
# 当前用户查看消息,则设置消息为已读
course_querys = @user.course_messages
forge_querys = @user.forge_messages
user_querys = @user.user_feedback_messages
forum_querys = @user.memo_messages
# if User.current.id == @user.id
# course_querys.update_all(:viewed => true)
# forge_querys.update_all(:viewed => true)
# user_querys.update_all(:viewed => true)
# forum_querys.update_all(:viewed => true)
# end
@new_message_count = @user.forge_messages.count + @user.memo_messages.count + @user.course_messages.count + @user.user_feedback_messages.count
case params[:type]
when nil
@user_message_all = MessageAll.where("user_id =?", @user).order("created_at desc")
@user_message_all_count = @user_message_all.count
when 'homework'
@user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "HomeworkCommon", @user).order("created_at desc")
@user_course_messages_count = @user_course_messages.count
when 'course_message'
@user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "Message", @user).order("created_at desc")
@user_course_messages_count = @user_course_messages.count
when 'forge_message'
@user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Message", @user).order("created_at desc")
@user_forge_messages_count = @user_forge_messages.count
when 'course_news'
@user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "News", @user).order("created_at desc")
@user_course_messages_count = @user_course_messages.count
when 'forge_news'
@user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "News", @user).order("created_at desc")
@user_forge_messages_count = @user_forge_messages.count
when 'course_news_reply'
@user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "Comment", @user).order("created_at desc")
@user_course_messages_count = @user_course_messages.count
when 'forge_news_reply'
@user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Comment", @user).order("created_at desc")
@user_forge_messagess_count = @user_forge_messages.count
when 'poll'
@user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "Poll", @user).order("created_at desc")
@user_course_messages_count = @user_course_messages.count
when 'works_reviewers'
@user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "StudentWorksScore", @user).order("created_at desc")
@user_course_messages_count = @user_course_messages.count
when 'works_reply'
@user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "JournalsForMessage", @user).order("created_at desc")
@user_course_messages_count = @user_course_messages.count
when 'issue'
@user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Issue", @user).order("created_at desc")
@user_forge_messages_count = @user_forge_messages.count
when 'issue_update' # 缺陷状态更新、留言
@user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Journal", @user).order("created_at desc")
@user_forge_messages_count = @user_forge_messages.count
when 'forum'
@user_memo_messages = MemoMessage.where("memo_type =? and user_id =?", "Memo", @user).order("created_at desc")
@user_memo_messages_count = @user_memo_messages.count
when 'user_feedback'
@user_feedback_messages = UserFeedbackMessage.where("journals_for_message_type =? and user_id =?", "JournalsForMessage", @user).order("created_at desc")
@user_feedback_messages_count = @user_feedback_messages.count
else
render_404
return
end
respond_to do |format|
format.html{render :layout=>'new_base_user'}
end
end
def user_projects_index
if User.current.admin?
memberships = @user.memberships.all(conditions: "projects.project_type = #{Project::ProjectType_project}").first

View File

@ -5,8 +5,15 @@ class CourseMessage < ActiveRecord::Base
belongs_to :course_message ,:polymorphic => true
belongs_to :course
belongs_to :user
has_many :message_alls, :class_name => 'MessageAll',:as =>:message, :dependent => :destroy
validates :user_id,presence: true
validates :course_id,presence: true
validates :course_message_id,presence: true
validates :course_message_type, presence: true
after_create :add_user_message
def add_user_message
self.message_alls << MessageAll.new(:user_id => self.user_id)
end
end

View File

@ -13,24 +13,15 @@ class ForgeMessage < ActiveRecord::Base
belongs_to :forge_message ,:polymorphic => true
belongs_to :project
belongs_to :user
has_many :message_alls, :class_name => 'MessageAll',:as =>:message
has_many :message_alls, :class_name => 'MessageAll',:as =>:message, :dependent => :destroy
validates :user_id,presence: true
validates :project_id,presence: true
validates :forge_message_id,presence: true
validates :forge_message_type, presence: true
after_save :add_user_activity
after_create :add_user_message
def add_user_activity
message_all = MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first
if message_all
message_all.save
else
message_all = MessageAll.new
message_all.message_id = self.id
message_all.message_type = self.class.to_s
message_all.container_type = "Project"
message_all.container_id = self.project_id
message_all.save
end
def add_user_message
self.message_alls << MessageAll.new(:user_id => self.user_id)
end
end

View File

@ -79,7 +79,7 @@ class Memo < ActiveRecord::Base
receivers << self.forum.creator
end
# 添加发帖人
if self.forum.creator_id != self.parent.author_id
if self.author_id != self.parent.author_id
receivers << self.parent.author
end
end

View File

@ -3,9 +3,15 @@ class MemoMessage < ActiveRecord::Base
belongs_to :memo
belongs_to :user
has_many :message_alls, :class_name => 'MessageAll',:as =>:message, :dependent => :destroy
validates :user_id,presence: true
validates :forum_id,presence: true
validates :memo_id,presence: true
validates :memo_type, presence: true
after_create :add_user_message
def add_user_message
self.message_alls << MessageAll.new(:user_id => self.user_id)
end
end

View File

@ -1,7 +1,5 @@
class MessageAll < ActiveRecord::Base
attr_accessible :container_id, :container_type, :message_id, :message_type
attr_accessible :message_id, :message_type, :user_id
# 虚拟关联---项目消息表/课程消息表/用户留言消息表/贴吧消息表
belongs_to :message ,:polymorphic => true
# 虚拟关联---项目/课程
belongs_to :container ,:polymorphic => true
end

View File

@ -3,8 +3,14 @@ class UserFeedbackMessage < ActiveRecord::Base
belongs_to :journals_for_message
belongs_to :user
has_many :message_alls, :class_name => 'MessageAll',:as =>:message, :dependent => :destroy
validates :user_id,presence: true
validates :journals_for_message_id,presence: true
validates :journals_for_message_type, presence: true
after_create :add_user_message
def add_user_message
self.message_alls << MessageAll.new(:user_id => self.user_id)
end
end

View File

@ -0,0 +1,233 @@
<div class="homepageRight">
<div class="resources">
<div class="homepageRightBanner">
<div class="NewsBannerName">消息</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"><%= link_to "作业消息",{:controller=> 'users', :action => 'user_messages_new', 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_new', id: User.current.id, host: Setting.host_user, :type => 'course_message'} %></a></li>
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "课程通知",{:controller=> 'users', :action => 'user_messages_new', id: User.current.id, host: Setting.host_user, :type => 'course_news'} %></a></li>
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "通知回复",{:controller=> 'users', :action => 'user_messages_new', id: User.current.id, host: Setting.host_user, :type => 'course_news_reply'} %></a></li>
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "课程问卷",{:controller=> 'users', :action => 'user_messages_new', id: User.current.id, host: Setting.host_user, :type => 'poll'} %></a></li>
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "作品评阅",{:controller=> 'users', :action => 'user_messages_new', id: User.current.id, host: Setting.host_user, :type => 'works_reviewers'} %></a></li>
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "作品讨论",{:controller=> 'users', :action => 'user_messages_new', id: User.current.id, host: Setting.host_user, :type => 'works_reply'} %></a></li>
<%# 项目相关消息 %>
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "指派给我",{:controller=> 'users', :action => 'user_messages_new', id: User.current.id, host: Setting.host_user, :type => 'issue'} %></a></li>
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "更新了问题",{:controller=> 'users', :action => 'user_messages_new', id: User.current.id, host: Setting.host_user, :type => 'issue_update'} %></a></li>
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "项目讨论区",{:controller=> 'users', :action => 'user_messages_new', id: User.current.id, host: Setting.host_user, :type => 'forge_message'} %></a></li>
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "项目新闻",{:controller=> 'users', :action => 'user_messages_new', id: User.current.id, host: Setting.host_user, :type => 'forge_news'} %></a></li>
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "新闻回复",{:controller=> 'users', :action => 'user_messages_new', id: User.current.id, host: Setting.host_user, :type => 'forge_news_reply'} %></a></li>
<%# 项目相关消息 %>
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "贴吧帖子",{:controller=> 'users', :action => 'user_messages_new', id: User.current.id, host: Setting.host_user, :type => 'forum'} %></a></li>
<%# 系统贴吧 %>
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "用户留言",{:controller=> 'users', :action => 'user_messages_new', id: User.current.id, host: Setting.host_user, :type => 'user_feedback'} %></a></li>
</ul>
</li>
</ul>
</div>
<% if params[:type].nil? %>
<div class="newsReadSetting">
有&nbsp;<span class="c_red">8</span>&nbsp;封未读<a href="javascript:void(0);" class="ml15">全部设为已读</a>
</div>
<% end %>
<div>
<% if @new_message_count >0 %>
<%# 课程消息 %>
<% unless @user_message_all.nil? %>
<% @user_message_all.each do |uma| %>
<% if uma.message.course_message_type == "News" %>
<ul class="homepageNewsList fl">
<li class="homepageNewsPortrait fl"><a href="javascript:void(0);"><%= image_tag(url_to_avatar(uma.message.course_message.author), :width => "30", :height => "30") %></a></li>
<li class="homepageNewsPublisher fl"><%=link_to uma.message.course_message.author, user_path(uma.message.course_message.author), :class => "newsBlue" %></li>
<li class="<%= ucm.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>">发布通知</li>
<li class="homepageNewsContent fl">
<%= link_to uma.message.course_message.title, {:controller => 'news', :action => 'show', :id => uma.message.course_message.id },
:class =>"#{uma.message.viewed == 0 ? "newsBlack" : "newsGrey"}",
:title => "#{uma.message.course_message.title}" %></li>
<li class="homepageNewsTime fl"><%= time_tag(uma.message.course_message.created_on).html_safe %> </li>
</ul>
<% end %>
<% if uma.message.course_message_type == "Comment" %>
<ul class="homepageNewsList fl">
<li class="homepageNewsPortrait fl"><a href="javascript:void(0);"><%= image_tag(url_to_avatar(uma.message.course_message.author), :width => "30", :height => "30") %></a></li>
<li class="homepageNewsPublisher fl"><%=link_to uma.message.course_message.author, user_path(uma.message.course_message.author), :class => "newsBlue" %></li>
<li class="<%= ucm.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>">回复了通知</li>
<li class="homepageNewsContent fl">
<%= link_to uma.message.course_message.comments.html_safe, {:controller => 'news', :action => 'show', :id => uma.message.course_message.commented.id },
:class =>"#{uma.message.viewed == 0 ? "newsBlack" : "newsGrey"}",
:title => "#{uma.message.course_message.comments.html_safe}" %></li>
<li class="homepageNewsTime fl"><%= time_tag(uma.message.course_message.created_on).html_safe %> </li>
</ul>
<% end %>
<% if uma.message.course_message_type == "HomeworkCommon" %>
<ul class="homepageNewsList fl">
<li class="homepageNewsPortrait fl"><a href="javascript:void(0);"><%= image_tag(url_to_avatar(uma.message.course_message.user), :width => "30", :height => "30") %></a></li>
<li class="homepageNewsPublisher fl"><%=link_to uma.message.course_message.user, user_path(uma.message.course_message.user), :class => "newsBlue" %></a></li>
<li class="homepageNewsType fl">发布作业</li>
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
<%= link_to uma.message.course_message.name, student_work_index_path(:homework => uma.message.course_message.id),:class => "newsGrey", :title => "#{uma.message.course_message.name}" %></a></li>
<li class="homepageNewsTime fl"><%= time_tag(uma.message.course_message.created_at).html_safe %> </li>
</ul>
<% end %>
<% if uma.message.course_message_type == "Poll" %>
<ul class="homepageNewsList fl">
<li class="homepageNewsPortrait fl"><a href="javascript:void(0);"><%= image_tag(url_to_avatar(uma.message.course_message.user), :width => "30", :height => "30") %></a></li>
<li class="homepageNewsPublisher fl"><%=link_to uma.message.course_message.user, user_path(uma.message.course_message.user), :class => "newsBlue" %></a></li>
<li class="<%= uma.message.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>">发布问卷</li>
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
<%= link_to format_activity_title(" #{uma.message.course_message.polls_name.nil? ? "未命名问卷" : uma.message.course_message.polls_name}"), poll_index_path(:polls_type => "Course", :polls_group_id => uma.message.course_id),
:class=>"#{uma.message.viewed==0?"newsBlack":"newsGrey"}",
:title => "#{uma.message.course_message.polls_name}" %></a></li>
<li class="homepageNewsTime fl"><%= time_tag(uma.message.course_message.created_at).html_safe %> </li>
</ul>
<% end %>
<% if uma.message.course_message_type == "Message" %>
<ul class="homepageNewsList fl">
<li class="homepageNewsPortrait fl"><a href="javascript:void(0);"><%= image_tag(url_to_avatar(uma.message.course_message.author), :width => "30", :height => "30") %></a></li>
<li class="homepageNewsPublisher fl"><%=link_to uma.message.course_message.author, user_path(uma.message.course_message.author), :class => "newsBlue" %></li>
<% if uma.message.course_message.parent_id.nil? %>
<li class="<%= uma.message.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>">发布帖子</li>
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
<%=link_to uma.message.course_message.subject.html_safe, course_boards_path(uma.message.course_message.course,:parent_id => uma.message.course_message.parent_id ? uma.message.course_message.parent_id : uma.message.course_message.id,
:topic_id => uma.message.course_message.id),:class=>"#{uma.message.viewed==0?"newsBlack":"newsGrey"}",
:title => "#{uma.message.course_message.subject.html_safe}" %></a></li>
<li class="homepageNewsTime fl"><%= time_tag(uma.message.course_message.created_on).html_safe %> </li>
<% else %>
<li class="<%= uma.message.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>">回复帖子</li>
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
<%=link_to uma.message.course_message.subject.html_safe, course_boards_path(uma.message.course_message.course,:parent_id => uma.message.course_message.parent_id ? uma.message.course_message.parent_id : uma.message.course_message.id,
:topic_id => uma.message.course_message.id),:class=>"#{uma.message.viewed==0?"newsBlack":"newsGrey"}",
:title => "#{uma.message.course_message.subject.html_safe}" %> </a></li>
<li class="homepageNewsTime fl"><%= time_tag(uma.message.course_message.created_on).html_safe %> </li>
<% end %>
</ul>
<% end %>
<% if uma.message.course_message_type == "StudentWorksScore" %>
<ul class="homepageNewsList fl">
<li class="homepageNewsPortrait fl"><a href="javascript:void(0);"><%= image_tag(url_to_avatar(uma.message.course_message.user), :width => "30", :height => "30") %></a></li>
<li class="homepageNewsPublisher fl"><%=link_to uma.message.course_message.user, user_path(uma.message.course_message.user), :class => "newsBlue" %></li>
<li class="homepageNewsType fl">评阅了作品</li>
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
<%= link_to "#{uma.message.course_message.comment.nil? ? "分数:"+uma.message.course_message.score.to_s : "分数:"+uma.message.course_message.score.to_s + "----" + "评语:" + uma.message.course_message.comment}", student_work_index_path(:homework => uma.message.course_message.student_work.homework_common_id),:class=>"newsGrey",:title => "#{uma.message.course_message.comment}" %></a></li>
<li class="homepageNewsTime fl"><%= time_tag(uma.message.course_message.created_at).html_safe %> </li>
</ul>
<% end %>
<% if uma.message.course_message_type == "JournalsForMessage" %>
<ul class="homepageNewsList fl">
<li class="homepageNewsPortrait fl"><a href="javascript:void(0);"><%= image_tag(url_to_avatar(uma.message.course_message.user), :width => "30", :height => "30") %></a></li>
<li class="homepageNewsPublisher fl"><%=link_to uma.message.course_message.user, user_path(uma.message.course_message.user), :class => "newsBlue" %></li>
<li class="homepageNewsType fl">回复了作品</li>
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
<%= link_to uma.message.course_message.notes, student_work_index_path(:homework => uma.message.course_message.jour.student_work.homework_common_id),:class=>"newsGrey",:title => "#{uma.message.course_message.notes}" %></a></li>
<li class="homepageNewsTime fl"><%= time_tag(uma.message.course_message.created_on).html_safe %> </li>
</ul>
<% end %>
<% if uma.message.forge_message_type == "Issue" %>
<ul class="homepageNewsList fl">
<li class="homepageNewsPortrait fl">
<a href="javascript:void(0);"><%= image_tag(url_to_avatar(uma.message.forge_message.author), :width => "30", :height => "30") %></a>
</li>
<li class="homepageNewsPublisher fl">
<%=link_to uma.message.forge_message.author, user_path(uma.message.forge_message.author), :class => "newsBlue" %>
</li>
<li class="<%= uma.message.viewed == 0 ? "homepageNewsTypeNotRead fl" : "homepageNewsType fl" %>">指派问题给我</li>
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
<%= link_to uma.message.forge_message.subject.html_safe, issue_path(:id => uma.message.forge_message.id), :class => "#{uma.message.viewed == 0 ? "newsBlack" : "newsGrey"}",:title => "#{uma.message.forge_message.subject.html_safe}" %></a>
</li>
<li class="homepageNewsTime fl"><%= time_tag(uma.message.forge_message.created_on).html_safe %> </li>
</ul>
<% end %>
<% if uma.message.forge_message_type == "Journal" %>
<ul class="homepageNewsList fl">
<li class="homepageNewsPortrait fl">
<a href="javascript:void(0);"><%= image_tag(url_to_avatar(uma.message.forge_message.user), :width => "30", :height => "30") %></a>
</li>
<li class="homepageNewsPublisher fl">
<%=link_to uma.message.forge_message.user, user_path(uma.message.forge_message.user), :class => "newsBlue" %>
</li>
<li class="<%= uma.message.viewed == 0 ? "homepageNewsTypeNotRead fl" : "homepageNewsType fl" %>">
更新了问题
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
<%= link_to get_issue_des_update(uma.message.forge_message),
issue_path(:id => uma.message.forge_message.journalized_id), :class => "#{uma.message.viewed == 0 ? "newsBlack" : "newsGrey"}",
:title => "#{get_issue_des_update(uma.message.forge_message)}" %></a>
</li>
<li class="homepageNewsTime fl"><%= time_tag(uma.message.forge_message.created_on).html_safe %> </li>
</ul>
<% end %>
<% if uma.message.forge_message_type == "Message" %>
<ul class="homepageNewsList fl">
<li class="homepageNewsPortrait fl"><a href="javascript:void(0);"><%= image_tag(url_to_avatar(uma.message.forge_message.author), :width => "30", :height => "30") %></a></li>
<li class="homepageNewsPublisher fl"><%=link_to uma.message.forge_message.author, user_path(uma.message.forge_message.author), :class => "newsBlue" %></li>
<li class="<%= uma.message.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>"><%= uma.message.forge_message.parent_id.nil? ? "发布帖子" : "回复帖子" %></li>
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
<%=link_to uma.message.forge_message.subject.html_safe, project_boards_path(uma.message.forge_message.project,
:parent_id => uma.message.forge_message.parent_id ? uma.message.forge_message.parent_id : uma.message.forge_message.id,
:topic_id => uma.message.forge_message.id),:class=>"#{uma.message.viewed==0?"newsBlack":"newsGrey"}",
:title => "#{uma.message.forge_message.subject.html_safe}" %></a></li>
<li class="homepageNewsTime fl"><%= time_tag(uma.message.forge_message.created_on).html_safe %> </li>
</ul>
<% end %>
<% if uma.message.forge_message_type == "News" %>
<ul class="homepageNewsList fl">
<li class="homepageNewsPortrait fl">
<a href="javascript:void(0);"><%= image_tag(url_to_avatar(uma.message.forge_message.author), :width => "30", :height => "30") %></a>
</li>
<li class="homepageNewsPublisher fl">
<%=link_to uma.message.forge_message.author, user_path(uma.message.forge_message.author), :class => "newsBlue" %>
</li>
<li class="homepageNewsType fl">发布新闻</li>
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
<%= link_to ("#{uma.message.forge_message.title.html_safe}"), {:controller => 'news', :action => 'show', :id => uma.message.forge_message.id}, :class => "newsGrey", :title => "#{uma.message.forge_message.title.html_safe}" %></a>
</li>
<li class="homepageNewsTime fl"><%= time_tag(uma.message.forge_message.created_on).html_safe %> </li>
</ul>
<% end %>
<% if uma.message.forge_message_type == "Comment" %>
<ul class="homepageNewsList fl">
<li class="homepageNewsPortrait fl"><a href="javascript:void(0);"><%= image_tag(url_to_avatar(uma.message.forge_message.author), :width => "30", :height => "30") %></a></li>
<li class="homepageNewsPublisher fl"><%=link_to uma.message.forge_message.author, user_path(uma.message.forge_message.author), :class => "newsBlue" %></li>
<li class="homepageNewsType fl">回复了新闻</li>
<li class="homepageNewsContent fl">
<%= link_to "#{uma.message.forge_message.comments.html_safe}",
{:controller => 'news', :action => 'show', :id => uma.message.forge_message.commented.id },:class =>"#{uma.message.viewed == 0 ? "newsBlack" : "newsGrey"}", :title => "#{uma.message.forge_message.comments.html_safe}"%></li>
<li class="homepageNewsTime fl"><%= time_tag(uma.message.forge_message.created_on).html_safe %> </li>
</ul>
<% end %>
<% end %>
<% end %>
<!--项目消息-->
<%# 公共贴吧 %>
<%# 用户留言消息 %>
<% else %>
<div class="flash notice">暂无消息!</div>
<% end %>
<div class="cl"></div>
</div>
</div>
</div>

View File

@ -364,7 +364,10 @@ 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, :as => "user_message"
match 'users/:id/user_messages_new', :to => 'users#user_messages_new', :via => :get, :as => "user_messages_new"
#match 'users/:id/user_messages/:homework', :to => 'users#user_messages_homework', :via => :get, :as => "user_message_homewrok"

View File

@ -1,10 +1,9 @@
class CreateMessageAlls < ActiveRecord::Migration
def change
create_table :message_alls do |t|
t.string :message_type
t.integer :user_id
t.integer :message_id
t.string :container_type
t.integer :container_id
t.string :message_type
t.timestamps
end

View File

@ -11,15 +11,14 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20150824092300) do
ActiveRecord::Schema.define(:version => 20150824133916) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
t.string "act_type", :null => false
t.integer "user_id", :null => false
t.integer "activity_container_id"
t.string "activity_container_type", :default => ""
t.datetime "created_at"
t.integer "act_id", :null => false
t.string "act_type", :null => false
t.integer "user_id", :null => false
t.integer "activity_container_id"
t.string "activity_container_type", :default => ""
end
add_index "activities", ["act_id", "act_type"], :name => "index_activities_on_act_id_and_act_type"
@ -572,16 +571,6 @@ ActiveRecord::Schema.define(:version => 20150824092300) do
t.datetime "updated_at", :null => false
end
create_table "forum_messages", :force => true do |t|
t.integer "user_id"
t.integer "forum_id"
t.integer "memo_message_id"
t.string "memo_message_type"
t.integer "viewed"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "forums", :force => true do |t|
t.string "name", :null => false
t.text "description"
@ -885,12 +874,19 @@ ActiveRecord::Schema.define(:version => 20150824092300) do
end
create_table "message_alls", :force => true do |t|
t.string "message_type"
t.integer "user_id"
t.integer "message_id"
t.string "container_type"
t.integer "container_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "message_type"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "message_publics", :force => true do |t|
t.integer "message_id"
t.string "massage_type"
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "messages", :force => true do |t|
@ -1543,7 +1539,6 @@ ActiveRecord::Schema.define(:version => 20150824092300) 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"

View File

@ -1,9 +1,8 @@
FactoryGirl.define do
factory :message_all do
message_type "MyString"
user_id 1
message_id 1
container_type "MyString"
container_id 1
message_type "MyString"
end
end