From 239cba54d9c6dc554632598212f1a52f9092f611 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 17 Aug 2015 11:34:29 +0800 Subject: [PATCH 01/51] =?UTF-8?q?=E5=8C=BA=E5=88=86=E6=9C=AA=E8=AF=BB?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=92=8C=E5=B7=B2=E8=AF=BB=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 6 +++--- app/views/users/user_messages.html.erb | 4 ++-- public/stylesheets/public_new.css | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 969d2d366..3d5f613aa 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -104,9 +104,9 @@ class UsersController < ApplicationController end # 当前用户查看消息,则设置消息为已读 querys = @user.course_messages - if User.current.id == @user.id - querys.update_all(:viewed => true) - end + # 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.reverse diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index cf3e13ff9..89bc45397 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -26,8 +26,8 @@
  • <%= image_tag(url_to_avatar(ucm.course_message.author), :width => "30", :height => "30") %>
  • <%= ucm.course_message.author %>
  • 发布通知
  • -
  • - <%= link_to format_activity_title(" #{ucm.course_message.title}"), {:controller => 'news', :action => 'show', :id => ucm.course_message.id} %>
  • +
  • + <%= link_to "#{ucm.course_message.title}", {:controller => 'news', :action => 'show', :id => ucm.course_message.id },:class =>"#{ucm.viewed == 0 ? "newsBlue" : "newsGrey"}" %>
  • <%= time_tag(ucm.course_message.created_on).html_safe %>
  • <% end %> diff --git a/public/stylesheets/public_new.css b/public/stylesheets/public_new.css index 83e8189b3..90521e067 100644 --- a/public/stylesheets/public_new.css +++ b/public/stylesheets/public_new.css @@ -587,9 +587,9 @@ a.homepageMenuText {color:#484848; font-size:16px; margin-left:20px;} .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;} +.homepageNewsPublisher {width:80px; max-width:80px; margin-right:10px; font-size:12px; color:#15bccf; display:block; padding-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; } .homepageNewsType {width:95px; font-size:12px; color:#888888; display:block;} -.homepageNewsContent {width:405px; font-size:12px; color:#4b4b4b; display:block;} +.homepageNewsContent {width:395px; max-width:395px; margin-right:10px; font-size:12px; color:#4b4b4b; display:block; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; } .homepageNewsTime {width:75px; font-size:12px; color:#888888; display:block; text-align:right;} a.homepageWhite {color:#ffffff;} a.homepageWhite:hover {color:#a1ebff} From e6cf2f400ca0047743337448694ff407cb56fc61 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Mon, 17 Aug 2015 11:35:47 +0800 Subject: [PATCH 02/51] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/stylesheets/public_new.css | 1 + 1 file changed, 1 insertion(+) diff --git a/public/stylesheets/public_new.css b/public/stylesheets/public_new.css index 452f2f853..31d599650 100644 --- a/public/stylesheets/public_new.css +++ b/public/stylesheets/public_new.css @@ -594,6 +594,7 @@ a.homepageMenuText {color:#484848; font-size:16px; margin-left:20px;} a.homepageWhite {color:#ffffff;} a.homepageWhite:hover {color:#a1ebff} a.newsGrey {color:#4b4b4b;} +a.newsBlack {color:black; font-weight:bold;} a.newsGrey:hover {color:#000000;} a.newsBlue {color:#15bccf;} a.newsBlue:hover {color:#0781b4;} From fda8c802fbcba8c5c16b53eccb0c25c0224de365 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Mon, 17 Aug 2015 12:47:15 +0800 Subject: [PATCH 03/51] =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_messages.html.erb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 89bc45397..09ddcdfa9 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -37,7 +37,7 @@
  • <%= ucm.course_message.user %>
  • 发布作业
  • - <%= link_to ("#{ucm.course_message.name}"), student_work_index_path(:homework => ucm.course_message.id) %>
  • + <%= link_to ("#{ucm.course_message.name}"), student_work_index_path(:homework => ucm.course_message.id),:class => "#{ucm.viewed == 0?"newsBlue":"newsGrey"}" %>
  • <%= time_tag(ucm.course_message.created_at).html_safe %>
  • <% end %> @@ -47,7 +47,7 @@
  • <%= ucm.course_message.user %>
  • 发布问卷
  • - <%= link_to format_activity_title(" #{ucm.course_message.polls_name}"), poll_index_path(:polls_type => "Course", :polls_group_id => ucm.course_id) %>
  • + <%= link_to format_activity_title(" #{ucm.course_message.polls_name}"), poll_index_path(:polls_type => "Course", :polls_group_id => ucm.course_id),:class=>"#{ucm.viewed==0?"newsBlue":"newsGrey"}" %>
  • <%= time_tag(ucm.course_message.created_at).html_safe %>
  • <% end %> @@ -58,12 +58,12 @@ <% if ucm.course_message.parent_id.nil? %>
  • 发布帖子
  • - <%=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) %>
  • + <%=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),:class=>"#{ucm.viewed==0?"newsBlue":"newsGrey"}" %>
  • <%= time_tag(ucm.course_message.created_on).html_safe %>
  • <% else %>
  • 回复帖子
  • - <%=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) %>
  • + <%=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),:class=>"#{ucm.viewed==0?"newsBlue":"newsGrey"}" %>
  • <%= time_tag(ucm.course_message.created_on).html_safe %>
  • <% end %> From fe077a27fbbbe32ebc61ee30e47ce3b1efb87eb8 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 17 Aug 2015 15:04:09 +0800 Subject: [PATCH 04/51] =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 3d5f613aa..0b844fb14 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -114,14 +114,13 @@ class UsersController < ApplicationController else case params[:type] when 'homework' - @user_course_messages = @user.course_messages.reverse.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;") + @user_course_messages = CourseMessage.where(:course_message_type => "HomeworkCommon", :user_id => @user) when 'message' - @user_course_messages = @user.course_messages.reverse.select{|x| x.course_message_type == "Message"} + @user_course_messages = CourseMessage.where(:course_message_type => "Message", :user_id => @user) when 'news' - @user_course_messages = @user.course_messages.reverse.select{|x| x.course_message_type == "News"} + @user_course_messages = CourseMessage.where(:course_message_type => "News", :user_id => @user) when 'poll' - @user_course_messages = @user.course_messages.reverse.select{|x| x.course_message_type == "Poll"} + @user_course_messages = CourseMessage.where(:course_message_type => "Poll", :user_id => @user) end end respond_to do |format| From e72eeb37c8111f18c48eb9fa5ebe7106b10dc567 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Mon, 17 Aug 2015 15:05:26 +0800 Subject: [PATCH 05/51] =?UTF-8?q?=E9=80=9A=E7=9F=A5=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_messages.html.erb | 12 ++++++------ public/stylesheets/public_new.css | 11 ++++++----- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 09ddcdfa9..3f774d384 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -27,7 +27,7 @@
  • <%= ucm.course_message.author %>
  • 发布通知
  • - <%= link_to "#{ucm.course_message.title}", {:controller => 'news', :action => 'show', :id => ucm.course_message.id },:class =>"#{ucm.viewed == 0 ? "newsBlue" : "newsGrey"}" %>
  • + <%= link_to "#{ucm.course_message.title}", {:controller => 'news', :action => 'show', :id => ucm.course_message.id },:class =>"#{ucm.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
  • <%= time_tag(ucm.course_message.created_on).html_safe %>
  • <% end %> @@ -35,9 +35,9 @@ <% end %> @@ -47,7 +47,7 @@
  • <%= ucm.course_message.user %>
  • 发布问卷
  • - <%= link_to format_activity_title(" #{ucm.course_message.polls_name}"), poll_index_path(:polls_type => "Course", :polls_group_id => ucm.course_id),:class=>"#{ucm.viewed==0?"newsBlue":"newsGrey"}" %>
  • + <%= link_to format_activity_title(" #{ucm.course_message.polls_name}"), poll_index_path(:polls_type => "Course", :polls_group_id => ucm.course_id),:class=>"#{ucm.viewed==0?"newsBlack":"newsGrey"}" %>
  • <%= time_tag(ucm.course_message.created_at).html_safe %>
  • <% end %> @@ -58,12 +58,12 @@ <% if ucm.course_message.parent_id.nil? %>
  • 发布帖子
  • - <%=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),:class=>"#{ucm.viewed==0?"newsBlue":"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),:class=>"#{ucm.viewed==0?"newsBlack":"newsGrey"}" %>
  • <%= time_tag(ucm.course_message.created_on).html_safe %>
  • <% else %>
  • 回复帖子
  • - <%=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),:class=>"#{ucm.viewed==0?"newsBlue":"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),:class=>"#{ucm.viewed==0?"newsBlack":"newsGrey"}" %>
  • <%= time_tag(ucm.course_message.created_on).html_safe %>
  • <% end %> diff --git a/public/stylesheets/public_new.css b/public/stylesheets/public_new.css index 5d5186c21..968e12a07 100644 --- a/public/stylesheets/public_new.css +++ b/public/stylesheets/public_new.css @@ -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:#15bccf;} -/*img{max-width: 100%;}*/ +a:hover,a:active{color:#000;} +img{max-width: 100%;} /*常用*/ select,input,textarea{ border:1px solid #64bdd9; background:#fff; color:#000; padding-left:5px; } @@ -587,17 +587,18 @@ a.homepageMenuText {color:#484848; font-size:16px; margin-left:20px;} .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:80px; max-width:80px; margin-right:10px; font-size:12px; color:#15bccf; display:block; padding-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; } +.homepageNewsPublisher {width:95px; font-size:12px; color:#15bccf; display:block;} .homepageNewsType {width:95px; font-size:12px; color:#888888; display:block;} -.homepageNewsContent {width:395px; max-width:395px; margin-right:10px; font-size:12px; color:#4b4b4b; display:block; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; } +.homepageNewsTypeNotRead {width:95px; font-size:12px; font-weight:bold; color:#000; 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.newsBlack {color:black; font-weight:bold;} a.newsGrey:hover {color:#000000;} a.newsBlue {color:#15bccf;} a.newsBlue:hover {color:#0781b4;} +a.newsBlack {color:black; font-weight:bold;} a.resourcesGrey {font-size:12px; color:#888888;} a.resourcesGrey:hover {font-size:12px; color:#15bccf;} From a677119ba04e057bbadec0e60fca3eaea5162875 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 17 Aug 2015 15:20:46 +0800 Subject: [PATCH 06/51] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_messages.html.erb | 2 +- public/stylesheets/public_new.css | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 3f774d384..96cd9f4ff 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -35,7 +35,7 @@
    • <%= image_tag(url_to_avatar(ucm.course_message.user), :width => "30", :height => "30") %>
    • <%= ucm.course_message.user %>
    • -
    • >发布作业
    • +
    • ">发布作业
    • <%= link_to ("#{ucm.course_message.name}"), student_work_index_path(:homework => ucm.course_message.id),:class => "#{ucm.viewed == 0?"newsBlack":"newsGrey"}" %>
    • <%= time_tag(ucm.course_message.created_at).html_safe %>
    • diff --git a/public/stylesheets/public_new.css b/public/stylesheets/public_new.css index 968e12a07..953ffc3e5 100644 --- a/public/stylesheets/public_new.css +++ b/public/stylesheets/public_new.css @@ -587,10 +587,10 @@ a.homepageMenuText {color:#484848; font-size:16px; margin-left:20px;} .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;} +.homepageNewsPublisher {width:80px; max-width:80px; margin-right:10px; font-size:12px; color:#15bccf; display:block; padding-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; } .homepageNewsType {width:95px; font-size:12px; color:#888888; display:block;} .homepageNewsTypeNotRead {width:95px; font-size:12px; font-weight:bold; color:#000; display:block;} -.homepageNewsContent {width:405px; font-size:12px; color:#4b4b4b; display:block;} +.homepageNewsContent {width:395px; max-width:395px; margin-right:10px; font-size:12px; color:#4b4b4b; display:block; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; } .homepageNewsTime {width:75px; font-size:12px; color:#888888; display:block; text-align:right;} a.homepageWhite {color:#ffffff;} a.homepageWhite:hover {color:#a1ebff} From 8f23a81261648b7d376fc58010309d4b15c1e68f Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Mon, 17 Aug 2015 15:56:16 +0800 Subject: [PATCH 07/51] =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_messages.html.erb | 16 ++++++++-------- public/stylesheets/public_new.css | 5 +++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 96cd9f4ff..c14a741a3 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -24,8 +24,8 @@ <% if ucm.course_message_type == "News" %>
      • <%= image_tag(url_to_avatar(ucm.course_message.author), :width => "30", :height => "30") %>
      • -
      • <%= ucm.course_message.author %>
      • -
      • 发布通知
      • +
      • "><%= ucm.course_message.author %>
      • +
      • ">发布通知
      • <%= link_to "#{ucm.course_message.title}", {:controller => 'news', :action => 'show', :id => ucm.course_message.id },:class =>"#{ucm.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
      • <%= time_tag(ucm.course_message.created_on).html_safe %>
      • @@ -34,7 +34,7 @@ <% if ucm.course_message_type == "HomeworkCommon" %>
        • <%= image_tag(url_to_avatar(ucm.course_message.user), :width => "30", :height => "30") %>
        • -
        • <%= ucm.course_message.user %>
        • +
        • "><%= ucm.course_message.user %>
        • ">发布作业
        • <%= link_to ("#{ucm.course_message.name}"), student_work_index_path(:homework => ucm.course_message.id),:class => "#{ucm.viewed == 0?"newsBlack":"newsGrey"}" %>
        • @@ -44,8 +44,8 @@ <% if ucm.course_message_type == "Poll" %>
          • <%= image_tag(url_to_avatar(ucm.course_message.user), :width => "30", :height => "30") %>
          • -
          • <%= ucm.course_message.user %>
          • -
          • 发布问卷
          • +
          • "><%= ucm.course_message.user %>
          • +
          • ">发布问卷
          • <%= link_to format_activity_title(" #{ucm.course_message.polls_name}"), poll_index_path(:polls_type => "Course", :polls_group_id => ucm.course_id),:class=>"#{ucm.viewed==0?"newsBlack":"newsGrey"}" %>
          • <%= time_tag(ucm.course_message.created_at).html_safe %>
          • @@ -54,14 +54,14 @@ <% if ucm.course_message_type == "Message" %>
            • <%= image_tag(url_to_avatar(ucm.course_message.author), :width => "30", :height => "30") %>
            • -
            • <%= ucm.course_message.author %>
            • +
            • "><%= ucm.course_message.author %>
            • <% if ucm.course_message.parent_id.nil? %> -
            • 发布帖子
            • +
            • ">发布帖子
            • <%=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),:class=>"#{ucm.viewed==0?"newsBlack":"newsGrey"}" %>
            • <%= time_tag(ucm.course_message.created_on).html_safe %>
            • <% else %> -
            • 回复帖子
            • +
            • ">回复帖子
            • <%=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),:class=>"#{ucm.viewed==0?"newsBlack":"newsGrey"}" %>
            • <%= time_tag(ucm.course_message.created_on).html_safe %>
            • diff --git a/public/stylesheets/public_new.css b/public/stylesheets/public_new.css index 953ffc3e5..e020694bc 100644 --- a/public/stylesheets/public_new.css +++ b/public/stylesheets/public_new.css @@ -589,7 +589,7 @@ a.homepageMenuText {color:#484848; font-size:16px; margin-left:20px;} .homepageNewsPortrait {width:40px; display:block; margin-top:7px;} .homepageNewsPublisher {width:80px; max-width:80px; margin-right:10px; font-size:12px; color:#15bccf; display:block; padding-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; } .homepageNewsType {width:95px; font-size:12px; color:#888888; display:block;} -.homepageNewsTypeNotRead {width:95px; font-size:12px; font-weight:bold; color:#000; display:block;} +.homepageNewsTypeNotRead {width:95px; font-size:12px; font-weight:bold; color:#4B4B4B; display:block;} .homepageNewsContent {width:395px; max-width:395px; margin-right:10px; font-size:12px; color:#4b4b4b; display:block; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; } .homepageNewsTime {width:75px; font-size:12px; color:#888888; display:block; text-align:right;} a.homepageWhite {color:#ffffff;} @@ -598,7 +598,8 @@ a.newsGrey {color:#4b4b4b;} a.newsGrey:hover {color:#000000;} a.newsBlue {color:#15bccf;} a.newsBlue:hover {color:#0781b4;} -a.newsBlack {color:black; font-weight:bold;} +a.newsBlack {color:#4B4B4B; font-weight:bold;} +a.newsBlack:hover {color:#0781b4;} a.resourcesGrey {font-size:12px; color:#888888;} a.resourcesGrey:hover {font-size:12px; color:#15bccf;} From 472254019e236f05e4a41f905ac14316e0ea7d1f Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 17 Aug 2015 16:04:04 +0800 Subject: [PATCH 08/51] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 0b844fb14..d0b3f91be 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -108,25 +108,26 @@ class UsersController < ApplicationController # querys.update_all(:viewed => true) # end if @user.course_messages - if params[:type].nil? - @user_course_messages = @user.course_messages.reverse - @user_project_messges = @user.forge_messages.reverse - else case params[:type] + when nil + @user_course_messages = @user.course_messages.reverse + @user_project_messges = @user.forge_messages.reverse when 'homework' - @user_course_messages = CourseMessage.where(:course_message_type => "HomeworkCommon", :user_id => @user) + @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "HomeworkCommon", @user).order("created_at desc") when 'message' - @user_course_messages = CourseMessage.where(:course_message_type => "Message", :user_id => @user) + @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "Message", @user).order("created_at desc") + # @user_course_messages = CourseMessage.where(:course_message_type => "Message", :user_id => @user).reverse when 'news' - @user_course_messages = CourseMessage.where(:course_message_type => "News", :user_id => @user) + @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "News", @user).order("created_at desc") when 'poll' - @user_course_messages = CourseMessage.where(:course_message_type => "Poll", :user_id => @user) + @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "Poll", @user).order("created_at desc") + when "" + when 'issue' + @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "Issue", @user).order("created_at desc") + end + respond_to do |format| + format.html{render :layout=>'base_users_new'} end - end - respond_to do |format| - format.html{render :layout=>'base_users_new'} - format.api - end end end From 9c8679eda853915b03d169d59c9ce803e03ae32f Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 17 Aug 2015 16:07:45 +0800 Subject: [PATCH 09/51] =?UTF-8?q?=E9=93=83=E9=93=9B=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/stylesheets/public_new.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/stylesheets/public_new.css b/public/stylesheets/public_new.css index e020694bc..599c3b1f1 100644 --- a/public/stylesheets/public_new.css +++ b/public/stylesheets/public_new.css @@ -7,7 +7,7 @@ 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%;} +/*img{max-width: 100%;}*/ /*常用*/ select,input,textarea{ border:1px solid #64bdd9; background:#fff; color:#000; padding-left:5px; } From dd1dd143f61c6015e00a9af5e83323e63673d9eb Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 17 Aug 2015 16:15:40 +0800 Subject: [PATCH 10/51] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E7=BC=BA=E9=99=B7=E6=B6=88=E6=81=AF=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 2 +- app/views/users/user_messages.html.erb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index d0b3f91be..a6f756490 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -123,7 +123,7 @@ class UsersController < ApplicationController @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "Poll", @user).order("created_at desc") when "" when 'issue' - @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "Issue", @user).order("created_at desc") + @user_course_messages = ForgeMessage.where("course_message_type =? and user_id =?", "Issue", @user).order("created_at desc") end respond_to do |format| format.html{render :layout=>'base_users_new'} diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index c14a741a3..70e2d7e1a 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -13,6 +13,7 @@
            • <%= link_to "课程通知",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'news'} %>
            • <%= link_to "问卷调查",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'poll'} %>
            • +
            • <%= link_to "指派给我",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'issue'} %>
          @@ -70,6 +71,12 @@ <% end %>
          <% end %> + + <% @user_forge_messages.each do |ufm| %> + <% if ufm.forge_message_type == "Issue" %> + + <% end %> + <% end %> <% else %>
          暂无消息!
          <% end %> From 71f69271453debbeb6d62835a2985cc0bc7ddf79 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 17 Aug 2015 16:37:05 +0800 Subject: [PATCH 11/51] =?UTF-8?q?issue=E6=8E=A7=E5=88=B6=E5=B1=82=E6=B6=88?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 8 +++----- app/views/users/user_messages.html.erb | 1 + 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index a6f756490..777cc75bb 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -107,11 +107,11 @@ class UsersController < ApplicationController # if User.current.id == @user.id # querys.update_all(:viewed => true) # end - if @user.course_messages + case params[:type] when nil @user_course_messages = @user.course_messages.reverse - @user_project_messges = @user.forge_messages.reverse + @user_forge_messages = @user.forge_messages.reverse when 'homework' @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "HomeworkCommon", @user).order("created_at desc") when 'message' @@ -121,14 +121,12 @@ class UsersController < ApplicationController @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "News", @user).order("created_at desc") when 'poll' @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "Poll", @user).order("created_at desc") - when "" when 'issue' - @user_course_messages = ForgeMessage.where("course_message_type =? and user_id =?", "Issue", @user).order("created_at desc") + @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Issue", @user).order("created_at desc") end respond_to do |format| format.html{render :layout=>'base_users_new'} end - end end def user_projects_index diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 70e2d7e1a..a50767573 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -72,6 +72,7 @@
          <% end %> + <% elsif !@user_forge_messages.blank? %> <% @user_forge_messages.each do |ufm| %> <% if ufm.forge_message_type == "Issue" %> From 4bc0e0eb69c0fd87c000f8347b41df943acae95b Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 18 Aug 2015 10:31:40 +0800 Subject: [PATCH 12/51] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=B7=BB=E5=8A=A0=20=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA=E7=BB=93=E6=9E=84=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 43 ++++++++-------- app/models/message.rb | 68 ++++++++++++-------------- app/models/news.rb | 17 +++++-- app/views/users/user_messages.html.erb | 9 ++-- public/stylesheets/public_new.css | 2 +- 5 files changed, 73 insertions(+), 66 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 777cc75bb..770d7d049 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -107,26 +107,29 @@ class UsersController < ApplicationController # if User.current.id == @user.id # querys.update_all(:viewed => true) # end - - case params[:type] - when nil - @user_course_messages = @user.course_messages.reverse - @user_forge_messages = @user.forge_messages.reverse - when 'homework' - @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "HomeworkCommon", @user).order("created_at desc") - when 'message' - @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "Message", @user).order("created_at desc") - # @user_course_messages = CourseMessage.where(:course_message_type => "Message", :user_id => @user).reverse - when 'news' - @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "News", @user).order("created_at desc") - when 'poll' - @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "Poll", @user).order("created_at desc") - when 'issue' - @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Issue", @user).order("created_at desc") - end - respond_to do |format| - format.html{render :layout=>'base_users_new'} - end + @new_message_count = ForgeMessage.all.count + case params[:type] + when nil + @user_course_messages = @user.course_messages.reverse + @user_forge_messages = @user.forge_messages.reverse + when 'homework' + @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "HomeworkCommon", @user).order("created_at desc") + @user_forge_messages = nil + when 'message' + @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "Message", @user).order("created_at desc") + @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Message", @user).order("created_at desc") + when 'news' + @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "News", @user).order("created_at desc") + @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "News", @user).order("created_at desc") + when 'poll' + @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "Poll", @user).order("created_at desc") + when 'issue' + @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Issue", @user).order("created_at desc") + @user_course_messages = nil + end + respond_to do |format| + format.html{render :layout=>'base_users_new'} + end end def user_projects_index diff --git a/app/models/message.rb b/app/models/message.rb index aa62cd625..4cc233eb5 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -35,8 +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 + has_many :forge_messages, :class_name => 'ForgeMessage', :as => :forge_message, :dependent => :destroy #end has_many :ActivityNotifies,:as => :activity, :dependent => :destroy @@ -73,7 +74,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, :act_as_course_message, :send_mail + after_create :act_as_activity,:act_as_course_activity,:be_user_score,:act_as_forge_activity, :act_as_system_message, :send_mail #before_save :be_user_score scope :visible, lambda {|*args| @@ -198,58 +199,49 @@ class Message < ActiveRecord::Base end end - # 课程讨论区添加消息 + # 课程讨论区添加消息: # 老师发帖所有人都能收到消息 # 学生发帖,有人回复则给该学生消息,没回复则不给其它人发送消息 # 帖子被回复的可以收到消息通知 - def act_as_course_message + # 项目讨论区添加消息: + # 主贴项目成员都能收到 + # 回帖:帖子的发布人收到 + def act_as_system_message if self.course - if self.parent_id.nil? #主贴 + 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 + if self.author.allowed_to?(:as_teacher, self.course) && 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 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 + 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 + else # 项目相关 + if self.parent_id.nil? # 主贴 + self.project.members.each do |m| + if m.user_id != self.author_id + self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false) + end + end + else # 回帖 + self.project.members.each do |m| + if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息 + self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false) + self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false) + 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 #新建message且无parent的为发帖 - if self.parent_id.nil? && !self.board.project.nil? UserScore.joint(:post_message, self.author,nil,self, { message_id: self.id }) update_memo_number(self.author,1) diff --git a/app/models/news.rb b/app/models/news.rb index 99d26d456..30e4b0f55 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -31,8 +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 + has_many :forge_messages, :class_name => 'ForgeMessage', :as => :forge_message, :dependent => :destroy #end has_many :ActivityNotifies,:as => :activity, :dependent => :destroy @@ -54,7 +55,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,:act_as_course_messge, :add_author_as_watcher, :send_mail + after_create :act_as_activity,:act_as_forge_activity, :act_as_course_activity,:act_as_system_message, :add_author_as_watcher, :send_mail after_destroy :delete_kindeditor_assets @@ -133,15 +134,23 @@ class News < ActiveRecord::Base end end - #课程通知 消息发送 + #课程/项目通知 消息发送 #消息发送原则:除了消息的发布者,课程的其它成员都能收到消息提醒 - def act_as_course_messge + def act_as_system_message 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 + else + if !self.project.nil? + self.project.members.each do |m| + if m.user_id != self.author_id + self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.project_id, :viewed => false) + end + end + end end end diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index a50767573..2e7b110bf 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -20,7 +20,8 @@
          - <% if !@user_course_messages.blank? %> + <% if @new_message_count >0 %> + <% unless @user_course_messages.nil? %> <% @user_course_messages.each do |ucm| %> <% if ucm.course_message_type == "News" %>
            @@ -71,13 +72,15 @@ <% end %>
            <% end %> + <% end %> - <% elsif !@user_forge_messages.blank? %> + <% unless @user_forge_messages.nil? %> <% @user_forge_messages.each do |ufm| %> <% if ufm.forge_message_type == "Issue" %> - + 22222 <% end %> <% end %> + <% end %> <% else %>
            暂无消息!
            <% end %> diff --git a/public/stylesheets/public_new.css b/public/stylesheets/public_new.css index 599c3b1f1..fb7e6fbf4 100644 --- a/public/stylesheets/public_new.css +++ b/public/stylesheets/public_new.css @@ -6,7 +6,7 @@ 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;} +a:hover,a:active{color:#15bccf;} /*img{max-width: 100%;}*/ /*常用*/ From 3e4f726855de4448c0fa8e6d7f2a2984d81a785c Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Tue, 18 Aug 2015 14:43:15 +0800 Subject: [PATCH 13/51] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=95=99=E8=A8=80?= =?UTF-8?q?=E3=80=81=E6=8C=87=E6=B4=BE=E7=BB=99=E6=88=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 3 +++ app/views/users/user_messages.html.erb | 34 +++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 770d7d049..dbcbdefa6 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -126,6 +126,9 @@ class UsersController < ApplicationController when 'issue' @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Issue", @user).order("created_at desc") @user_course_messages = nil + when 'journal' + @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Journal", @user).order("created_at desc") + @user_course_messages = nil end respond_to do |format| format.html{render :layout=>'base_users_new'} diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 2e7b110bf..c23ad3716 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -14,6 +14,7 @@
          • <%= link_to "问卷调查",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'poll'} %>
          • <%= link_to "指派给我",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'issue'} %>
          • +
          • <%= link_to "问题更新",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'journal'} %>
        @@ -76,9 +77,36 @@ <% unless @user_forge_messages.nil? %> <% @user_forge_messages.each do |ufm| %> - <% if ufm.forge_message_type == "Issue" %> - 22222 - <% end %> + <% if ufm.forge_message_type == "Issue" %> + + <% end %> + <% if ufm.forge_message_type == "Journal" %> + + <% end %> <% end %> <% end %> <% else %> From 9c4e89177f68967aa0537dc390737c6ea6ad463a Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Tue, 18 Aug 2015 14:44:46 +0800 Subject: [PATCH 14/51] =?UTF-8?q?=E7=95=99=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_messages.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index c23ad3716..77b7d5898 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -14,7 +14,7 @@
      • <%= link_to "问卷调查",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'poll'} %>
      • <%= link_to "指派给我",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'issue'} %>
      • -
      • <%= link_to "问题更新",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'journal'} %>
      • +
      • <%= link_to "我的留言",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'journal'} %>
    From 6b5547462338521b53a9da9548a488b699e76de5 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 18 Aug 2015 15:27:16 +0800 Subject: [PATCH 15/51] =?UTF-8?q?=E4=BD=9C=E5=93=81=E8=A2=AB=E8=AF=84?= =?UTF-8?q?=E9=98=85=20=E4=BD=9C=E5=93=81=E8=A2=AB=E5=9B=9E=E5=A4=8D=20?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 4 ++++ app/models/journals_for_message.rb | 13 ++++++++++++- app/models/student_works_score.rb | 11 +++++++++++ app/views/users/user_messages.html.erb | 2 +- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 770d7d049..3e50f3131 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -97,6 +97,8 @@ class UsersController < ApplicationController end # 用户消息 + # 说明: homework 发布作业;message:讨论区; news:新闻; poll:问卷;works_reviewers:作品评阅 + # issue:问题; def user_messages unless User.current.logged? render_403 @@ -123,6 +125,8 @@ class UsersController < ApplicationController @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "News", @user).order("created_at desc") when 'poll' @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "Poll", @user).order("created_at desc") + when 'works_reviewers' + @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "StudentWorksScore", @user).order("created_at desc") when 'issue' @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Issue", @user).order("created_at desc") @user_course_messages = nil diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index bcae58174..da19ba1f2 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -58,9 +58,11 @@ class JournalsForMessage < 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 validates :notes, presence: true, if: :is_homework_jour? - after_create :act_as_activity, :act_as_course_activity + after_create :act_as_activity, :act_as_course_activity, :act_as_course_message after_create :reset_counters! after_destroy :reset_counters! after_save :be_user_score @@ -186,4 +188,13 @@ class JournalsForMessage < ActiveRecord::Base self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.jour_id) end end + + # 课程作品留言消息通知 + def act_as_course_message + if self.jour_type == 'StudentWorksScore' + if self.user_id != self.jour.user_id + self.course_messages << CourseMessage.new(:user_id => self.jour.user_id,:course_id => self.jour.student_work.homework_common.course.id) + end + end + end end diff --git a/app/models/student_works_score.rb b/app/models/student_works_score.rb index 8fa14f8de..639722389 100644 --- a/app/models/student_works_score.rb +++ b/app/models/student_works_score.rb @@ -5,6 +5,17 @@ class StudentWorksScore < ActiveRecord::Base belongs_to :user belongs_to :student_work has_many :journals_for_messages, :as => :jour, :dependent => :destroy + has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy acts_as_attachable + + after_create :act_as_course_message + + # 评阅作品消息提示 + def act_as_course_message + if self.student_work + receiver = self.student_work.user + self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id, :viewed => false) + end + end end diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 2e7b110bf..93e0fe967 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -22,7 +22,7 @@
    <% if @new_message_count >0 %> <% unless @user_course_messages.nil? %> - <% @user_course_messages.each do |ucm| %> + <% @user_course_messages.each do |ucm| %> <% if ucm.course_message_type == "News" %>
    - <% if @new_message_count >0 %> - <% unless @user_course_messages.nil? %> - <% @user_course_messages.each do |ucm| %> - <% if ucm.course_message_type == "News" %> - + <% if @new_message_count >0 %> + <% unless @user_course_messages.nil? %> + <% @user_course_messages.each do |ucm| %> + <% if ucm.course_message_type == "News" %> + + <% end %> + <% if ucm.course_message_type == "HomeworkCommon" %> + + <% end %> + <% if ucm.course_message_type == "Poll" %> + + <% end %> + <% if ucm.course_message_type == "Message" %> + + <% end %> +
    + <% end %> <% end %> - <% if ucm.course_message_type == "HomeworkCommon" %> - - <% end %> - <% if ucm.course_message_type == "Poll" %> - - <% end %> - <% if ucm.course_message_type == "Message" %> - - <% end %> -
    - <% end %> - <% end %> - - <% unless @user_forge_messages.nil? %> - <% @user_forge_messages.each do |ufm| %> + + <% unless @user_forge_messages.nil? %> + <% @user_forge_messages.each do |ufm| %> <% if ufm.forge_message_type == "Issue" %> <% end %> + <% end %> + <% end %> + <% else %> +
    暂无消息!
    <% end %> - <% end %> - <% else %> -
    暂无消息!
    - <% end %>
    From 90661066d36e8e81069c6d0bc242095a855f6e84 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 18 Aug 2015 16:53:26 +0800 Subject: [PATCH 17/51] =?UTF-8?q?=E5=8C=BA=E5=88=86=E8=AF=BE=E7=A8=8B/?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E8=AE=A8=E8=AE=BA=E5=8C=BA=20=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E9=A1=B9=E7=9B=AE/=E6=96=B0=E9=97=BB=20=E7=9A=84?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=98=BE=E7=A4=BA=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 8 ++++++-- app/views/users/user_messages.html.erb | 11 ++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index d1073c8c3..00ce151cf 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -117,16 +117,20 @@ class UsersController < ApplicationController when 'homework' @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "HomeworkCommon", @user).order("created_at desc") @user_forge_messages = nil - when 'message' + when 'course_message' @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "Message", @user).order("created_at desc") + when 'forge_message' @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Message", @user).order("created_at desc") - when 'news' + when 'course_news' @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "News", @user).order("created_at desc") + when 'forge_news' @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "News", @user).order("created_at desc") when 'poll' @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "Poll", @user).order("created_at desc") when 'works_reviewers' @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "StudentWorksScore", @user).order("created_at desc") + when 'works_reply' + @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "JournalsForMessage", @user).order("created_at desc") when 'issue' @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Issue", @user).order("created_at desc") @user_course_messages = nil diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 03cdda8ad..a4cc521ff 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -9,12 +9,17 @@
  • <%= link_to "全部",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user} %>
  • <%= link_to "作业消息",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'homework'} %>
  • -
  • <%= link_to "讨论区",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'message'} %>
  • -
  • <%= link_to "课程通知",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'news'} %>
  • +
  • <%= link_to "课程讨论区",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'course_message'} %>
  • +
  • <%= link_to "课程通知",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'course_news'} %>
  • <%= link_to "问卷调查",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'poll'} %>
  • +
  • <%= link_to "作品评阅",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'works_reviewers'} %>
  • +
  • <%= link_to "作品讨论",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'works_reply'} %>
  • +
  • <%= link_to "指派给我",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'issue'} %>
  • -
  • <%= link_to "我的留言",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'issue_update'} %>
  • +
  • <%= link_to "问题更新",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'issue_update'} %>
  • +
  • <%= link_to "项目讨论区",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forge_message'} %>
  • +
  • <%= link_to "项目新闻",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forge_news'} %>
  • From d657e9f3cc44e2964828eb6dd173eb9cd7c1bf38 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 19 Aug 2015 11:06:39 +0800 Subject: [PATCH 18/51] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E5=85=AC=E5=85=B1?= =?UTF-8?q?=E8=B4=B4=E5=90=A7=20=E6=B6=88=E6=81=AF=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 11 ++-- app/models/forum.rb | 1 + app/models/forum_message.rb | 11 ++++ app/models/memo.rb | 30 ++++++++++- app/models/user.rb | 4 +- .../20150818091800_create_forum_messages.rb | 13 +++++ db/schema.rb | 50 ++++++++++++++++++- spec/factories/forum_messages.rb | 10 ++++ spec/models/forum_message_spec.rb | 5 ++ 9 files changed, 126 insertions(+), 9 deletions(-) create mode 100644 app/models/forum_message.rb create mode 100644 db/migrate/20150818091800_create_forum_messages.rb create mode 100644 spec/factories/forum_messages.rb create mode 100644 spec/models/forum_message_spec.rb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 00ce151cf..d77ccb958 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -97,8 +97,8 @@ class UsersController < ApplicationController end # 用户消息 - # 说明: homework 发布作业;message:讨论区; news:新闻; poll:问卷;works_reviewers:作品评阅 - # issue:问题; + # 说明: homework 发布作业;message:讨论区; news:新闻; poll:问卷;works_reviewers:作品评阅;works_reply:作品回复 + # issue:问题;journal:缺陷状态更新; forum:公共贴吧 def user_messages unless User.current.logged? render_403 @@ -114,6 +114,7 @@ class UsersController < ApplicationController when nil @user_course_messages = @user.course_messages.reverse @user_forge_messages = @user.forge_messages.reverse + @user_forum_messages = @user.forum_messages.reverse when 'homework' @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "HomeworkCommon", @user).order("created_at desc") @user_forge_messages = nil @@ -134,9 +135,11 @@ class UsersController < ApplicationController when 'issue' @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Issue", @user).order("created_at desc") @user_course_messages = nil - when 'journal' - @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Journal", @user).order("created_at desc") + when 'journal' # 缺陷状态更新、留言 + @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Forum", @user).order("created_at desc") @user_course_messages = nil + when 'forum' + @user_forum_messages = ForumMessage.where("memo_message_type =? and user_id =?", "Forum", @user).order("created_at desc") end respond_to do |format| format.html{render :layout=>'base_users_new'} diff --git a/app/models/forum.rb b/app/models/forum.rb index 2af1abf9e..530639f81 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -39,6 +39,7 @@ class Forum < ActiveRecord::Base logger.debug "send mail for forum add." Mailer.run.forum_add(self) if Setting.notified_events.include?('forum_add') end + # Updates topic_count, memo_count and last_memo_id attributes for +board_id+ def self.reset_counters!(forum_id) forum_id = forum_id.to_i diff --git a/app/models/forum_message.rb b/app/models/forum_message.rb new file mode 100644 index 000000000..c7b07e164 --- /dev/null +++ b/app/models/forum_message.rb @@ -0,0 +1,11 @@ +class ForumMessage < ActiveRecord::Base + attr_accessible :forum_id, :memo_message_id, :memo_message_type, :user_id, :viewed + + belongs_to :memo + belongs_to :user + + validates :user_id,presence: true + validates :forum_id,presence: true + validates :memo_message_id,presence: true + validates :memo_message_type, presence: true +end diff --git a/app/models/memo.rb b/app/models/memo.rb index e0abaa19f..e4dabf131 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -16,6 +16,8 @@ class Memo < ActiveRecord::Base acts_as_attachable has_many :user_score_details, :class_name => 'UserScoreDetails',:as => :score_changeable_obj has_many :praise_tread, as: :praise_tread_object, dependent: :destroy + # 消息 + has_many :forum_messages, dependent: :destroy belongs_to :last_reply, :class_name => 'Memo', :foreign_key => 'last_reply_id' # acts_as_searchable :column => ['subject', 'content'], # #:include => { :forum => :p} @@ -44,7 +46,7 @@ class Memo < ActiveRecord::Base "parent_id", "replies_count" - after_create :add_author_as_watcher, :reset_counters!, :send_mail + after_create :add_author_as_watcher, :reset_counters!, :send_mail, :send_message # after_update :update_memos_forum after_destroy :reset_counters!,:delete_kindeditor_assets#,:down_user_score -- 公共区发帖暂不计入得分 # after_create :send_notification @@ -59,6 +61,32 @@ class Memo < ActiveRecord::Base Mailer.run.forum_message_added(self) if Setting.notified_events.include?('forum_message_added') end + # 公共贴吧消息记录 + # 原则:贴吧创始人;发帖人,wanglingchun(特殊用户) + def send_message + receivers = [] + u = User.find(6) + receivers << u + # 主贴 + if self.parent_id.nil? + if self.author_id != self.forum.creator_id # 发帖人不是吧主 + receivers << self.forum.creator + end + else # 回帖 + # 添加吧主 + if self.author_id != self.forum.creator_id + receivers << self.forum.creator + end + # 添加发帖人 + if self.author_id != self.parent.author_id + receivers << self.parent.author + end + end + receivers.each do |r| + self.forum_messages << ForumMessage.new(:user_id => r.id, :forum_id => self.forum_id, :memo_message_id => self.id, :memo_message_type => "Forum", :viewed => false) + end + end + def cannot_reply_to_locked_topic errors.add :base, l(:label_memo_locked) if root.locked? && self != root end diff --git a/app/models/user.rb b/app/models/user.rb index 9f88ff53a..82ecdbd47 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -127,10 +127,10 @@ 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 :forum_messages # 虚拟转换 has_many :new_jours, :as => :jour, :class_name => 'JournalsForMessage', :conditions => "status=1" diff --git a/db/migrate/20150818091800_create_forum_messages.rb b/db/migrate/20150818091800_create_forum_messages.rb new file mode 100644 index 000000000..20ad1ca51 --- /dev/null +++ b/db/migrate/20150818091800_create_forum_messages.rb @@ -0,0 +1,13 @@ +class CreateForumMessages < ActiveRecord::Migration + def change + create_table :forum_messages do |t| + t.integer :user_id + t.integer :forum_id + t.integer :memo_message_id + t.string :memo_message_type + t.integer :viewed + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index db9b9ff9b..5471381d7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20150810064247) do +ActiveRecord::Schema.define(:version => 20150818091800) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -325,6 +325,15 @@ ActiveRecord::Schema.define(:version => 20150810064247) do t.datetime "updated_on", :null => false end + create_table "course_activities", :force => true do |t| + t.integer "user_id" + t.integer "course_id" + t.integer "course_act_id" + t.string "course_act_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "course_attachments", :force => true do |t| t.string "filename" t.string "disk_filename" @@ -357,6 +366,16 @@ ActiveRecord::Schema.define(:version => 20150810064247) do t.datetime "updated_at", :null => false end + create_table "course_messages", :force => true do |t| + t.integer "user_id" + t.integer "course_id" + t.integer "course_message_id" + t.string "course_message_type" + t.integer "viewed" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "course_statuses", :force => true do |t| t.integer "changesets_count" t.integer "watchers_count" @@ -455,6 +474,13 @@ ActiveRecord::Schema.define(:version => 20150810064247) do add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" + create_table "discuss_demos", :force => true do |t| + t.string "title" + t.text "body" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "documents", :force => true do |t| t.integer "project_id", :default => 0, :null => false t.integer "category_id", :default => 0, :null => false @@ -536,6 +562,26 @@ ActiveRecord::Schema.define(:version => 20150810064247) do add_index "forge_activities", ["forge_act_id"], :name => "index_forge_activities_on_forge_act_id" + create_table "forge_messages", :force => true do |t| + t.integer "user_id" + t.integer "project_id" + t.integer "forge_message_id" + t.string "forge_message_type" + t.integer "viewed" + t.datetime "created_at", :null => false + 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" @@ -857,7 +903,6 @@ ActiveRecord::Schema.define(:version => 20150810064247) do t.datetime "created_on" t.integer "comments_count", :default => 0, :null => false t.integer "course_id" - t.datetime "updated_on" end add_index "news", ["author_id"], :name => "index_news_on_author_id" @@ -1461,6 +1506,7 @@ ActiveRecord::Schema.define(:version => 20150810064247) 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" diff --git a/spec/factories/forum_messages.rb b/spec/factories/forum_messages.rb new file mode 100644 index 000000000..adb114d3c --- /dev/null +++ b/spec/factories/forum_messages.rb @@ -0,0 +1,10 @@ +FactoryGirl.define do + factory :forum_message do + user_id 1 +forum_id 1 +memo_message_id 1 +memo_message_type "MyString" +viewed 1 + end + +end diff --git a/spec/models/forum_message_spec.rb b/spec/models/forum_message_spec.rb new file mode 100644 index 000000000..e0159c3ca --- /dev/null +++ b/spec/models/forum_message_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe ForumMessage, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end From ff3edf4d5e56e335e9cbaaeb0b536a42c3252545 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Wed, 19 Aug 2015 11:12:47 +0800 Subject: [PATCH 19/51] =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_messages.html.erb | 52 ++++++++++++++++++++++++++ public/stylesheets/public_new.css | 4 +- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index a4cc521ff..089dca32f 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -76,6 +76,26 @@ <% end %> <% end %> + <% if ucm.course_message_type == "StudentWorksScore" %> + + <% end %> + <% if ucm.course_message_type == "JournalsForMessage" %> + + <% end %>
    <% end %> <% end %> @@ -113,6 +133,38 @@
  • <%= time_tag(ufm.forge_message.created_on).html_safe %>
  • <% end %> + <% if ufm.forge_message_type == "Message" %> + + <% end %> + <% if ufm.forge_message_type == "News" %> + + <% end %> <% end %> <% end %> <% else %> diff --git a/public/stylesheets/public_new.css b/public/stylesheets/public_new.css index fb7e6fbf4..6837a5466 100644 --- a/public/stylesheets/public_new.css +++ b/public/stylesheets/public_new.css @@ -589,7 +589,7 @@ a.homepageMenuText {color:#484848; font-size:16px; margin-left:20px;} .homepageNewsPortrait {width:40px; display:block; margin-top:7px;} .homepageNewsPublisher {width:80px; max-width:80px; margin-right:10px; font-size:12px; color:#15bccf; display:block; padding-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; } .homepageNewsType {width:95px; font-size:12px; color:#888888; display:block;} -.homepageNewsTypeNotRead {width:95px; font-size:12px; font-weight:bold; color:#4B4B4B; display:block;} +.homepageNewsTypeNotRead {width:95px; font-size:13px; font-weight:bold; color:#4B4B4B; display:block;} .homepageNewsContent {width:395px; max-width:395px; margin-right:10px; font-size:12px; color:#4b4b4b; display:block; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; } .homepageNewsTime {width:75px; font-size:12px; color:#888888; display:block; text-align:right;} a.homepageWhite {color:#ffffff;} @@ -598,7 +598,7 @@ a.newsGrey {color:#4b4b4b;} a.newsGrey:hover {color:#000000;} a.newsBlue {color:#15bccf;} a.newsBlue:hover {color:#0781b4;} -a.newsBlack {color:#4B4B4B; font-weight:bold;} +a.newsBlack {color:#4B4B4B; font-weight:bold; font-size:13px;} a.newsBlack:hover {color:#0781b4;} a.resourcesGrey {font-size:12px; color:#888888;} a.resourcesGrey:hover {font-size:12px; color:#15bccf;} From 2d282f73cb51286716fbc3900e37a2763a8cf193 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 19 Aug 2015 11:21:48 +0800 Subject: [PATCH 20/51] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/message.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/message.rb b/app/models/message.rb index 4cc233eb5..37129885f 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -232,7 +232,6 @@ class Message < ActiveRecord::Base self.project.members.each do |m| if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息 self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false) - self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false) end end end From 425e0dd89a953885f844e277730d4865ed633181 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 19 Aug 2015 15:03:04 +0800 Subject: [PATCH 21/51] =?UTF-8?q?=E5=85=AC=E5=85=B1=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA=E6=B6=88=E6=81=AF=E9=A1=B5=E9=9D=A2=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=20=E9=83=A8=E5=88=86=E7=95=8C=E9=9D=A2=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 17 ++++++++-- app/views/users/user_messages.html.erb | 44 +++++++++++++++++--------- 2 files changed, 43 insertions(+), 18 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index d77ccb958..bc3719685 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -115,31 +115,42 @@ class UsersController < ApplicationController @user_course_messages = @user.course_messages.reverse @user_forge_messages = @user.forge_messages.reverse @user_forum_messages = @user.forum_messages.reverse + @user_course_messages_count = @user_course_messages.count + @user_forge_messages_count = @user_forum_messages.count when 'homework' @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "HomeworkCommon", @user).order("created_at desc") - @user_forge_messages = nil + @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") 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") 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_course_messages = nil + @user_forge_messages_count = @user_forge_messages.count when 'journal' # 缺陷状态更新、留言 @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Forum", @user).order("created_at desc") - @user_course_messages = nil + @user_forge_messages_count = @user_forge_messages.count when 'forum' @user_forum_messages = ForumMessage.where("memo_message_type =? and user_id =?", "Forum", @user).order("created_at desc") + @user_forum_messages_count = @user_forum_messages.count + else + render_404 + return end respond_to do |format| format.html{render :layout=>'base_users_new'} diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 089dca32f..233b5bcb2 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -7,19 +7,31 @@
  • @@ -82,7 +94,7 @@
  • "><%= ucm.course_message.user %>
  • ">作品评阅
  • - <%= link_to ucm.course_message.comment, nil,:class=>"#{ucm.viewed==0?"newsBlack":"newsGrey"}" %>
  • + <%= link_to ucm.course_message.comment, student_work_path(ucm.course_message.id),:class=>"#{ucm.viewed==0?"newsBlack":"newsGrey"}" %> %>
  • <%= time_tag(ucm.course_message.created_at).html_safe %>
  • <% end %> @@ -92,7 +104,7 @@
  • "><%= ucm.course_message.user %>
  • ">作品讨论
  • - <%= link_to ucm.course_message.notes, nil,:class=>"#{ucm.viewed==0?"newsBlack":"newsGrey"}" %>
  • + <%= link_to ucm.course_message.notes, student_work_path(ucm.course_message.id),:class=>"#{ucm.viewed==0?"newsBlack":"newsGrey"}" %>
  • <%= time_tag(ucm.course_message.created_on).html_safe %>
  • <% end %> @@ -167,6 +179,8 @@ <% end %> <% end %> <% end %> + <% unless @user_forum_messages.nil? %> + <% end %> <% else %>
    暂无消息!
    <% end %> From d387a529d78d3d4fdfef5863b63ed921c9589bad Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Wed, 19 Aug 2015 17:28:43 +0800 Subject: [PATCH 22/51] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=85=AC=E5=85=B1?= =?UTF-8?q?=E8=B4=B4=E5=90=A7=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_messages.html.erb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 233b5bcb2..37dbfa3f7 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -180,6 +180,23 @@ <% end %> <% end %> <% unless @user_forum_messages.nil? %> + <% @user_forum_messages.each do |urm| %> + <% if urm.memo_message_type == "Forum" %> + + <% end %> + <% end %> <% end %> <% else %>
    暂无消息!
    From d18d1a9d81fced1e9f0d2dba6a6da5165710fe24 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 19 Aug 2015 17:29:05 +0800 Subject: [PATCH 23/51] =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=95=99=E8=A8=80?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20=E5=85=AC=E5=85=B1=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA=E7=95=99=E8=A8=80=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 2 +- app/models/forum_message.rb | 11 ------ app/models/journals_for_message.rb | 30 ++++++++++++++- app/models/memo.rb | 5 ++- app/models/memo_message.rb | 11 ++++++ app/models/user.rb | 3 +- app/models/user_feedback_message.rb | 10 +++++ .../20150818091800_create_forum_messages.rb | 13 ------- ...819072608_create_user_feedback_messages.rb | 12 ++++++ .../20150819090720_create_memo_messages.rb | 13 +++++++ db/schema.rb | 38 ++++++++++++++++--- spec/factories/forum_messages.rb | 10 ----- spec/factories/memo_messages.rb | 10 +++++ spec/factories/user_feedback_messages.rb | 9 +++++ ...m_message_spec.rb => memo_message_spec.rb} | 2 +- spec/models/user_feedback_message_spec.rb | 5 +++ 16 files changed, 138 insertions(+), 46 deletions(-) delete mode 100644 app/models/forum_message.rb create mode 100644 app/models/memo_message.rb create mode 100644 app/models/user_feedback_message.rb delete mode 100644 db/migrate/20150818091800_create_forum_messages.rb create mode 100644 db/migrate/20150819072608_create_user_feedback_messages.rb create mode 100644 db/migrate/20150819090720_create_memo_messages.rb delete mode 100644 spec/factories/forum_messages.rb create mode 100644 spec/factories/memo_messages.rb create mode 100644 spec/factories/user_feedback_messages.rb rename spec/models/{forum_message_spec.rb => memo_message_spec.rb} (63%) create mode 100644 spec/models/user_feedback_message_spec.rb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index bc3719685..f9ddc58f2 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -146,7 +146,7 @@ class UsersController < ApplicationController @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Forum", @user).order("created_at desc") @user_forge_messages_count = @user_forge_messages.count when 'forum' - @user_forum_messages = ForumMessage.where("memo_message_type =? and user_id =?", "Forum", @user).order("created_at desc") + @user_forum_messages = Memo.where("memo_type =? and user_id =?", "Memo", @user).order("created_at desc") @user_forum_messages_count = @user_forum_messages.count else render_404 diff --git a/app/models/forum_message.rb b/app/models/forum_message.rb deleted file mode 100644 index c7b07e164..000000000 --- a/app/models/forum_message.rb +++ /dev/null @@ -1,11 +0,0 @@ -class ForumMessage < ActiveRecord::Base - attr_accessible :forum_id, :memo_message_id, :memo_message_type, :user_id, :viewed - - belongs_to :memo - belongs_to :user - - validates :user_id,presence: true - validates :forum_id,presence: true - validates :memo_message_id,presence: true - validates :memo_message_type, presence: true -end diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index da19ba1f2..f1bdc7e7c 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -60,9 +60,10 @@ 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 validates :notes, presence: true, if: :is_homework_jour? - after_create :act_as_activity, :act_as_course_activity, :act_as_course_message + after_create :act_as_activity, :act_as_course_activity, :act_as_course_message, :act_as_user_feedback_message after_create :reset_counters! after_destroy :reset_counters! after_save :be_user_score @@ -193,7 +194,32 @@ class JournalsForMessage < ActiveRecord::Base def act_as_course_message if self.jour_type == 'StudentWorksScore' if self.user_id != self.jour.user_id - self.course_messages << CourseMessage.new(:user_id => self.jour.user_id,:course_id => self.jour.student_work.homework_common.course.id) + self.course_messages << CourseMessage.new(:user_id => self.jour.user_id,:course_id => self.jour.student_work.homework_common.course.id, :viewed => false) + end + end + end + + # 用户留言消息通知 + def act_as_user_feedback_message + # 主留言 + receivers = [] + if self.reply_id == 0 + if self.author_id != self.jour_id # 过滤自己给自己的留言消息 + receivers << self.jour + end + else # 回帖 + # 添加吧主 + if self.author_id != self.forum.creator_id + receivers << self.jour + end + # 添加发帖人 + if self.author_id != self.parent.author_id + receivers << self.parent.author + end + end + if self.jour_type == 'Principal' + if self.user_id != self.jour.user_id + self.user_feedback_messages << UserFeedbackMessage.new(:user_id => self.jour.user_id, :memo_message_id => self.id, :memo_message_type => "Forum", :viewed => false) end end end diff --git a/app/models/memo.rb b/app/models/memo.rb index e4dabf131..7225ae524 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -17,7 +17,8 @@ class Memo < ActiveRecord::Base has_many :user_score_details, :class_name => 'UserScoreDetails',:as => :score_changeable_obj has_many :praise_tread, as: :praise_tread_object, dependent: :destroy # 消息 - has_many :forum_messages, dependent: :destroy + has_many :memo_messages, :class_name =>'MemoMessage', :dependent => :destroy + # end belongs_to :last_reply, :class_name => 'Memo', :foreign_key => 'last_reply_id' # acts_as_searchable :column => ['subject', 'content'], # #:include => { :forum => :p} @@ -83,7 +84,7 @@ class Memo < ActiveRecord::Base end end receivers.each do |r| - self.forum_messages << ForumMessage.new(:user_id => r.id, :forum_id => self.forum_id, :memo_message_id => self.id, :memo_message_type => "Forum", :viewed => false) + self.memo_messages << MemoMessage.new(:user_id => r.id, :forum_id => self.forum_id, :memo_id => self.id, :memo_type => "Memo", :viewed => false) end end diff --git a/app/models/memo_message.rb b/app/models/memo_message.rb new file mode 100644 index 000000000..051fac317 --- /dev/null +++ b/app/models/memo_message.rb @@ -0,0 +1,11 @@ +class MemoMessage < ActiveRecord::Base + attr_accessible :forum_id, :memo_id, :memo_type, :user_id, :viewed + + belongs_to :memo + belongs_to :user + + validates :user_id,presence: true + validates :forum_id,presence: true + validates :memo_id,presence: true + validates :memo_type, presence: true +end diff --git a/app/models/user.rb b/app/models/user.rb index 82ecdbd47..3a57d6217 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -130,7 +130,8 @@ class User < Principal # 关联消息表 has_many :forge_messages has_many :course_messages - has_many :forum_messages + has_many :memo_messages + has_many :user_feedback_messages # 虚拟转换 has_many :new_jours, :as => :jour, :class_name => 'JournalsForMessage', :conditions => "status=1" diff --git a/app/models/user_feedback_message.rb b/app/models/user_feedback_message.rb new file mode 100644 index 000000000..7cd8f5132 --- /dev/null +++ b/app/models/user_feedback_message.rb @@ -0,0 +1,10 @@ +class UserFeedbackMessage < ActiveRecord::Base + attr_accessible :user_id, :user_message_id, :user_message_type, :viewed + + belongs_to :user + belongs_to :journals_for_message + + validates :user_id,presence: true + validates :user_message_id,presence: true + validates :user_message_type, presence: true +end diff --git a/db/migrate/20150818091800_create_forum_messages.rb b/db/migrate/20150818091800_create_forum_messages.rb deleted file mode 100644 index 20ad1ca51..000000000 --- a/db/migrate/20150818091800_create_forum_messages.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateForumMessages < ActiveRecord::Migration - def change - create_table :forum_messages do |t| - t.integer :user_id - t.integer :forum_id - t.integer :memo_message_id - t.string :memo_message_type - t.integer :viewed - - t.timestamps - end - end -end diff --git a/db/migrate/20150819072608_create_user_feedback_messages.rb b/db/migrate/20150819072608_create_user_feedback_messages.rb new file mode 100644 index 000000000..382841c47 --- /dev/null +++ b/db/migrate/20150819072608_create_user_feedback_messages.rb @@ -0,0 +1,12 @@ +class CreateUserFeedbackMessages < ActiveRecord::Migration + def change + create_table :user_feedback_messages do |t| + t.integer :user_id + t.integer :user_message_id + t.string :user_message_type + t.integer :viewed + + t.timestamps + end + end +end diff --git a/db/migrate/20150819090720_create_memo_messages.rb b/db/migrate/20150819090720_create_memo_messages.rb new file mode 100644 index 000000000..d050a7815 --- /dev/null +++ b/db/migrate/20150819090720_create_memo_messages.rb @@ -0,0 +1,13 @@ +class CreateMemoMessages < ActiveRecord::Migration + def change + create_table :memo_messages do |t| + t.integer :user_id + t.integer :forum_id + t.integer :memo_id + t.string :memo_type + t.integer :viewed + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 5471381d7..fd1d98e58 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20150818091800) do +ActiveRecord::Schema.define(:version => 20150819090720) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -575,11 +575,11 @@ ActiveRecord::Schema.define(:version => 20150818091800) do 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 "memo_id" + t.string "memo_type" t.integer "viewed" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "forums", :force => true do |t| @@ -859,6 +859,16 @@ ActiveRecord::Schema.define(:version => 20150818091800) do add_index "members", ["user_id", "project_id", "course_id"], :name => "index_members_on_user_id_and_project_id", :unique => true add_index "members", ["user_id"], :name => "index_members_on_user_id" + create_table "memo_messages", :force => true do |t| + t.integer "user_id" + t.integer "forum_id" + t.integer "memo_id" + t.string "memo_type" + t.integer "viewed" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "memos", :force => true do |t| t.integer "forum_id", :null => false t.integer "parent_id" @@ -1424,6 +1434,15 @@ ActiveRecord::Schema.define(:version => 20150818091800) do t.string "description", :default => "" end + create_table "user_feedback_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 "user_grades", :force => true do |t| t.integer "user_id", :null => false t.integer "project_id", :null => false @@ -1489,6 +1508,15 @@ ActiveRecord::Schema.define(:version => 20150818091800) 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 diff --git a/spec/factories/forum_messages.rb b/spec/factories/forum_messages.rb deleted file mode 100644 index adb114d3c..000000000 --- a/spec/factories/forum_messages.rb +++ /dev/null @@ -1,10 +0,0 @@ -FactoryGirl.define do - factory :forum_message do - user_id 1 -forum_id 1 -memo_message_id 1 -memo_message_type "MyString" -viewed 1 - end - -end diff --git a/spec/factories/memo_messages.rb b/spec/factories/memo_messages.rb new file mode 100644 index 000000000..edd5f7f54 --- /dev/null +++ b/spec/factories/memo_messages.rb @@ -0,0 +1,10 @@ +FactoryGirl.define do + factory :memo_message do + user_id 1 +forum_id 1 +memo_id 1 +memo_type "MyString" +viewed 1 + end + +end diff --git a/spec/factories/user_feedback_messages.rb b/spec/factories/user_feedback_messages.rb new file mode 100644 index 000000000..945d6d8b3 --- /dev/null +++ b/spec/factories/user_feedback_messages.rb @@ -0,0 +1,9 @@ +FactoryGirl.define do + factory :user_feedback_message do + user_id 1 +user_message_id 1 +user_message_type "MyString" +viewed 1 + end + +end diff --git a/spec/models/forum_message_spec.rb b/spec/models/memo_message_spec.rb similarity index 63% rename from spec/models/forum_message_spec.rb rename to spec/models/memo_message_spec.rb index e0159c3ca..a7921fc84 100644 --- a/spec/models/forum_message_spec.rb +++ b/spec/models/memo_message_spec.rb @@ -1,5 +1,5 @@ require 'rails_helper' -RSpec.describe ForumMessage, :type => :model do +RSpec.describe MemoMessage, :type => :model do pending "add some examples to (or delete) #{__FILE__}" end diff --git a/spec/models/user_feedback_message_spec.rb b/spec/models/user_feedback_message_spec.rb new file mode 100644 index 000000000..4ea61c36a --- /dev/null +++ b/spec/models/user_feedback_message_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe UserFeedbackMessage, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end From c8399cdf584670918db6db93a3a0a353cfeae1e6 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 19 Aug 2015 17:49:47 +0800 Subject: [PATCH 24/51] =?UTF-8?q?=E5=8E=BB=E6=8E=89forum?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 3 ++- app/models/journals_for_message.rb | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index f9ddc58f2..018cdf2e6 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -114,9 +114,10 @@ class UsersController < ApplicationController when nil @user_course_messages = @user.course_messages.reverse @user_forge_messages = @user.forge_messages.reverse - @user_forum_messages = @user.forum_messages.reverse + @user_memo_messages = @user.memo_messages.reverse @user_course_messages_count = @user_course_messages.count @user_forge_messages_count = @user_forum_messages.count + @user_memo_messages_count = @user_memo_messages.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 diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index f1bdc7e7c..c9a511ccc 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -204,7 +204,7 @@ class JournalsForMessage < ActiveRecord::Base # 主留言 receivers = [] if self.reply_id == 0 - if self.author_id != self.jour_id # 过滤自己给自己的留言消息 + if self.user_id != self.jour_id # 过滤自己给自己的留言消息 receivers << self.jour end else # 回帖 @@ -218,8 +218,8 @@ class JournalsForMessage < ActiveRecord::Base end end if self.jour_type == 'Principal' - if self.user_id != self.jour.user_id - self.user_feedback_messages << UserFeedbackMessage.new(:user_id => self.jour.user_id, :memo_message_id => self.id, :memo_message_type => "Forum", :viewed => false) + if self.user_id != self.jour_id + self.user_feedback_messages << UserFeedbackMessage.new(:user_id => self.jour_id, :user_message_id => self.id, :user_message_type => "Forum", :viewed => false) end end end From 6b6f6e0b0da72c440196ab5ca68b035e474cc5b6 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 20 Aug 2015 09:25:48 +0800 Subject: [PATCH 25/51] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5?= =?UTF-8?q?=E7=95=99=E8=A8=80=E6=B6=88=E6=81=AF=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 6 +++--- app/models/journals_for_message.rb | 17 ++++++++-------- app/models/user_feedback_message.rb | 10 ---------- ...20004659_create_user_feedback_messages.rb} | 4 ++-- db/schema.rb | 20 +++++-------------- spec/factories/user_feedback_messages.rb | 9 --------- spec/models/user_feedback_message_spec.rb | 5 ----- 7 files changed, 19 insertions(+), 52 deletions(-) delete mode 100644 app/models/user_feedback_message.rb rename db/migrate/{20150819072608_create_user_feedback_messages.rb => 20150820004659_create_user_feedback_messages.rb} (71%) delete mode 100644 spec/factories/user_feedback_messages.rb delete mode 100644 spec/models/user_feedback_message_spec.rb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 018cdf2e6..5badac36e 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -116,7 +116,7 @@ class UsersController < ApplicationController @user_forge_messages = @user.forge_messages.reverse @user_memo_messages = @user.memo_messages.reverse @user_course_messages_count = @user_course_messages.count - @user_forge_messages_count = @user_forum_messages.count + @user_forge_messages_count = @user_forge_messages.count @user_memo_messages_count = @user_memo_messages.count when 'homework' @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "HomeworkCommon", @user).order("created_at desc") @@ -147,8 +147,8 @@ class UsersController < ApplicationController @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Forum", @user).order("created_at desc") @user_forge_messages_count = @user_forge_messages.count when 'forum' - @user_forum_messages = Memo.where("memo_type =? and user_id =?", "Memo", @user).order("created_at desc") - @user_forum_messages_count = @user_forum_messages.count + @user_memo_messages = Memo.where("memo_type =? and user_id =?", "Memo", @user).order("created_at desc") + @user_memo_messages_count = @user_memo_messages.count else render_404 return diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index c9a511ccc..818bdaa74 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -207,19 +207,20 @@ class JournalsForMessage < ActiveRecord::Base if self.user_id != self.jour_id # 过滤自己给自己的留言消息 receivers << self.jour end - else # 回帖 - # 添加吧主 - if self.author_id != self.forum.creator_id - receivers << self.jour + else # 留言回复 + # 添加留言回复人 + if self.user_id != self.parent.user_id # 如果回帖人不是用户自己 + receivers << User.find(self.reply_id) end - # 添加发帖人 - if self.author_id != self.parent.author_id - receivers << self.parent.author + if self.user_id != self.parent.jour_id + receivers << self.parent.jour end end if self.jour_type == 'Principal' if self.user_id != self.jour_id - self.user_feedback_messages << UserFeedbackMessage.new(:user_id => self.jour_id, :user_message_id => self.id, :user_message_type => "Forum", :viewed => false) + receivers.each do |r| + self.user_feedback_messages << UserFeedbackMessage.new(:user_id => r.id, :journals_for_message_id => self.id, :journals_for_message_type => "Principal", :viewed => false) + end end end end diff --git a/app/models/user_feedback_message.rb b/app/models/user_feedback_message.rb deleted file mode 100644 index 7cd8f5132..000000000 --- a/app/models/user_feedback_message.rb +++ /dev/null @@ -1,10 +0,0 @@ -class UserFeedbackMessage < ActiveRecord::Base - attr_accessible :user_id, :user_message_id, :user_message_type, :viewed - - belongs_to :user - belongs_to :journals_for_message - - validates :user_id,presence: true - validates :user_message_id,presence: true - validates :user_message_type, presence: true -end diff --git a/db/migrate/20150819072608_create_user_feedback_messages.rb b/db/migrate/20150820004659_create_user_feedback_messages.rb similarity index 71% rename from db/migrate/20150819072608_create_user_feedback_messages.rb rename to db/migrate/20150820004659_create_user_feedback_messages.rb index 382841c47..c5f5b85d9 100644 --- a/db/migrate/20150819072608_create_user_feedback_messages.rb +++ b/db/migrate/20150820004659_create_user_feedback_messages.rb @@ -2,8 +2,8 @@ class CreateUserFeedbackMessages < ActiveRecord::Migration def change create_table :user_feedback_messages do |t| t.integer :user_id - t.integer :user_message_id - t.string :user_message_type + t.integer :journals_for_message_id + t.string :journals_for_message_type t.integer :viewed t.timestamps diff --git a/db/schema.rb b/db/schema.rb index fd1d98e58..ea1c37968 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20150819090720) do +ActiveRecord::Schema.define(:version => 20150820004659) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -572,16 +572,6 @@ ActiveRecord::Schema.define(:version => 20150819090720) 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_id" - t.string "memo_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" @@ -1436,11 +1426,11 @@ ActiveRecord::Schema.define(:version => 20150819090720) do create_table "user_feedback_messages", :force => true do |t| t.integer "user_id" - t.integer "user_message_id" - t.string "user_message_type" + t.integer "journals_for_message_id" + t.string "journals_for_message_type" t.integer "viewed" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "user_grades", :force => true do |t| diff --git a/spec/factories/user_feedback_messages.rb b/spec/factories/user_feedback_messages.rb deleted file mode 100644 index 945d6d8b3..000000000 --- a/spec/factories/user_feedback_messages.rb +++ /dev/null @@ -1,9 +0,0 @@ -FactoryGirl.define do - factory :user_feedback_message do - user_id 1 -user_message_id 1 -user_message_type "MyString" -viewed 1 - end - -end diff --git a/spec/models/user_feedback_message_spec.rb b/spec/models/user_feedback_message_spec.rb deleted file mode 100644 index 4ea61c36a..000000000 --- a/spec/models/user_feedback_message_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe UserFeedbackMessage, :type => :model do - pending "add some examples to (or delete) #{__FILE__}" -end From 88fe0a69f46179dcacf48b7393194df92201db24 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Thu, 20 Aug 2015 10:38:14 +0800 Subject: [PATCH 26/51] =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_messages.html.erb | 40 ++++++++++++++++++-------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 37dbfa3f7..a40a54e95 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -12,9 +12,15 @@ <% unless @user_course_messages_count > 0 %>
  • <%= link_to "作业消息",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'homework'} %>
  • <% end %> -
  • <%= link_to "课程讨论区",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'course_message'} %>
  • -
  • <%= link_to "发布了课程通知",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'course_news'} %>
  • -
  • <%= link_to "问卷调查",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'poll'} %>
  • + <% unless @user_course_messages_count > 0 %> +
  • <%= link_to "课程讨论区",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'course_message'} %>
  • + <% end %> + <% unless @user_course_messages_count > 0 %> +
  • <%= link_to "发布了课程通知",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'course_news'} %>
  • + <% end %> + <% unless @user_course_messages_count > 0 %> +
  • <%= link_to "问卷调查",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'poll'} %>
  • + <% end %> <% unless @user_course_messages_count > 0 %>
  • <%= link_to "作品评阅",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'works_reviewers'} %>
  • <% end %> @@ -22,14 +28,24 @@ <% end %> <%# 项目相关消息 %> <% unless @user_forge_messages.nil? %> -
  • <%= link_to "指派给我",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'issue'} %>
  • -
  • <%= link_to "更新了问题",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'issue_update'} %>
  • -
  • <%= link_to "项目讨论区",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forge_message'} %>
  • -
  • <%= link_to "发布了新闻",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forge_news'} %>
  • + <% unless @user_forge_messages_count > 0 %> +
  • <%= link_to "指派给我",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'issue'} %>
  • + <% end %> + <% unless @user_forge_messages_count > 0 %> +
  • <%= link_to "更新了问题",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'issue_update'} %>
  • + <% end %> + <% unless @user_forge_messages_count > 0 %> +
  • <%= link_to "项目讨论区",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forge_message'} %>
  • + <% end %> + <% unless @user_forge_messages_count > 0 %> +
  • <%= link_to "发布了新闻",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forge_news'} %>
  • + <% end %> <% end %> <%# 公共贴吧 %> <% unless @user_forum_messages.nil? %> + <% unless @user_memo_messages_count > 0 %>
  • <%= link_to "发布了帖子",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forum'} %>
  • + <% end %> <% end %> <%# 用户留言 %> @@ -179,9 +195,9 @@ <% end %> <% end %> <% end %> - <% unless @user_forum_messages.nil? %> - <% @user_forum_messages.each do |urm| %> - <% if urm.memo_message_type == "Forum" %> + <% unless @user_memo_messages.nil? %> + <% @user_memo_messages.each do |urm| %> + <% if urm.memo_type == "Memo" %> From 192f16ba795d91cb59f246f0e4fa80c929a63098 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 20 Aug 2015 10:38:22 +0800 Subject: [PATCH 27/51] =?UTF-8?q?=E4=BF=AE=E6=94=B9memo=E7=B1=BB=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=B0=E7=9A=84=E7=94=A8=E6=88=B7=E7=95=99?= =?UTF-8?q?=E8=A8=80=E8=A1=A8=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 2 +- app/models/journals_for_message.rb | 3 ++- app/models/user_feedback_message.rb | 10 ++++++++++ spec/factories/user_feedback_messages.rb | 9 +++++++++ spec/models/user_feedback_message_spec.rb | 5 +++++ 5 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 app/models/user_feedback_message.rb create mode 100644 spec/factories/user_feedback_messages.rb create mode 100644 spec/models/user_feedback_message_spec.rb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 5badac36e..74c3afaa7 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -147,7 +147,7 @@ class UsersController < ApplicationController @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Forum", @user).order("created_at desc") @user_forge_messages_count = @user_forge_messages.count when 'forum' - @user_memo_messages = Memo.where("memo_type =? and user_id =?", "Memo", @user).order("created_at desc") + @user_memo_messages = MemoMessage.where("memo_type =? and user_id =?", "Memo", @user).order("created_at desc") @user_memo_messages_count = @user_memo_messages.count else render_404 diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 818bdaa74..305e7742f 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -209,7 +209,8 @@ class JournalsForMessage < ActiveRecord::Base end else # 留言回复 # 添加留言回复人 - if self.user_id != self.parent.user_id # 如果回帖人不是用户自己 + # reply_to = User.find(self.reply_id) + if self.user_id != self.parent.user_id && self.user_id != self.reply_id # 如果回帖人不是用户自己 receivers << User.find(self.reply_id) end if self.user_id != self.parent.jour_id diff --git a/app/models/user_feedback_message.rb b/app/models/user_feedback_message.rb new file mode 100644 index 000000000..98b53e973 --- /dev/null +++ b/app/models/user_feedback_message.rb @@ -0,0 +1,10 @@ +class UserFeedbackMessage < ActiveRecord::Base + attr_accessible :journals_for_message_id, :journals_for_message_type, :user_id, :viewed + + belongs_to :journals_for_message + belongs_to :user + + validates :user_id,presence: true + validates :journals_for_message_id,presence: true + validates :journals_for_message_type, presence: true +end diff --git a/spec/factories/user_feedback_messages.rb b/spec/factories/user_feedback_messages.rb new file mode 100644 index 000000000..26a768dad --- /dev/null +++ b/spec/factories/user_feedback_messages.rb @@ -0,0 +1,9 @@ +FactoryGirl.define do + factory :user_feedback_message do + user_id 1 +journals_for_message_id 1 +journals_for_message_type "MyString" +viewed 1 + end + +end diff --git a/spec/models/user_feedback_message_spec.rb b/spec/models/user_feedback_message_spec.rb new file mode 100644 index 000000000..4ea61c36a --- /dev/null +++ b/spec/models/user_feedback_message_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe UserFeedbackMessage, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end From b5682adcd3aa7c524200ccba0e17e9f1a566586d Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 20 Aug 2015 10:50:40 +0800 Subject: [PATCH 28/51] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 1 + app/models/journals_for_message.rb | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 74c3afaa7..6c91fd805 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -131,6 +131,7 @@ class UsersController < ApplicationController @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 '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 diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 305e7742f..ce58fdc69 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -210,12 +210,13 @@ class JournalsForMessage < ActiveRecord::Base else # 留言回复 # 添加留言回复人 # reply_to = User.find(self.reply_id) - if self.user_id != self.parent.user_id && self.user_id != self.reply_id # 如果回帖人不是用户自己 + if self.user_id != self.parent.user_id && self.user_id != self.reply_id && self.user_id != self.jour_id# 如果回帖人不是用户自己 receivers << User.find(self.reply_id) - end - if self.user_id != self.parent.jour_id receivers << self.parent.jour end + # if self.user_id != self.parent.jour_id + # receivers << self.parent.jour + # end end if self.jour_type == 'Principal' if self.user_id != self.jour_id From 84182171f5d6d4082f33634edb9e9f0a19d09a2d Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Thu, 20 Aug 2015 12:41:53 +0800 Subject: [PATCH 29/51] =?UTF-8?q?=E6=B6=88=E6=81=AF=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_messages.html.erb | 30 ++++++++++++++------------ 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index a40a54e95..2e53dfe6e 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -9,42 +9,44 @@
  • <%= link_to "全部",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user} %>
  • <%# 课程相关消息 %> <% unless @user_course_messages.nil? %> - <% unless @user_course_messages_count > 0 %> + <% if @user_course_messages_count > 0 %>
  • <%= link_to "作业消息",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'homework'} %>
  • <% end %> - <% unless @user_course_messages_count > 0 %> + <% if @user_course_messages_count > 0 %>
  • <%= link_to "课程讨论区",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'course_message'} %>
  • <% end %> - <% unless @user_course_messages_count > 0 %> + <% if @user_course_messages_count > 0 %>
  • <%= link_to "发布了课程通知",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'course_news'} %>
  • <% end %> - <% unless @user_course_messages_count > 0 %> + <% if @user_course_messages_count > 0 %>
  • <%= link_to "问卷调查",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'poll'} %>
  • <% end %> - <% unless @user_course_messages_count > 0 %> -
  • <%= link_to "作品评阅",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'works_reviewers'} %>
  • + <% if @user_course_messages_count > 0 %> +
  • <%= link_to "作品评阅",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'works_reviewers'} %>
  • + <% end %> + <% if @user_course_messages_count > 0 %> +
  • <%= link_to "作品讨论",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'works_reply'} %>
  • <% end %> -
  • <%= link_to "作品讨论",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'works_reply'} %>
  • <% end %> <%# 项目相关消息 %> <% unless @user_forge_messages.nil? %> - <% unless @user_forge_messages_count > 0 %> + <% if @user_forge_messages_count > 0 %>
  • <%= link_to "指派给我",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'issue'} %>
  • <% end %> - <% unless @user_forge_messages_count > 0 %> + <% if @user_forge_messages_count > 0 %>
  • <%= link_to "更新了问题",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'issue_update'} %>
  • <% end %> - <% unless @user_forge_messages_count > 0 %> + <% if @user_forge_messages_count > 0 %>
  • <%= link_to "项目讨论区",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forge_message'} %>
  • <% end %> - <% unless @user_forge_messages_count > 0 %> + <% if @user_forge_messages_count > 0 %>
  • <%= link_to "发布了新闻",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forge_news'} %>
  • <% end %> <% end %> <%# 公共贴吧 %> - <% unless @user_forum_messages.nil? %> - <% unless @user_memo_messages_count > 0 %> -
  • <%= link_to "发布了帖子",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forum'} %>
  • + <% unless @user_memo_messages.nil? %> + <% if @user_memo_messages_count > 0 %> +
  • <%= link_to "发布了xiang帖子",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forum'} %>
  • <% end %> <% end %> <%# 用户留言 %> From e4dda89c075b51f98cb855697bb4af04893962d5 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 20 Aug 2015 12:44:32 +0800 Subject: [PATCH 30/51] =?UTF-8?q?=E6=B6=88=E6=81=AF---=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=95=99=E8=A8=80=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 8 ++++++- app/models/journals_for_message.rb | 29 ++++++++++++++------------ app/views/users/user_messages.html.erb | 28 ++++++++++++++++++++++++- 3 files changed, 50 insertions(+), 15 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 6c91fd805..686ffbb89 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -98,7 +98,7 @@ class UsersController < ApplicationController # 用户消息 # 说明: homework 发布作业;message:讨论区; news:新闻; poll:问卷;works_reviewers:作品评阅;works_reply:作品回复 - # issue:问题;journal:缺陷状态更新; forum:公共贴吧 + # issue:问题;journal:缺陷状态更新; forum:公共贴吧: user_feedback: 用户留言 def user_messages unless User.current.logged? render_403 @@ -115,9 +115,11 @@ class UsersController < ApplicationController @user_course_messages = @user.course_messages.reverse @user_forge_messages = @user.forge_messages.reverse @user_memo_messages = @user.memo_messages.reverse + @user_feedback_messages = @user.user_feedback_messages.reverse @user_course_messages_count = @user_course_messages.count @user_forge_messages_count = @user_forge_messages.count @user_memo_messages_count = @user_memo_messages.count + @user_feedback_messages_count = @user_feedback_messages.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 @@ -126,6 +128,7 @@ class UsersController < ApplicationController @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 @@ -150,6 +153,9 @@ class UsersController < ApplicationController 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 =?", "Principal", @user).order("created_at desc") + @user_feedback_messages_count = @user_feedback_messages.count else render_404 return diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index ce58fdc69..2c397ffcf 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -209,21 +209,24 @@ class JournalsForMessage < ActiveRecord::Base end else # 留言回复 # 添加留言回复人 - # reply_to = User.find(self.reply_id) - if self.user_id != self.parent.user_id && self.user_id != self.reply_id && self.user_id != self.jour_id# 如果回帖人不是用户自己 - receivers << User.find(self.reply_id) - receivers << self.parent.jour - end - # if self.user_id != self.parent.jour_id - # receivers << self.parent.jour - # end - end - if self.jour_type == 'Principal' - if self.user_id != self.jour_id - receivers.each do |r| - self.user_feedback_messages << UserFeedbackMessage.new(:user_id => r.id, :journals_for_message_id => self.id, :journals_for_message_type => "Principal", :viewed => false) + reply_to = User.find(self.reply_id) + if self.user_id != self.parent.user_id # 如果回帖人不是用户自己 + receivers << self.parent.jour + if self.reply_id != self.parent.user_id + receivers << reply_to + end + else # 用户自己回复别人的,别人收到消息通知 + if self.user_id != self.reply_id # 过滤掉自己回复自己的 + receivers << reply_to end end end + if self.jour_type == 'Principal' + + receivers.each do |r| + self.user_feedback_messages << UserFeedbackMessage.new(:user_id => r.id, :journals_for_message_id => self.id, :journals_for_message_type => "Principal", :viewed => false) + end + + end end end diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index a40a54e95..cb7fb0e60 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -25,6 +25,7 @@
  • <%= link_to "作品评阅",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'works_reviewers'} %>
  • <% end %>
  • <%= link_to "作品讨论",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'works_reply'} %>
  • + <% end %> <%# 项目相关消息 %> <% unless @user_forge_messages.nil? %> @@ -44,10 +45,15 @@ <%# 公共贴吧 %> <% unless @user_forum_messages.nil? %> <% unless @user_memo_messages_count > 0 %> -
  • <%= link_to "发布了帖子",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forum'} %>
  • +
  • <%= link_to "发布了帖子",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forum'} %>
  • <% end %> <% end %> <%# 用户留言 %> + <% unless @user_forge_messages.nil? %> + <% unless @user_forge_messages_count > 0 %> +
  • <%= link_to "用户留言",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'user_feedback'} %>
  • + <% end %> + <% end %> @@ -214,6 +220,26 @@ <% end %> <% end %> <% end %> + <%# 用户留言消息 %> + <% unless @user_feedback_messages.nil? %> + <% @user_forge_messages.each do |urm| %> + <% if urm.memo_type == "Memo" %> + + <% end %> + <% end %> + <% end %> <% else %>
    暂无消息!
    <% end %> From ee09a105d2eba38fa53250cb8302c2224bf155ba Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Thu, 20 Aug 2015 12:46:31 +0800 Subject: [PATCH 31/51] =?UTF-8?q?=E8=B4=B4=E5=90=A7=E5=B8=96=E5=AD=90?= =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_messages.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 2e53dfe6e..c34a31a3c 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -46,7 +46,7 @@ <%# 公共贴吧 %> <% unless @user_memo_messages.nil? %> <% if @user_memo_messages_count > 0 %> -
  • <%= link_to "发布了xiang帖子",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forum'} %>
  • +
  • <%= link_to "发布了帖子",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forum'} %>
  • <% end %> <% end %> <%# 用户留言 %> From 6b847e27d98db77189acb5b784771ff3f644cfee Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 20 Aug 2015 14:00:31 +0800 Subject: [PATCH 32/51] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/journals_for_message.rb | 4 ++-- app/views/users/user_messages.html.erb | 30 ++++++++++++++++---------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 2c397ffcf..bb59f612d 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -210,8 +210,8 @@ class JournalsForMessage < ActiveRecord::Base else # 留言回复 # 添加留言回复人 reply_to = User.find(self.reply_id) - if self.user_id != self.parent.user_id # 如果回帖人不是用户自己 - receivers << self.parent.jour + if self.user_id != self.parent.user_id && self.user_id != self.parent.jour_id # 如果回帖人不是用户自己 + receivers << self.parent.user if self.reply_id != self.parent.user_id receivers << reply_to end diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 80deeb8f6..adfc6290b 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -51,8 +51,8 @@ <% end %> <% end %> <%# 用户留言 %> - <% unless @user_forge_messages.nil? %> - <% unless @user_forge_messages_count > 0 %> + <% unless @user_feedback_messages.nil? %> + <% if @user_feedback_messages_count > 0 %>
  • <%= link_to "用户留言",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'user_feedback'} %>
  • <% end %> <% end %> @@ -224,20 +224,28 @@ <% end %> <%# 用户留言消息 %> <% unless @user_feedback_messages.nil? %> - <% @user_forge_messages.each do |urm| %> - <% if urm.memo_type == "Memo" %> + <% @user_feedback_messages.each do |ufm| %> + <% if ufm.journals_for_message_type == "Principal" %> <% end %> <% end %> From b40122c9eeff9d52290ea8cbf7fb41b50bc288a6 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 20 Aug 2015 14:18:16 +0800 Subject: [PATCH 33/51] =?UTF-8?q?=E8=B7=9F=E6=96=B0issue=E7=8A=B6=E6=80=81?= =?UTF-8?q?=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 2 +- app/views/users/user_messages.html.erb | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 686ffbb89..f6ff5fd5d 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -147,7 +147,7 @@ class UsersController < ApplicationController 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 'journal' # 缺陷状态更新、留言 + when 'issue_update' # 缺陷状态更新、留言 @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Forum", @user).order("created_at desc") @user_forge_messages_count = @user_forge_messages.count when 'forum' diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index c9de406bf..fcc2d36e7 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -211,11 +211,11 @@ <%= image_tag(url_to_avatar(urm.memo.author), :width => "30", :height => "30") %>
  • - "><%= urm.memo.author %> + <%= urm.memo.author %>
  • -
  • ">回复了贴吧帖子
  • +
  • 回复了贴吧帖子
  • - <%= link_to urm.memo.subject, forum_memo_path(urm.memo.forum_id, urm.memo.parent_id ? urm.memo.parent_id: urm.memo.id),:class => "#{urm.viewed == 0 ? "newsBlack" : "newsGrey"}" %> + <%= link_to urm.memo.subject, forum_memo_path(urm.memo.forum_id, urm.memo.parent_id ? urm.memo.parent_id: urm.memo.id),:class => "newsGrey" %>
  • <%= time_tag(urm.memo.created_at).html_safe %>
  • @@ -231,18 +231,18 @@ <%= image_tag(url_to_avatar(ufm.journals_for_message.user), :width => "30", :height => "30") %>
  • - "><%= ufm.journals_for_message.user %> + <%= ufm.journals_for_message.user %>
  • <% if ufm.journals_for_message.reply_id == 0 %> -
  • ">给你留言了
  • +
  • 给你留言了
  • - <%= link_to ufm.journals_for_message.notes, feedback_path(ufm.journals_for_message.jour_id),:class => "#{ufm.viewed == 0 ? "newsBlack" : "newsGrey"}" %> + <%= link_to ufm.journals_for_message.notes, feedback_path(ufm.journals_for_message.jour_id), :class => "newsGrey" %>
  • <% else %> -
  • ">回复了你的留言
  • +
  • 回复了你的留言
  • - <%= link_to ufm.journals_for_message.notes, feedback_path(ufm.journals_for_message.parent.user_id),:class => "#{ufm.viewed == 0 ? "newsBlack" : "newsGrey"}" %> + <%= link_to ufm.journals_for_message.notes, feedback_path(ufm.journals_for_message.parent.user_id),:class => "newsGrey" %>
  • <% end %>
  • <%= time_tag(ufm.journals_for_message.created_on).html_safe %>
  • From 93f44287aad19ebbb4b20d909e4b3043b56cb6b7 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 20 Aug 2015 14:32:46 +0800 Subject: [PATCH 34/51] =?UTF-8?q?jounal=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 2 +- app/views/users/user_messages.html.erb | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index f6ff5fd5d..724a62a67 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -148,7 +148,7 @@ class UsersController < ApplicationController @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 =?", "Forum", @user).order("created_at desc") + @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") diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index fcc2d36e7..03934b9aa 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -47,7 +47,7 @@ <%# 公共贴吧 %> <% unless @user_memo_messages.nil? %> <% if @user_memo_messages_count > 0 %> -
  • <%= link_to "发布了帖子",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forum'} %>
  • +
  • <%= link_to "贴吧帖子",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forum'} %>
  • <% end %> <% end %> <%# 用户留言 %> @@ -63,6 +63,7 @@
    <% if @new_message_count >0 %> + <%# 课程消息 %> <% unless @user_course_messages.nil? %> <% @user_course_messages.each do |ucm| %> <% if ucm.course_message_type == "News" %> @@ -203,9 +204,10 @@ <% end %> <% end %> <% end %> + <%# 公共贴吧 %> <% unless @user_memo_messages.nil? %> <% @user_memo_messages.each do |urm| %> - <% if urm.memo_type == "Memo" %> + <% if urm.memo_type == "forum" %> @@ -43,6 +46,16 @@
  • <%= time_tag(ucm.course_message.created_on).html_safe %>
  • <% end %> + <% if ucm.course_message_type == "Comment" %> + + <% end %> <% if ucm.course_message_type == "HomeworkCommon" %> <% end %> + <% if ufm.forge_message_type == "Comment" %> + + <% end %> <% end %> <% end %> <%# 公共贴吧 %> From 840caf18f3ed2b11ce927a21c8ee0f318c66df54 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 20 Aug 2015 17:40:01 +0800 Subject: [PATCH 39/51] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 08101fe5d..1748c5a07 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -105,17 +105,23 @@ class UsersController < ApplicationController return end # 当前用户查看消息,则设置消息为已读 - querys = @user.course_messages + 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 - querys.update_all(:viewed => true) + 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_course_messages = @user.course_messages.reverse - @user_forge_messages = @user.forge_messages.reverse - @user_memo_messages = @user.memo_messages.reverse - @user_feedback_messages = @user.user_feedback_messages.reverse + @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") + @user_feedback_messages = UserFeedbackMessage.where("user_id =?",@user).order("created_at desc") @user_course_messages_count = @user_course_messages.count @user_forge_messages_count = @user_forge_messages.count @user_memo_messages_count = @user_memo_messages.count From 893c1c753f7f8e971deaa42b9aa1559a3e594b52 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 20 Aug 2015 18:54:01 +0800 Subject: [PATCH 40/51] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=95=99=E8=A8=80?= =?UTF-8?q?=E5=B5=8C=E5=A5=97=E5=9B=9E=E5=A4=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/journals_for_message.rb | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index bb59f612d..853376f6a 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -208,18 +208,28 @@ class JournalsForMessage < ActiveRecord::Base receivers << self.jour end else # 留言回复 - # 添加留言回复人 reply_to = User.find(self.reply_id) - if self.user_id != self.parent.user_id && self.user_id != self.parent.jour_id # 如果回帖人不是用户自己 - receivers << self.parent.user + if self.user_id != self.parent.user_id + receivers << reply_to if self.reply_id != self.parent.user_id - receivers << reply_to - end - else # 用户自己回复别人的,别人收到消息通知 - if self.user_id != self.reply_id # 过滤掉自己回复自己的 - receivers << reply_to + receivers << self.parent.user end + else + receivers << reply_to end + + # 添加留言回复人 + #reply_to = User.find(self.reply_id) + #if self.user_id != self.parent.user_id && self.user_id != self.parent.jour_id # 如果回帖人不是用户自己 + # receivers << self.parent.user + # if self.reply_id != self.parent.user_id + # receivers << reply_to + # end + #else # 用户自己回复别人的,别人收到消息通知 + # if self.user_id != self.reply_id # 过滤掉自己回复自己的 + # receivers << reply_to + # end + #end end if self.jour_type == 'Principal' From ef45e41a40a1ed2b5e6f5e62514cc66b7cbb5e15 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 21 Aug 2015 09:41:59 +0800 Subject: [PATCH 41/51] =?UTF-8?q?=E6=96=B0=E6=B6=88=E6=81=AF=E6=8F=90?= =?UTF-8?q?=E9=86=92=E3=80=82=E8=A1=A8=E6=83=85=E6=8F=92=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user.rb | 6 +- app/views/users/user_messages.html.erb | 381 ++++++++++++------------- 2 files changed, 189 insertions(+), 198 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 3a57d6217..99604c798 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -256,7 +256,11 @@ class User < Principal # 新消息统计 def count_new_message - count = CourseMessage.where("user_id =? and viewed =?", User.current.id, 0).count + course_count = CourseMessage.where("user_id =? and viewed =?", User.current.id, 0).count + forge_count = ForgeMessage.where("user_id =? and viewed =?", User.current.id, 0).count + user_feedback_count = UserFeedbackMessage.where("user_id =? and viewed =?", User.current.id, 0).count + user_memo_count = MemoMessage.where("user_id =? and viewed =?", User.current.id, 0).count + messages_count = course_count + forge_count + user_feedback_count + user_memo_count end # 查询指派给我的缺陷记录 def issue_status_update diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 7a8d98668..602e3c5c9 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -32,219 +32,206 @@
    - <% if @new_message_count >0 %> - <%# 课程消息 %> - <% unless @user_course_messages.nil? %> - <% @user_course_messages.each do |ucm| %> - <% if ucm.course_message_type == "News" %> - - <% end %> - <% if ucm.course_message_type == "Comment" %> +<% if @new_message_count >0 %> + <%# 课程消息 %> + <% unless @user_course_messages.nil? %> + <% @user_course_messages.each do |ucm| %> + <% if ucm.course_message_type == "News" %> + + <% end %> + <% if ucm.course_message_type == "Comment" %> - <% end %> - <% if ucm.course_message_type == "HomeworkCommon" %> - - <% end %> - <% if ucm.course_message_type == "Poll" %> - - <% end %> - <% if ucm.course_message_type == "Message" %> - - <% end %> - <% if ucm.course_message_type == "StudentWorksScore" %> - - <% end %> - <% if ucm.course_message_type == "JournalsForMessage" %> - - <% end %> -
    - <% end %> - <% end %> - - <% unless @user_forge_messages.nil? %> - <% @user_forge_messages.each do |ufm| %> - <% if ufm.forge_message_type == "Issue" %> - - <% end %> - <% if ufm.forge_message_type == "Journal" %> - - <% end %> - <% if ufm.forge_message_type == "Message" %> - - <% end %> - <% if ufm.forge_message_type == "News" %> - - <% end %> + <% end %> + <% if ucm.course_message_type == "HomeworkCommon" %> + + <% end %> + <% if ucm.course_message_type == "Poll" %> + + <% end %> + <% if ucm.course_message_type == "Message" %> + + <% end %> + <% if ucm.course_message_type == "StudentWorksScore" %> + + <% end %> + <% if ucm.course_message_type == "JournalsForMessage" %> + + <% end %> +
    + <% end %> + <% end %> + + <% unless @user_forge_messages.nil? %> + <% @user_forge_messages.each do |ufm| %> + <% if ufm.forge_message_type == "Issue" %> + + <% end %> + <% if ufm.forge_message_type == "Journal" %> + + <% end %> + <% if ufm.forge_message_type == "Message" %> + + <% end %> + <% if ufm.forge_message_type == "News" %> + + <% end %> <% if ufm.forge_message_type == "Comment" %> <% end %> - <% end %> - <% end %> - <%# 公共贴吧 %> - <% unless @user_memo_messages.nil? %> - <% @user_memo_messages.each do |urm| %> - <% if urm.memo_type == "Memo" %> - - <% end %> - <% end %> - <% end %> - <%# 用户留言消息 %> - <% unless @user_feedback_messages.nil? %> - <% @user_feedback_messages.each do |ufm| %> - <% if ufm.journals_for_message_type == "Principal" %> - - <% end %> - <% end %> - <% end %> - <% else %> -
    暂无消息!
    - <% end %> + <% end %> + <% end %> + <%# 公共贴吧 %> + <% unless @user_memo_messages.nil? %> + <% @user_memo_messages.each do |urm| %> + <% if urm.memo_type == "Memo" %> + + <% end %> + <% end %> + <% end %> + <%# 用户留言消息 %> + <% unless @user_feedback_messages.nil? %> + <% @user_feedback_messages.each do |ufm| %> + <% if ufm.journals_for_message_type == "Principal" %> + + <% end %> + <% end %> + <% end %> +<% else %> +
    暂无消息!
    +<% end %>
    From 9b827a698cc4b2f003e22a3bec4b52303c725be9 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 21 Aug 2015 10:02:58 +0800 Subject: [PATCH 42/51] =?UTF-8?q?=E9=BC=A0=E6=A0=87=E7=BB=8F=E8=BF=87?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=E6=98=BE=E7=A4=BA=E5=AE=8C=E6=95=B4?= =?UTF-8?q?=E7=9A=84=E6=A0=87=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_messages.html.erb | 46 +++++++++++++++++--------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 602e3c5c9..c9b17d09f 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -42,7 +42,9 @@
  • "><%= ucm.course_message.author %>
  • ">发布通知
  • - <%= link_to "#{ucm.course_message.title.html_safe}", {:controller => 'news', :action => 'show', :id => ucm.course_message.id },:class =>"#{ucm.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
  • + <%= link_to "#{ucm.course_message.title.html_safe}", {:controller => 'news', :action => 'show', :id => ucm.course_message.id }, + :class =>"#{ucm.viewed == 0 ? "newsBlack" : "newsGrey"}", + :title => "#{ucm.course_message.title.html_safe}" %>
  • <%= time_tag(ucm.course_message.created_on).html_safe %>
  • <% end %> @@ -52,7 +54,9 @@
  • <%= ucm.course_message.author %>
  • ">回复了通知
  • - <%= link_to "#{ucm.course_message.comments.html_safe}", {:controller => 'news', :action => 'show', :id => ucm.course_message.commented.id },:class =>"#{ucm.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
  • + <%= link_to "#{ucm.course_message.comments.html_safe}", {:controller => 'news', :action => 'show', :id => ucm.course_message.commented.id }, + :class =>"#{ucm.viewed == 0 ? "newsBlack" : "newsGrey"}", + :title => "#{ucm.course_message.comments.html_safe}" %>
  • <%= time_tag(ucm.course_message.created_on).html_safe %>
  • <% end %> @@ -62,7 +66,7 @@
  • <%= ucm.course_message.user %>
  • 发布作业
  • - <%= link_to ("#{ucm.course_message.name}"), student_work_index_path(:homework => ucm.course_message.id),:class => "newsGrey" %>
  • + <%= link_to ("#{ucm.course_message.name}"), student_work_index_path(:homework => ucm.course_message.id),:class => "newsGrey", :title => "#{ucm.course_message.name}" %>
  • <%= time_tag(ucm.course_message.created_at).html_safe %>
  • <% end %> @@ -72,7 +76,9 @@
  • "><%= ucm.course_message.user %>
  • ">发布问卷
  • - <%= link_to format_activity_title(" #{ucm.course_message.polls_name}"), poll_index_path(:polls_type => "Course", :polls_group_id => ucm.course_id),:class=>"#{ucm.viewed==0?"newsBlack":"newsGrey"}" %>
  • + <%= link_to format_activity_title(" #{ucm.course_message.polls_name}"), poll_index_path(:polls_type => "Course", :polls_group_id => ucm.course_id), + :class=>"#{ucm.viewed==0?"newsBlack":"newsGrey"}", + :title => "#{ucm.course_message.polls_name}" %>
  • <%= time_tag(ucm.course_message.created_at).html_safe %>
  • <% end %> @@ -83,12 +89,16 @@ <% if ucm.course_message.parent_id.nil? %>
  • ">发布帖子
  • - <%=link_to ucm.course_message.subject.html_safe, 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),:class=>"#{ucm.viewed==0?"newsBlack":"newsGrey"}" %>
  • + <%=link_to ucm.course_message.subject.html_safe, 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),:class=>"#{ucm.viewed==0?"newsBlack":"newsGrey"}", + :title => "#{ucm.course_message.subject.html_safe}" %>
  • <%= time_tag(ucm.course_message.created_on).html_safe %>
  • <% else %>
  • ">回复帖子
  • - <%=link_to ucm.course_message.subject.html_safe, 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),:class=>"#{ucm.viewed==0?"newsBlack":"newsGrey"}" %>
  • + <%=link_to ucm.course_message.subject.html_safe, 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),:class=>"#{ucm.viewed==0?"newsBlack":"newsGrey"}", + :title => "#{ucm.course_message.subject.html_safe}" %>
  • <%= time_tag(ucm.course_message.created_on).html_safe %>
  • <% end %> @@ -99,7 +109,7 @@
  • <%= ucm.course_message.user %>
  • 评阅了作品
  • - <%= link_to ucm.course_message.comment.html_safe, student_work_index_path(:homework => ucm.course_message.student_work.homework_common_id),:class=>"newsGrey" %>
  • + <%= link_to ucm.course_message.comment.html_safe, student_work_index_path(:homework => ucm.course_message.student_work.homework_common_id),:class=>"newsGrey",:title => "#{ucm.course_message.comment.html_safe}" %>
  • <%= time_tag(ucm.course_message.created_at).html_safe %>
  • <% end %> @@ -109,7 +119,7 @@
  • <%= ucm.course_message.user %>
  • 回复了作品
  • - <%= link_to ucm.course_message.notes.html_safe, student_work_index_path(:homework => ucm.course_message.jour.student_work.homework_common_id),:class=>"newsGrey" %>
  • + <%= link_to ucm.course_message.notes.html_safe, student_work_index_path(:homework => ucm.course_message.jour.student_work.homework_common_id),:class=>"newsGrey",:title => "#{ucm.course_message.notes.html_safe}" %>
  • <%= time_tag(ucm.course_message.created_on).html_safe %>
  • <% end %> @@ -129,7 +139,7 @@
  • ">指派问题给我
  • - <%= link_to ("#{ufm.forge_message.subject.html_safe}"), issue_path(:id => ufm.forge_message.id), :class => "#{ufm.viewed == 0 ? "newsBlack" : "newsGrey"}" %> + <%= link_to ("#{ufm.forge_message.subject.html_safe}"), issue_path(:id => ufm.forge_message.id), :class => "#{ufm.viewed == 0 ? "newsBlack" : "newsGrey"}",:title => "#{ufm.forge_message.subject.html_safe}" %>
  • <%= time_tag(ufm.forge_message.created_on).html_safe %>
  • @@ -145,7 +155,9 @@
  • "> <%= ufm.forge_message.notes.empty? ? "更新了问题状态" : "在问题中留言了" %>
  • - <%= link_to ("#{ufm.forge_message.notes.empty? ? ufm.forge_message.issue.subject.html_safe : ufm.forge_message.notes.html_safe }"), issue_path(:id => ufm.forge_message.journalized_id), :class => "#{ufm.viewed == 0 ? "newsBlack" : "newsGrey"}" %> + <%= link_to ("#{ufm.forge_message.notes.empty? ? ufm.forge_message.issue.subject.html_safe : ufm.forge_message.notes.html_safe }"), + issue_path(:id => ufm.forge_message.journalized_id), :class => "#{ufm.viewed == 0 ? "newsBlack" : "newsGrey"}", + :title => "#{ufm.forge_message.notes.empty? ? ufm.forge_message.issue.subject.html_safe : ufm.forge_message.notes.html_safe }" %>
  • <%= time_tag(ufm.forge_message.created_on).html_safe %>
  • @@ -157,7 +169,10 @@
  • "><%= ufm.forge_message.parent_id.nil? ? "发布帖子" : "回复帖子" %>
  • - <%=link_to ufm.forge_message.subject.html_safe, project_boards_path(ufm.forge_message.project,:parent_id => ufm.forge_message.parent_id ? ufm.forge_message.parent_id : ufm.forge_message.id, :topic_id => ufm.forge_message.id),:class=>"#{ufm.viewed==0?"newsBlack":"newsGrey"}" %>
  • + <%=link_to ufm.forge_message.subject.html_safe, project_boards_path(ufm.forge_message.project, + :parent_id => ufm.forge_message.parent_id ? ufm.forge_message.parent_id : ufm.forge_message.id, + :topic_id => ufm.forge_message.id),:class=>"#{ufm.viewed==0?"newsBlack":"newsGrey"}", + :title => "#{ufm.forge_message.subject.html_safe}" %>
  • <%= time_tag(ufm.forge_message.created_on).html_safe %>
  • @@ -172,7 +187,7 @@
  • 发布新闻
  • - <%= link_to ("#{ufm.forge_message.title.html_safe}"), {:controller => 'news', :action => 'show', :id => ufm.forge_message.id}, :class => "newsGrey" %> + <%= link_to ("#{ufm.forge_message.title.html_safe}"), {:controller => 'news', :action => 'show', :id => ufm.forge_message.id}, :class => "newsGrey", :title => "#{ufm.forge_message.title.html_safe}" %>
  • <%= time_tag(ufm.forge_message.created_on).html_safe %>
  • @@ -183,7 +198,8 @@
  • <%= ufm.forge_message.author %>
  • 回复了新闻
  • - <%= link_to "#{ufm.forge_message.comments.html_safe}", {:controller => 'news', :action => 'show', :id => ufm.forge_message.commented.id },:class =>"#{ufm.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
  • + <%= link_to "#{ufm.forge_message.comments.html_safe}", + {:controller => 'news', :action => 'show', :id => ufm.forge_message.commented.id },:class =>"#{ufm.viewed == 0 ? "newsBlack" : "newsGrey"}", :title => "#{ufm.forge_message.comments.html_safe}"%>
  • <%= time_tag(ufm.forge_message.created_on).html_safe %>
  • <% end %> @@ -202,7 +218,7 @@
  • 回复了贴吧帖子
  • - <%= link_to urm.memo.content.html_safe, forum_memo_path(urm.memo.forum_id, urm.memo.parent_id ? urm.memo.parent_id: urm.memo.id),:class => "newsGrey" %> + <%= link_to urm.memo.content.html_safe, forum_memo_path(urm.memo.forum_id, urm.memo.parent_id ? urm.memo.parent_id: urm.memo.id),:class => "newsGrey" , :title => "#{urm.memo.content.html_safe}" %>
  • <%= time_tag(urm.memo.created_at).html_safe %>
  • @@ -222,7 +238,7 @@
  • <%= ufm.journals_for_message.reply_id == 0 ? "给你留言了" : "回复了你的留言" %>
  • - <%= link_to ufm.journals_for_message.notes.html_safe, feedback_path(ufm.journals_for_message.jour_id), :class => "newsGrey" %> + <%= link_to ufm.journals_for_message.notes.html_safe, feedback_path(ufm.journals_for_message.jour_id), :class => "newsGrey", :title => "#{ufm.journals_for_message.notes.html_safe}" %>
  • <%= time_tag(ufm.journals_for_message.created_on).html_safe %>
  • From 947fcc160c15e1d6909d54334f63ffabe5c6a2fe Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 21 Aug 2015 10:49:13 +0800 Subject: [PATCH 43/51] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E6=A0=B7=E5=BC=8F=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/stylesheets/public_new.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/stylesheets/public_new.css b/public/stylesheets/public_new.css index 1d4874192..86848047d 100644 --- a/public/stylesheets/public_new.css +++ b/public/stylesheets/public_new.css @@ -590,7 +590,7 @@ a.homepageMenuText {color:#484848; font-size:16px; margin-left:20px;} .homepageNewsPublisher {width:80px; max-width:80px; margin-right:10px; font-size:12px; color:#15bccf; display:block; padding-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; } .homepageNewsType {width:95px; font-size:12px; color:#888888; display:block;} .homepageNewsTypeNotRead {width:95px; font-size:12px; color:#888888; display:block;} -.homepageNewsContent {width:395px; max-width:395px; margin-right:10px; font-size:12px; color:#4b4b4b; display:block; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; } +.homepageNewsContent {width:395px; max-width:395px; margin-right:10px; font-size:12px; color:#4b4b4b; display:block; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; overflow: hidden;height:49px; max-height:49px;} .homepageNewsTime {width:75px; font-size:12px; color:#888888; display:block; text-align:right;} a.homepageWhite {color:#ffffff;} a.homepageWhite:hover {color:#a1ebff} From 580735ef79535b0e38ee36784adb254c253ef597 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 21 Aug 2015 11:28:10 +0800 Subject: [PATCH 44/51] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E7=9A=84=E5=85=B3=E8=81=94=E7=9A=84500=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/news.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/news.rb b/app/models/news.rb index 30e4b0f55..6e2725d1c 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -23,7 +23,7 @@ class News < ActiveRecord::Base #added by nwb belongs_to :course belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' - has_many :comments, :as => :commented, :dependent => :delete_all, :order => "created_on" + has_many :comments, :as => :commented, :dependent => :destroy, :order => "created_on" # fq has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy # 被ForgeActivity虚拟关联 From 953817800a05ad071da3a16b960de123c096b773 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 21 Aug 2015 11:46:04 +0800 Subject: [PATCH 45/51] =?UTF-8?q?=E9=97=AE=E5=8D=B7=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E5=90=8E=E6=89=8D=E8=83=BD=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/poll.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/models/poll.rb b/app/models/poll.rb index 62f91380b..bb6e17b9a 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -13,7 +13,8 @@ class Poll < ActiveRecord::Base 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 + after_create :act_as_activity, :act_as_course_activity + after_save :act_as_course_message acts_as_event :title => Proc.new {|o| "#{l(:label_course_poll)}: #{o.polls_name}" }, :description => :polls_description, @@ -46,10 +47,14 @@ class Poll < ActiveRecord::Base # 发布问卷,出了发布者外,其他人都能收到消息通知 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) + if self.polls_status == 2 #问卷是发布状态 + 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 + elsif self.polls_status == 1 #问卷是新建状态 + self.course_messages.destroy_all end end end From 3f3c55cb52672623a28a83ae7830da239a6c46b8 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 21 Aug 2015 12:59:50 +0800 Subject: [PATCH 46/51] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=8D=E5=AD=97?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA=E7=9A=84=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_messages.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index c9b17d09f..07c8b420a 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -109,7 +109,7 @@
  • <%= ucm.course_message.user %>
  • 评阅了作品
  • - <%= link_to ucm.course_message.comment.html_safe, student_work_index_path(:homework => ucm.course_message.student_work.homework_common_id),:class=>"newsGrey",:title => "#{ucm.course_message.comment.html_safe}" %>
  • + <%= link_to ucm.course_message.comment, student_work_index_path(:homework => ucm.course_message.student_work.homework_common_id),:class=>"newsGrey",:title => "#{ucm.course_message.comment}" %>
  • <%= time_tag(ucm.course_message.created_at).html_safe %>
  • <% end %> @@ -119,7 +119,7 @@
  • <%= ucm.course_message.user %>
  • 回复了作品
  • - <%= link_to ucm.course_message.notes.html_safe, student_work_index_path(:homework => ucm.course_message.jour.student_work.homework_common_id),:class=>"newsGrey",:title => "#{ucm.course_message.notes.html_safe}" %>
  • + <%= link_to ucm.course_message.notes, student_work_index_path(:homework => ucm.course_message.jour.student_work.homework_common_id),:class=>"newsGrey",:title => "#{ucm.course_message.notes}" %>
  • <%= time_tag(ucm.course_message.created_on).html_safe %>
  • <% end %> From 241d525e2caaaf42597d80d29ba6ebe3cc3b88d4 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 21 Aug 2015 13:08:05 +0800 Subject: [PATCH 47/51] =?UTF-8?q?=E9=97=AE=E5=8D=B7=E5=90=8D=E4=B8=BA?= =?UTF-8?q?=E7=A9=BA=E7=9A=84=E6=98=BE=E7=A4=BA=E2=80=9C=E6=9C=AA=E5=91=BD?= =?UTF-8?q?=E5=90=8D=E9=97=AE=E5=8D=B7=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_messages.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 07c8b420a..3b1652f2d 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -76,7 +76,7 @@
  • "><%= ucm.course_message.user %>
  • ">发布问卷
  • - <%= link_to format_activity_title(" #{ucm.course_message.polls_name}"), poll_index_path(:polls_type => "Course", :polls_group_id => ucm.course_id), + <%= link_to format_activity_title(" #{ucm.course_message.polls_name.nil? ? "未命名问卷" : ucm.course_message.polls_name}"), poll_index_path(:polls_type => "Course", :polls_group_id => ucm.course_id), :class=>"#{ucm.viewed==0?"newsBlack":"newsGrey"}", :title => "#{ucm.course_message.polls_name}" %>
  • <%= time_tag(ucm.course_message.created_at).html_safe %>
  • From 2473849a6bc028c091a9ca1837c2cd8647a03b44 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 21 Aug 2015 13:53:36 +0800 Subject: [PATCH 48/51] =?UTF-8?q?=E4=BD=9C=E5=93=81=E5=8F=AA=E6=89=93?= =?UTF-8?q?=E5=88=86=E4=B8=8D=E7=95=99=E8=A8=80=E7=9A=84=E6=83=85=E5=86=B5?= =?UTF-8?q?=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_messages.html.erb | 2 +- public/stylesheets/public.css | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 3b1652f2d..5597fe351 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -109,7 +109,7 @@
  • <%= ucm.course_message.user %>
  • 评阅了作品
  • - <%= link_to ucm.course_message.comment, student_work_index_path(:homework => ucm.course_message.student_work.homework_common_id),:class=>"newsGrey",:title => "#{ucm.course_message.comment}" %>
  • + <%= link_to "#{ucm.course_message.comment.nil? ? "分数:"+ucm.course_message.score.to_s : ucm.course_message.comment}", student_work_index_path(:homework => ucm.course_message.student_work.homework_common_id),:class=>"newsGrey",:title => "#{ucm.course_message.comment}" %>
  • <%= time_tag(ucm.course_message.created_at).html_safe %>
  • <% end %> diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index 82b3f17aa..12fa037d6 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -467,3 +467,6 @@ img,embed{max-width: 100%;} /*.copyright{ width:390px; margin:0 auto;height:20px;line-height:20px;}*/ /*a.f_grey {color:#666666;}*/ /*a.f_grey:hover {color:#000000;}*/ + +/*.navHomepageNews {width:30px; display:block; float:right; margin-top:5px; position:relative;}*/ +/*.newsActive {width:10px; height:10px; border-radius:50%; border:2px solid #ffffff; background-color:#ff0000; position:absolute; left:17px; top:5px;z-index:99;}*/ From a53e66d4b00e3e4cf853390f275edfb094cd9404 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 21 Aug 2015 14:04:10 +0800 Subject: [PATCH 49/51] =?UTF-8?q?=E6=B6=88=E6=81=AF=E4=B8=AD=E5=90=8C?= =?UTF-8?q?=E4=BA=8B=E6=98=BE=E7=A4=BA=20=E8=AF=84=E8=AE=BA=E5=92=8C=20?= =?UTF-8?q?=E6=89=93=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_messages.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 5597fe351..17ee0957a 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -109,7 +109,7 @@
  • <%= ucm.course_message.user %>
  • 评阅了作品
  • - <%= link_to "#{ucm.course_message.comment.nil? ? "分数:"+ucm.course_message.score.to_s : ucm.course_message.comment}", student_work_index_path(:homework => ucm.course_message.student_work.homework_common_id),:class=>"newsGrey",:title => "#{ucm.course_message.comment}" %>
  • + <%= link_to "#{ucm.course_message.comment.nil? ? "分数:"+ucm.course_message.score.to_s : "分数:"+ucm.course_message.score.to_s + "----" + "评语:" + ucm.course_message.comment}", student_work_index_path(:homework => ucm.course_message.student_work.homework_common_id),:class=>"newsGrey",:title => "#{ucm.course_message.comment}" %>
  • <%= time_tag(ucm.course_message.created_at).html_safe %>
  • <% end %> From 5594295c9e61a45356e3261e035b50cdd47c99f1 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 21 Aug 2015 15:27:01 +0800 Subject: [PATCH 50/51] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=AD=96=E7=95=A5=20=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/users_helper.rb | 8 ++++++++ app/models/issue.rb | 11 ++++++++++- app/models/journal.rb | 8 +++++--- app/views/users/user_messages.html.erb | 8 ++++---- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 49865d335..48019e597 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -402,6 +402,14 @@ module UsersHelper return str.html_safe end + def get_issue_des_update(journal) + arr = details_to_strings(journal.details,true) + arr << journal.notes + str = '' + arr.each { |item| str = str+item } + return str + end + def get_activity_act_showname(activity) case activity.act_type when "HomeworkCommon" diff --git a/app/models/issue.rb b/app/models/issue.rb index 66627c00a..1724e3484 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -83,7 +83,7 @@ class Issue < ActiveRecord::Base # fq after_create :act_as_activity,:be_user_score_new_issue,:act_as_forge_activity, :act_as_forge_message - after_update :be_user_score + after_update :be_user_score, :act_as_forge_message_update after_destroy :down_user_score # after_create :be_user_score # end @@ -150,6 +150,15 @@ class Issue < ActiveRecord::Base :viewed => false) end end + + # 更新缺陷 + def act_as_forge_message_update + 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 diff --git a/app/models/journal.rb b/app/models/journal.rb index c705b1a09..a5bea92af 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -171,9 +171,11 @@ class Journal < ActiveRecord::Base # 缺陷状态更改,消息提醒 def act_as_forge_message - self.forge_messages << ForgeMessage.new(:user_id => self.issue.author_id, - :project_id => self.issue.project_id, - :viewed => false) + if self.user_id != self.issue.author_id + self.forge_messages << ForgeMessage.new(:user_id => self.issue.author_id, + :project_id => self.issue.project_id, + :viewed => false) + end end # 更新用户分数 -by zjc diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 17ee0957a..c1b57aabb 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -153,11 +153,11 @@ "><%= ufm.forge_message.user %>
  • "> - <%= ufm.forge_message.notes.empty? ? "更新了问题状态" : "在问题中留言了" %>
  • + 更新了问题
  • - <%= link_to ("#{ufm.forge_message.notes.empty? ? ufm.forge_message.issue.subject.html_safe : ufm.forge_message.notes.html_safe }"), + <%= link_to get_issue_des_update(ufm.forge_message), issue_path(:id => ufm.forge_message.journalized_id), :class => "#{ufm.viewed == 0 ? "newsBlack" : "newsGrey"}", - :title => "#{ufm.forge_message.notes.empty? ? ufm.forge_message.issue.subject.html_safe : ufm.forge_message.notes.html_safe }" %> + :title => "#{get_issue_des_update(ufm.forge_message)}" %>
  • <%= time_tag(ufm.forge_message.created_on).html_safe %>
  • @@ -216,7 +216,7 @@
  • <%= urm.memo.author %>
  • -
  • 回复了贴吧帖子
  • +
  • 新建贴吧帖子
  • <%= link_to urm.memo.content.html_safe, forum_memo_path(urm.memo.forum_id, urm.memo.parent_id ? urm.memo.parent_id: urm.memo.id),:class => "newsGrey" , :title => "#{urm.memo.content.html_safe}" %>
  • From 604fe40f84175810fd054227c42b05c22387171d Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 21 Aug 2015 15:55:17 +0800 Subject: [PATCH 51/51] poll after create --- app/models/poll.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/models/poll.rb b/app/models/poll.rb index bb6e17b9a..67bb9f5a8 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -13,8 +13,7 @@ class Poll < ActiveRecord::Base 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 - after_save :act_as_course_message + after_save :act_as_course_message, :act_as_activity, :act_as_course_activity acts_as_event :title => Proc.new {|o| "#{l(:label_course_poll)}: #{o.polls_name}" }, :description => :polls_description,