From b9fc410802cde4d1a843a1b7e756b06eabf21f6d Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 17 Sep 2015 14:41:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=B3=BB=E7=BB=9F=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E5=8D=95=E7=8B=AC=E6=96=B0=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/system_messages_controller.rb | 7 +- app/controllers/users_controller.rb | 11 +- app/views/admin/messages.html.erb | 4 +- app/views/users/system_messages.html.erb | 65 ++++ app/views/users/user_messages.html.erb | 320 +++++++++--------- config/routes.rb | 1 + spec/factories/system_messages.rb | 2 +- 7 files changed, 243 insertions(+), 167 deletions(-) create mode 100644 app/views/users/system_messages.html.erb diff --git a/app/controllers/system_messages_controller.rb b/app/controllers/system_messages_controller.rb index 5ba04241c..2697f17b5 100644 --- a/app/controllers/system_messages_controller.rb +++ b/app/controllers/system_messages_controller.rb @@ -14,7 +14,8 @@ class SystemMessagesController < ApplicationController # end def index - @system_messages = SystemMessage.all + render_403 + # @system_messages = SystemMessage.all end # def show @@ -38,14 +39,14 @@ class SystemMessagesController < ApplicationController return end @system_messages = SystemMessage.new - @system_messages.description = params[:system_message][:description] + @system_messages.description = params[:system_messages][:description] @system_messages.user_id = User.current.id respond_to do |format| if @system_messages.save format.html {redirect_to user_message_path(User.current, :type => "system_messages")} flash[:notice] = l(:notice_successful_message) else - if params[:system_message][:description].empty? + if params[:system_messages][:description].empty? flash[:error] = l(:label_content_blank_fail) else flash[:error] = l(:label_admin_message_fail) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 748967990..c88ceb299 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -46,7 +46,7 @@ class UsersController < ApplicationController :activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index, :activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource, :user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction, - :user_import_homeworks,:user_search_homeworks,:user_import_resource] + :user_import_homeworks,:user_search_homeworks,:user_import_resource, :system_messages] before_filter :auth_user_extension, only: :show #before_filter :rest_user_score, only: :show #before_filter :select_entry, only: :user_projects @@ -200,6 +200,15 @@ class UsersController < ApplicationController end end + # 系统消息 + def system_messages + @sytem_messages = SystemMessage.order("created_at desc").all + @sytem_messages = paginateHelper @sytem_messages,25 + respond_to do |format| + format.html{render :layout=>'new_base_user'} + end + end + def user_projects_index if User.current.admin? memberships = @user.memberships.all(conditions: "projects.project_type = #{Project::ProjectType_project}").first diff --git a/app/views/admin/messages.html.erb b/app/views/admin/messages.html.erb index 2ccb34f68..26a54d647 100644 --- a/app/views/admin/messages.html.erb +++ b/app/views/admin/messages.html.erb @@ -3,7 +3,7 @@ <%=l(:label_system_message)%>
- <%= form_for(@admin_messages, :html => {:id =>'system_message-form'}) do |f| %> + <%= form_for(@admin_messages, :html => {:id =>'system_messages-form'}) do |f| %>
<%= f.kindeditor :description,:width=>'87%',:editor_id=>'system_message_editor' %>

@@ -40,7 +40,7 @@ function submit_message() { if (system_message_length()) { - $("#system_message-form").submit(); + $("#system_messages-form").submit(); } } diff --git a/app/views/users/system_messages.html.erb b/app/views/users/system_messages.html.erb new file mode 100644 index 000000000..495e05fc9 --- /dev/null +++ b/app/views/users/system_messages.html.erb @@ -0,0 +1,65 @@ +
+
系统消息
+
    +
  • +
      +
    • <%= link_to "全部",user_message_path(User.current), :class => "resourcesGrey" %>
    • +
    • <%= link_to "未读消息", user_message_path(User.current, :type => 'unviewed'), :class => "resourcesGrey" %>
    • +
    • <%= link_to "用户申请", user_message_path(User.current, :type => 'apply'), :class => "resourcesGrey" %>
    • + <%# 课程相关消息 %> +
    • <%= link_to "作业消息", user_message_path(User.current, :type => 'homework'), :class => "resourcesGrey" %>
    • +
    • <%= link_to "课程讨论",user_message_path(User.current, :type => 'course_message'), :class => "resourcesGrey" %>
    • +
    • <%= link_to "课程通知",user_message_path(User.current, :type => 'course_news'), :class => "resourcesGrey" %>
    • + + + + + <%# 项目相关消息 %> +
    • <%= link_to "项目任务", user_message_path(User.current, :type => 'issue'), :class => "resourcesGrey" %>
    • + + + + + <%# 项目相关消息 %> +
    • <%= link_to "贴吧帖子", user_message_path(User.current, :type => 'forum'), :class => "resourcesGrey" %>
    • + <%# 系统贴吧 %> +
    • <%= link_to "用户留言",user_message_path(User.current, :type => 'user_feedback'), :class => "resourcesGrey" %>
    • + <%# 系统消息 %> +
    • <%= link_to "系统消息", system_messages_path(User.current), :class => "resourcesGrey" %>
    • +
    +
  • +
