From 112f350995801a5bd471fedfce5cd85db2dddfd7 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 30 Sep 2017 21:34:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B8=96=E5=AD=90=E5=9B=9E=E5=A4=8D=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/memos_controller.rb | 7 +++---- app/views/forums/index.html.erb | 2 +- app/views/messages/_message_reply.html.erb | 2 +- config/routes.rb | 2 ++ db/migrate/20170930122738_modify_sticky_for_memos.rb | 11 +++++++++++ 5 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 db/migrate/20170930122738_modify_sticky_for_memos.rb diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb index 7e9662563..b96c1774f 100644 --- a/app/controllers/memos_controller.rb +++ b/app/controllers/memos_controller.rb @@ -165,10 +165,9 @@ class MemosController < ApplicationController @flag = false respond_to do |format| - if( #@memo.update_column(:subject, params[:memo][:subject]) && - @memo.update_column(:content, params[:memo][:content]) && - @memo.update_column(:sticky, params[:memo][:sticky]) && - @memo.update_column(:lock, params[:memo][:lock]) && + if( @memo.update_column(:content, params[:memo][:content]) && + @memo.update_column(:sticky, params[:memo][:sticky].to_i) && + @memo.update_column(:lock, params[:memo][:lock].to_i) && @memo.update_column(:subject,params[:memo][:subject]) && @memo.update_column(:updated_at,Time.now)) @memo.save_attachments(params[:attachments] || (params[:memo] && params[:memo][:uploads])) diff --git a/app/views/forums/index.html.erb b/app/views/forums/index.html.erb index c6516c87d..a3cbaa03e 100644 --- a/app/views/forums/index.html.erb +++ b/app/views/forums/index.html.erb @@ -41,7 +41,7 @@ <% end %>

-

<%= memo.content.html_safe %>

+
<%= memo.content.html_safe %>
<%= User.find(memo.author_id).try(:show_name) %> <%= time_from_now memo.updated_at %> diff --git a/app/views/messages/_message_reply.html.erb b/app/views/messages/_message_reply.html.erb index 9410832e6..02d9e36e9 100644 --- a/app/views/messages/_message_reply.html.erb +++ b/app/views/messages/_message_reply.html.erb @@ -1,7 +1,7 @@
<% if !comment.parent.nil? && !comment.parent.parent.nil? %>
- <%= render :partial => 'student_work/homework_reply', :locals => {:comment => comment.parent, :parent_id => parent_id, :type => type, :user_activity_id => user_activity_id} %> + <%= render :partial => 'messages/message_reply', :locals => {:comment => comment.parent, :parent_id => parent_id, :type => type, :user_activity_id => user_activity_id} %>
<% end %> <%= render :partial => 'student_work/homework_reply_detail', :locals => {:comment => comment, :parent_id => parent_id, :type => type, :user_activity_id => user_activity_id} %> diff --git a/config/routes.rb b/config/routes.rb index 1d5b87363..41f47ea9a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -750,6 +750,8 @@ RedmineApp::Application.routes.draw do end member do get "change_sticky" + post "reply" + match "message_replies", :via => [:get, :post] end end end diff --git a/db/migrate/20170930122738_modify_sticky_for_memos.rb b/db/migrate/20170930122738_modify_sticky_for_memos.rb new file mode 100644 index 000000000..25c985f32 --- /dev/null +++ b/db/migrate/20170930122738_modify_sticky_for_memos.rb @@ -0,0 +1,11 @@ +class ModifyStickyForMemos < ActiveRecord::Migration + def up + memos = Memo.where(:sticky => nil) + if memos.present? + memos.update_all(:sticky => 0) + end + end + + def down + end +end