From ed8c4ac906f864b3c5fd1118954be0dc4f229da4 Mon Sep 17 00:00:00 2001 From: huang Date: Sat, 15 Aug 2015 02:11:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8D=E5=90=8C=E7=B1=BB=E5=9E=8B=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E5=8F=91=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 26 +++++++++++--- app/models/user.rb | 20 +++++++++++ app/views/users/user_messages.html.erb | 40 ++++++++++++++-------- public/stylesheets/public_new.css | 47 +++++++++++++++++++++++++- 4 files changed, 113 insertions(+), 20 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index bee68c419..c6dfb9b54 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -98,12 +98,28 @@ class UsersController < ApplicationController # 用户消息 def user_messages - @user_course_messages = @user.course_messages - @user_project_messges = @user.forge_messages - respond_to do |format| - format.html{render :layout=>'base_users_new'} - format.api + if @user.course_messages + if params[:type].nil? + @user_course_messages = @user.course_messages + @user_project_messges = @user.forge_messages + else + case params[:type] + when 'homework' + @user_course_messages = @user.course_messages + #@user_course_messages = ForgeMessage.find_by_sql("select * from course_messages where user_id='#{@user.id}' and course_message_type = 'HomeworkCommon' order by created_at desc;") + when 'message' + @user_course_messages = @user.course_message_message + when 'news' + @user_course_messages = @user.course_message_new + when 'poll' + @user_course_messages = @user.course_message_poll end + end + respond_to do |format| + format.html{render :layout=>'base_users_new'} + format.api + end + end end def user_projects_index diff --git a/app/models/user.rb b/app/models/user.rb index bb9a6d0a1..4bc249673 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -134,6 +134,10 @@ class User < Principal # 虚拟转换 has_many :new_jours, :as => :jour, :class_name => 'JournalsForMessage', :conditions => "status=1" + has_many :course_messages_homeworks, :class_name => 'ForgeMessage', :conditions => 'forge_message_type="HomeworkCommon"' + has_many :course_messages_polls, :class_name => 'ForgeMessage', :conditions => 'forge_message_type="Poll"' + has_many :course_messages_messages, :class_name => 'ForgeMessage', :conditions => 'forge_message_type="Message"' + has_many :course_messages_news, :class_name => 'ForgeMessage', :conditions => 'forge_message_type="News"' has_many :issue_assigns, :class_name => 'ForgeMessage', :conditions => 'viewed=0 and forge_message_type="Issue"' has_many :status_updates, :class_name => 'ForgeMessage', :conditions => 'viewed=0 and forge_message_type="Journal"' # 邮件邀请状态 @@ -248,6 +252,22 @@ class User < Principal # count = self.journals_for_messages(:conditions => ["status=? and is_readed = ? " ,1, 0]).count end + def course_message_homework user + user.course_messages_homeworks + end + + def course_message_poll + self.course_messages_polls + end + + def course_message_new + self.course_messages_news + end + + def course_message_message + self.course_messages_messages + end + # 查询指派给我的缺陷记录 def count_new_issue_assign_to self.issue_assigns diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 204ed2c08..687a694bb 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -6,20 +6,20 @@
+ <% if !@user_course_messages.nil? %> <% @user_course_messages.each do |ucm| %> <% if ucm.course_message_type == "News" %> <% end %> @@ -37,7 +37,7 @@
  • <%= ucm.course_message.user %>
  • 发布作业
  • - <%= link_to format_activity_title("#{ucm.course_message.name}"), {:controller => 'news', :action => 'show', :id => ucm.course_message.id} %>
  • + <%= link_to ("#{ucm.course_message.name}"), student_work_index_path(:homework => ucm.course_message.id) %>
  • <%= time_tag(ucm.course_message.created_at).html_safe %>
  • <% end %> @@ -46,7 +46,8 @@
  • <%= ucm.course_message.user %>
  • 发布问卷
  • -
  • <%= ucm.course_message.polls_name %>
  • +
  • + <%= link_to format_activity_title(" #{ucm.course_message.polls_name}"), poll_index_path(:polls_type => "Course", :polls_group_id => ucm.course_id) %>
  • <%= time_tag(ucm.course_message.created_at).html_safe %>
  • <% end %> @@ -54,13 +55,24 @@ <% end %>
    <% end %> + <% else %> +
    你没有新消息!
    + <% end %>
    diff --git a/public/stylesheets/public_new.css b/public/stylesheets/public_new.css index 5a4a4c195..a14aa6759 100644 --- a/public/stylesheets/public_new.css +++ b/public/stylesheets/public_new.css @@ -596,4 +596,49 @@ a.homepageWhite:hover {color:#a1ebff} a.newsGrey {color:#4b4b4b;} a.newsGrey:hover {color:#000000;} a.newsBlue {color:#15bccf;} -a.newsBlue:hover {color:#0781b4;} \ No newline at end of file +a.newsBlue:hover {color:#0781b4;} + +/***** Flash & error messages ****/ +#errorExplanation, div.flash, .nodata, .warning, .conflict { + padding: 4px 4px 4px 30px; + margin-bottom: 12px; + font-size: 1.1em; + border: 2px solid; +} + +div.flash {margin-top: 8px;} + +div.flash.error, #errorExplanation { + background: url(../images/exclamation.png) 8px 50% no-repeat; + background-color: #ffe3e3; + border-color: #dd0000; + color: #880000; +} + +div.flash.notice { + background: url(../images/true.png) 8px 5px no-repeat; + background-color: #dfffdf; + border-color: #9fcf9f; + color: #005f00; +} + +div.flash.warning, .conflict { + background: url(../images/warning.png) 8px 5px no-repeat; + background-color: #FFEBC1; + border-color: #FDBF3B; + color: #A6750C; + text-align: left; +} + +.nodata, .warning { + text-align: center; + background-color: #FFEBC1; + border-color: #FDBF3B; + color: #A6750C; +} + +#errorExplanation ul { font-size: 0.9em;} +#errorExplanation h2, #errorExplanation p { display: none; } + +.conflict-details {font-size:80%;} +/***** end Flash & error messages ****/ \ No newline at end of file