+
+ +<% @sytem_messages.each do |sytem_message| %> +
+
+
+ <%= link_to image_tag(url_to_avatar(sytem_message.user), :width => "50", :height => "50"), user_path(sytem_message.user_id), :alt => "用户头像" %> +
+
+
+ Trustie平台 发布了 + 系统消息 +
+
+ 系统消息系统消息系统消息系统消息 +
+
+
+ <%#= student_work_activity_submit_status(homework: activity) %> +
+
截止时间:<%= sytem_message.created_at %>
+
+
+ <%= sytem_message.content.nil? ? sytem_message.description.html_safe : sytem_message.content.html_safe %> +
+ +
+
+
+
+<% end %> +
    + <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> +
\ No newline at end of file diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 376f7ab8e..300a34993 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -1,35 +1,35 @@
-
<%= title_for_message(params[:type]) %>
-
    -
  • -
      -
    • <%= link_to "全部",user_message_path(User.current), :class => "resourcesGrey" %>
    • -
    • <%= link_to "未读消息", user_message_path(User.current, :type => 'unviewed'), :class => "resourcesGrey" %>
    • -
    • <%= link_to "用户申请", user_message_path(User.current, :type => 'apply'), :class => "resourcesGrey" %>
    • - <%# 课程相关消息 %> -
    • <%= link_to "作业消息", user_message_path(User.current, :type => 'homework'), :class => "resourcesGrey" %>
    • -
    • <%= link_to "课程讨论",user_message_path(User.current, :type => 'course_message'), :class => "resourcesGrey" %>
    • -
    • <%= link_to "课程通知",user_message_path(User.current, :type => 'course_news'), :class => "resourcesGrey" %>
    • - - - - - <%# 项目相关消息 %> -
    • <%= link_to "项目任务", user_message_path(User.current, :type => 'issue'), :class => "resourcesGrey" %>
    • - - - - - <%# 项目相关消息 %> -
    • <%= link_to "贴吧帖子", user_message_path(User.current, :type => 'forum'), :class => "resourcesGrey" %>
    • - <%# 系统贴吧 %> -
    • <%= link_to "用户留言",user_message_path(User.current, :type => 'user_feedback'), :class => "resourcesGrey" %>
    • - <%# 系统消息 %> -
    • <%= link_to "系统消息", user_message_path(User.current, :type => 'system_messages'), :class => "resourcesGrey" %>
    • -
    -
  • -
-
+
<%= title_for_message(params[:type]) %>
+
    +
  • +
      +
    • <%= link_to "全部",user_message_path(User.current), :class => "resourcesGrey" %>
    • +
    • <%= link_to "未读消息", user_message_path(User.current, :type => 'unviewed'), :class => "resourcesGrey" %>
    • +
    • <%= link_to "用户申请", user_message_path(User.current, :type => 'apply'), :class => "resourcesGrey" %>
    • + <%# 课程相关消息 %> +
    • <%= link_to "作业消息", user_message_path(User.current, :type => 'homework'), :class => "resourcesGrey" %>
    • +
    • <%= link_to "课程讨论",user_message_path(User.current, :type => 'course_message'), :class => "resourcesGrey" %>
    • +
    • <%= link_to "课程通知",user_message_path(User.current, :type => 'course_news'), :class => "resourcesGrey" %>
    • + + + + + <%# 项目相关消息 %> +
    • <%= link_to "项目任务", user_message_path(User.current, :type => 'issue'), :class => "resourcesGrey" %>
    • + + + + + <%# 项目相关消息 %> +
    • <%= link_to "贴吧帖子", user_message_path(User.current, :type => 'forum'), :class => "resourcesGrey" %>
    • + <%# 系统贴吧 %> +
    • <%= link_to "用户留言",user_message_path(User.current, :type => 'user_feedback'), :class => "resourcesGrey" %>
    • + <%# 系统消息 %> +
    • <%= link_to "系统消息", user_message_path(User.current, :type => 'system_messages'), :class => "resourcesGrey" %>
    • +
    +
  • +
+
<% if @message_alls.count >0 || @user_system_messages.count >0 %> @@ -42,30 +42,30 @@
<% end %> <%# 系统消息 %> - <% if params[:type] != 'system_messages' %> - <% @user_system_messages.each do |usm| %> -
    -
  • - -
  • -
  • - Trustie平台发布新消息: -
  • -
  • - 【系统消息】
  • - <%= link_to usm.content.nil? ? usm.description.html_safe : usm.content.html_safe, user_message_path(User.current, :type => "system_messages"), - :id => "content_link_#{usm.id}", - :onmouseover =>"message_titile_show($(this),event);", - :onmouseout => "message_titile_hide($(this));" - %> -
  • - -
  • <%= time_tag(usm.created_at).html_safe %>
  • -
- <% end %> - <% end %> + <% if params[:type] != 'system_messages' %> + <% @user_system_messages.each do |usm| %> +
    +
  • + +
  • +
  • + Trustie平台发布新消息: +
  • +
  • + 【系统消息】
  • + <%= link_to usm.content.nil? ? usm.description.html_safe : usm.content.html_safe, user_message_path(User.current, :type => "system_messages"), + :id => "content_link_#{usm.id}", + :onmouseover =>"message_titile_show($(this),event);", + :onmouseout => "message_titile_hide($(this));" + %> +
  • + +
  • <%= time_tag(usm.created_at).html_safe %>
  • +
+ <% end %> + <% end %> <%# 课程消息 %> <% unless @message_alls.nil? %> <% @message_alls.each do |ma| %> @@ -109,16 +109,16 @@
  • <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
  • <%=link_to ma.course_message.user, user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>">发布的作业:
  • - <% if ma.viewed == 0 %> + <% if ma.viewed == 0 %>
  • <%= link_to ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :title => "#{ma.course_message.name}" %>
  •    截止时间快到了!
  • - <% else %> + <% else %>
  • <%= link_to ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :title => "#{ma.course_message.name}" %>
  • - <% end %> + <% end %>
  • <%= time_tag(ma.created_at).html_safe %>
<% end %> @@ -167,42 +167,42 @@
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> - <% if ma.course_message_type == "JournalsForMessage" %> - <% if ma.course_message.jour_type == 'Course' %> - + <% if ma.course_message_type == "JournalsForMessage" %> + <% if ma.course_message.jour_type == 'Course' %> + - <% else %> - - <% end %> - <% end %> + <% else %> + + <% end %> + <% end %> <% end %> <% if ma.class == ForgeMessage %> @@ -266,14 +266,14 @@ <% if ma.forge_message.parent_id.nil? %>
  • <%=link_to ma.forge_message.subject, project_boards_path(ma.forge_message.project, - :parent_id => ma.forge_message.parent_id ? ma.forge_message.parent_id : ma.forge_message.id, - :topic_id => ma.forge_message.id),:class=>"#{ma.viewed==0?"newsBlack":"newsGrey"}", + :parent_id => ma.forge_message.parent_id ? ma.forge_message.parent_id : ma.forge_message.id, + :topic_id => ma.forge_message.id),:class=>"#{ma.viewed==0?"newsBlack":"newsGrey"}", :title => "#{ma.forge_message.subject.html_safe}" %>
  • <% else %>
  • <%=link_to ma.forge_message.content.html_safe, project_boards_path(ma.forge_message.project, - :parent_id => ma.forge_message.parent_id ? ma.forge_message.parent_id : ma.forge_message.id, - :topic_id => ma.forge_message.id),:class=>"#{ma.viewed==0?"newsBlack":"newsGrey"}", + :parent_id => ma.forge_message.parent_id ? ma.forge_message.parent_id : ma.forge_message.id, + :topic_id => ma.forge_message.id),:class=>"#{ma.viewed==0?"newsBlack":"newsGrey"}", :onmouseover =>"message_titile_show($(this),event)", :onmouseout => "message_titile_hide($(this))" %>
  • diff --git a/config/routes.rb b/config/routes.rb index 103885292..e35c7ff3b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -389,6 +389,7 @@ RedmineApp::Application.routes.draw do match 'users/:id/user_projects', :to => 'users#user_projects', :via => :get #消息 match 'users/:id/user_messages', :to => 'users#user_messages', :via => :get, :as => "user_message" + match 'users/:id/system_messages', :to => 'users#system_messages', :via => :get, :as => "system_messages" #match 'users/:id/user_messages/:homework', :to => 'users#user_messages_homework', :via => :get, :as => "user_message_homewrok" diff --git a/spec/factories/system_messages.rb b/spec/factories/system_messages.rb index 7bcc27422..a95505cfd 100644 --- a/spec/factories/system_messages.rb +++ b/spec/factories/system_messages.rb @@ -1,5 +1,5 @@ FactoryGirl.define do - factory :system_message do + factory :system_messages do id 1 user_id 1 content "MyString"