From 4fc47ce3a3e5ef4b13d0b2c7b7e6b148f0fa07f4 Mon Sep 17 00:00:00 2001 From: nieguanghui <hust.ud.hui@gmail.com> Date: Thu, 26 Dec 2013 15:32:34 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9B=9E=E5=A4=8D?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E8=A1=A8=E7=8E=B0=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/words/_journal_reply_items.html.erb | 8 +++++--- app/views/words/_message.html.erb | 4 ++-- .../redpenny-master/stylesheets/application.css | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/app/views/words/_journal_reply_items.html.erb b/app/views/words/_journal_reply_items.html.erb index 92ed24c65..da10e5c9b 100644 --- a/app/views/words/_journal_reply_items.html.erb +++ b/app/views/words/_journal_reply_items.html.erb @@ -1,4 +1,5 @@ -<li> + <% ids_r = 'reply_respond_form_'+ reply.id.to_s %> +<li onmouseover="$('#<%= ids_r %>').show()" onmouseout="$('#<%= ids_r %>').hide()"> <span class="portrait"> <%= image_tag url_to_avatar(reply.user), :class => "avatar-3" %> </span> @@ -7,9 +8,10 @@ <span><%= link_to reply.user.name, user_path(reply.user) %>: </span> <span class="message-notes"> <%= reply.notes %></span> <% ids = 'project_respond_form_'+ journal.id.to_s%> - <p style="margin-top: 4px; font-size: 9pt;"> + + <p> <span class="time"><%= format_time reply.created_on %></span> - <span style="float: right;"> + <span style="display: none; margin-left: 4px;" id=<%= ids_r %>> <%#= toggle_link l(:label_projects_feedback_respond), id, {:focus => 'project_respond'} %> <%= link_to l(:label_projects_feedback_respond),'', {:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{id}'), $('##{id} textarea'), '#{l(:label_reply_plural)} #{reply.user.show_name}: '); return false;"} diff --git a/app/views/words/_message.html.erb b/app/views/words/_message.html.erb index b756141bd..5ba80f698 100644 --- a/app/views/words/_message.html.erb +++ b/app/views/words/_message.html.erb @@ -12,9 +12,9 @@ <% else %> <span class="font_lighter"><%= l(:label_leave_others_message) %></span> <% end %> - <span> + <p> <%= textilizable journal.notes%> - </span> + </p> <span class="font_lighter"> <%= l :label_comment_time %>: <%= format_time journal.created_on %></span> <% ids = 'project_respond_form_'+ journal.id.to_s%> <%#= toggle_link l(:label_projects_feedback_respond), ids, {:focus => 'project_respond'} %> diff --git a/public/themes/redpenny-master/stylesheets/application.css b/public/themes/redpenny-master/stylesheets/application.css index 437720c5c..1ed6c9207 100644 --- a/public/themes/redpenny-master/stylesheets/application.css +++ b/public/themes/redpenny-master/stylesheets/application.css @@ -2118,6 +2118,7 @@ span.body{ ul.messages-for-user-reply li { padding-bottom: 4px; + font-size: 9pt; } .respond-form{ @@ -2125,4 +2126,18 @@ ul.messages-for-user-reply li { width: 100%; margin: auto; clear:both; +} + +.outer-message-for-use p { + margin: 0; + padding: 0; + margin-top: 5px; +} + +.body p { + margin: 0; + padding: 0; + margin-top: 4px; + margin-left: 4px; + font-size: 9pt; } \ No newline at end of file From 809e7023eecaf7837af0f29294be5134310e2b57 Mon Sep 17 00:00:00 2001 From: nieguanghui <hust.ud.hui@gmail.com> Date: Thu, 26 Dec 2013 16:06:59 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E7=BB=99=E7=95=99=E8=A8=80=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=88=A0=E9=99=A4=E5=8A=9F=E8=83=BD=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _message.html.erb, _journal_reply_items.html.erb 调用words的destroy方法。 --- app/views/words/_journal_reply_items.html.erb | 12 +++++++---- app/views/words/_message.html.erb | 21 ++++++++++++------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/app/views/words/_journal_reply_items.html.erb b/app/views/words/_journal_reply_items.html.erb index da10e5c9b..4a3a72aba 100644 --- a/app/views/words/_journal_reply_items.html.erb +++ b/app/views/words/_journal_reply_items.html.erb @@ -12,10 +12,14 @@ <p> <span class="time"><%= format_time reply.created_on %></span> <span style="display: none; margin-left: 4px;" id=<%= ids_r %>> - <%#= toggle_link l(:label_projects_feedback_respond), id, {:focus => 'project_respond'} %> - <%= link_to l(:label_projects_feedback_respond),'', - {:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{id}'), $('##{id} textarea'), '#{l(:label_reply_plural)} #{reply.user.show_name}: '); return false;"} - %> + <%= link_to l(:label_projects_feedback_respond),'', + {:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea'), '#{l(:label_reply_plural)} #{journal.user.show_name}:'); return false;"} + %> + + <% if @user == User.current %> + <%= link_to(l(:label_newfeedback_delete), {:controller => 'words', :action => 'destroy', :object_id => journal, :user_id => reply.user}, + :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "delete", :title => l(:button_delete)) if (User.current.id == reply.user_id) || journal.jour_id == User.current.id %></td> + <% end %> </span> </p> </div> diff --git a/app/views/words/_message.html.erb b/app/views/words/_message.html.erb index 5ba80f698..f0d5a651e 100644 --- a/app/views/words/_message.html.erb +++ b/app/views/words/_message.html.erb @@ -8,20 +8,25 @@ <span class="body"> <span class="user"><%= link_to journal.user, user_path(journal.user)%></span> <% if @user == User.current %> - <span class="font_lighter"><%= l(:label_leave_me_message) %></span> + <span class="font_lighter"><%= l(:label_leave_me_message) %> :</span> <% else %> - <span class="font_lighter"><%= l(:label_leave_others_message) %></span> + <span class="font_lighter"><%= l(:label_leave_others_message) %> :</span> <% end %> <p> <%= textilizable journal.notes%> </p> <span class="font_lighter"> <%= l :label_comment_time %>: <%= format_time journal.created_on %></span> - <% ids = 'project_respond_form_'+ journal.id.to_s%> - <%#= toggle_link l(:label_projects_feedback_respond), ids, {:focus => 'project_respond'} %> - - <%= link_to l(:label_projects_feedback_respond),'', - {:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea'), '#{l(:label_reply_plural)} #{journal.user.show_name}:'); return false;"} - %> + <% ids = 'project_respond_form_'+ journal.id.to_s%> + <span> + <%= link_to l(:label_projects_feedback_respond),'', + {:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea'), '#{l(:label_reply_plural)} #{journal.user.show_name}:'); return false;"} + %> + + <% if @user == User.current %> + <%= link_to(l(:label_newfeedback_delete), {:controller => 'words', :action => 'destroy', :object_id => journal, :user_id => user}, + :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "delete", :title => l(:button_delete)) if remove_allowed || journal.jour_id == User.current.id %></td> + <% end %> + </span> </span> <div style="clear: both;"></div> <div id=<%= ids %> class="respond-form"> From 7197e3d90ce16be72482ab08eef2daad5f73064f Mon Sep 17 00:00:00 2001 From: yanxd <sxty32@hotmaill.com> Date: Thu, 26 Dec 2013 16:34:50 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E8=AE=BA=E5=9D=9B=E7=9B=B4=E6=8E=A5?= =?UTF-8?q?=E5=BB=BA=E7=AB=8B=E6=96=B0=E5=B8=96=E4=BC=A0=E9=80=81=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=8D=E8=83=BD=E6=88=90=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/forums/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erb index 8388b6aef..47662f254 100644 --- a/app/views/forums/show.html.erb +++ b/app/views/forums/show.html.erb @@ -2,7 +2,7 @@ <div id="add-memo" style="display:none;"> <h3><%=l(:label_memo_new)%></h3> <% if User.current.logged? %> - <%= labelled_form_for(@memo, :url => forum_memos_path(@forum)) do |f| %> + <%= labelled_form_for(@memo, :url => forum_memos_path(@forum), :html => {:multipart => true} ) do |f| %> <% if @memo.errors.any? %> <div id="error_explanation"> <h2><%= pluralize(@memo.errors.count, "error") %> prohibited this memo from being saved:</h2> From 8a1316cf8f3a4664400d8cc57b2e7e212a145d5c Mon Sep 17 00:00:00 2001 From: yanxd <sxty32@hotmaill.com> Date: Thu, 26 Dec 2013 19:28:18 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=95=99=E8=A8=80?= =?UTF-8?q?=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/words_controller.rb | 6 +++--- app/models/journals_for_message.rb | 4 ++-- app/views/words/_journal_reply.html.erb | 2 +- app/views/words/_journal_reply_items.html.erb | 18 +++++++++--------- app/views/words/_message.html.erb | 16 ++++++++-------- app/views/words/create_reply.js.erb | 7 ++++--- app/views/words/destroy.js.erb | 13 +++++++++++-- config/locales/en.yml | 1 + config/locales/zh.yml | 1 + public/javascripts/application.js | 2 +- .../stylesheets/application.css | 2 +- 11 files changed, 42 insertions(+), 30 deletions(-) diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index 7c05c5af5..193b2b61d 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -73,10 +73,10 @@ class WordsController < ApplicationController end def destroy - if User.current.admin? || User.current.id == @user.id - JournalsForMessage.delete_message(params[:object_id]) + if User.current.admin? || @user.id == User.current.id || User.current.id == JournalsForMessage.find(params[:object_id]).jour_id + @journal_destroyed = JournalsForMessage.delete_message(params[:object_id]) end - @jours = @user.journals_for_messages.reverse + @jours = @user.journals_for_messages.where('m_parent_id IS NULL').reverse @limit = 10 @feedback_count = @jours.count @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index e00564f18..e83018be6 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -20,7 +20,6 @@ class JournalsForMessage < ActiveRecord::Base belongs_to :at_user, :class_name => "User", :foreign_key => 'reply_id' has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy - has_many :reply_for_journals, :dependent => :destroy validates :notes, presence: true after_create :act_as_activity #huang @@ -30,7 +29,8 @@ class JournalsForMessage < ActiveRecord::Base # default_scope { where('m_parent_id IS NULL') } def self.delete_message(message_id) - self.delete_all "id = #{message_id}" + self.find(message_id).destroy + # self.destroy_all "id = #{message_id}" end def reference_user diff --git a/app/views/words/_journal_reply.html.erb b/app/views/words/_journal_reply.html.erb index a909362d9..1249c9cb4 100644 --- a/app/views/words/_journal_reply.html.erb +++ b/app/views/words/_journal_reply.html.erb @@ -1,6 +1,6 @@ <% id = "journal_reply_ul_" + journal.id.to_s%> -<ul class="messages-for-user-reply" id = <%= id %> > +<ul class="messages-for-user-reply" id = '<%= id %>' > <% fetch_user_leaveWord_reply(journal).each do |reply|%> <%= render :partial => "words/journal_reply_items", :locals => {:reply => reply, :journal => journal, :m_reply_id => reply.id} %> <% end %> diff --git a/app/views/words/_journal_reply_items.html.erb b/app/views/words/_journal_reply_items.html.erb index 4a3a72aba..5a66b5133 100644 --- a/app/views/words/_journal_reply_items.html.erb +++ b/app/views/words/_journal_reply_items.html.erb @@ -1,23 +1,23 @@ - <% ids_r = 'reply_respond_form_'+ reply.id.to_s %> -<li onmouseover="$('#<%= ids_r %>').show()" onmouseout="$('#<%= ids_r %>').hide()"> +<% ids_r = 'reply_respond_form_'+ reply.id.to_s %> +<li id='word_li_<%=reply.id.to_s%>' onmouseover="$('#<%= ids_r %>').show()" onmouseout="$('#<%= ids_r %>').hide()"> <span class="portrait"> <%= image_tag url_to_avatar(reply.user), :class => "avatar-3" %> </span> <div class="body"> - <% id = 'project_respond_form_'+ reply.id.to_s %> + <% id = 'project_respond_form_'+ reply.id.to_s %> <span><%= link_to reply.user.name, user_path(reply.user) %>: </span> <span class="message-notes"> <%= reply.notes %></span> - <% ids = 'project_respond_form_'+ journal.id.to_s%> + <%# ids = 'project_respond_form_'+ journal.id.to_s%> <p> <span class="time"><%= format_time reply.created_on %></span> - <span style="display: none; margin-left: 4px;" id=<%= ids_r %>> + <span style="display: none; margin-left: 4px;" id='<%=ids_r%>' > <%= link_to l(:label_projects_feedback_respond),'', - {:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea'), '#{l(:label_reply_plural)} #{journal.user.show_name}:'); return false;"} + {:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{id}'), $('##{id} textarea'), '#{l(:label_reply_plural)} #{journal.user.show_name}: '); return false;"} %> <% if @user == User.current %> - <%= link_to(l(:label_newfeedback_delete), {:controller => 'words', :action => 'destroy', :object_id => journal, :user_id => reply.user}, + <%= link_to(l(:label_newfeedback_delete), {:controller => 'words', :action => 'destroy', :object_id => reply, :user_id => reply.user}, :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "delete", :title => l(:button_delete)) if (User.current.id == reply.user_id) || journal.jour_id == User.current.id %></td> <% end %> </span> @@ -25,6 +25,6 @@ </div> <div id='<%=id%>' class="respond-form"> <%= render :partial => "words/new_respond", :locals => {:journal => journal, :m_reply_id => m_reply_id} %> - </div> - <div style="clear: both;"></div> + </div> + <div style="clear: both;"></div> </li> \ No newline at end of file diff --git a/app/views/words/_message.html.erb b/app/views/words/_message.html.erb index f0d5a651e..f5df90ec9 100644 --- a/app/views/words/_message.html.erb +++ b/app/views/words/_message.html.erb @@ -3,7 +3,7 @@ <% remove_allowed = (User.current.id == jour.first.user_id) %> <ul class="message-for-user"> <% for journal in jour%> - <li class="outer-message-for-user"> + <li id='word_li_<%=journal.id.to_s%>' class="outer-message-for-user"> <span class="portrait"><%= image_tag(url_to_avatar(journal.user), :class => "avatar") %></span> <span class="body"> <span class="user"><%= link_to journal.user, user_path(journal.user)%></span> @@ -19,7 +19,7 @@ <% ids = 'project_respond_form_'+ journal.id.to_s%> <span> <%= link_to l(:label_projects_feedback_respond),'', - {:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea'), '#{l(:label_reply_plural)} #{journal.user.show_name}:'); return false;"} + {:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea'), '#{l(:label_reply_plural)} #{journal.user.show_name}: '); $('##{ids} textarea') ;return false;"} %> <% if @user == User.current %> @@ -29,13 +29,13 @@ </span> </span> <div style="clear: both;"></div> - <div id=<%= ids %> class="respond-form"> + <div id='<%= ids %>' class="respond-form"> <%= render :partial => 'words/new_respond', :locals => {:journal => journal, :m_reply_id => journal.id} %> - </div> - <div> - <%= render :partial => "words/journal_reply", :locals => {:journal => journal } %> - </div> - </li> + </div> + <div> + <%= render :partial => "words/journal_reply", :locals => {:journal => journal } %> + </div> +</li> <% end %> </ul> <% end %> diff --git a/app/views/words/create_reply.js.erb b/app/views/words/create_reply.js.erb index 20964d9b0..6d625bdc5 100644 --- a/app/views/words/create_reply.js.erb +++ b/app/views/words/create_reply.js.erb @@ -1,9 +1,10 @@ <% if @save_succ %> - $('#journal_reply_ul_<%=@jfm.m_parent_id%>').append( - '<%= j( + var pre_append = $('<%= j( render :partial => "words/journal_reply_items", :locals => {:reply => @jfm, :journal => @jfm.parent, :m_reply_id => @jfm.id} - ) %>'); + ) %>').hide(); + $('#journal_reply_ul_<%=@jfm.m_parent_id%>').append(pre_append); + pre_append.fadeIn(600); $('#project_respond_form_<%=@jfm.m_reply_id.to_s%> textarea').val(''); $('#project_respond_form_<%=@jfm.m_reply_id.to_s%>').hide(); <% else %> diff --git a/app/views/words/destroy.js.erb b/app/views/words/destroy.js.erb index 53dc614b2..6b582f804 100644 --- a/app/views/words/destroy.js.erb +++ b/app/views/words/destroy.js.erb @@ -1,2 +1,11 @@ -$('#message').html('<%= escape_javascript(render(:partial => 'words/message', :locals => {:jour => @jour, :state => false, :user => @user, :feedback_pages => @feedback_pages})) %>'); -$('#new_form_reference_user_id').val(""); \ No newline at end of file +<% if @journal_destroyed.nil? %> + alert('<%=l(:notice_failed_delete)%>'); +<% elsif (@journal_destroyed.jour_type == 'Principal')%> + var destroyedItem = $('#word_li_<%=@journal_destroyed.id%>') + destroyedItem.fadeOut(600,function(){ + destroyedItem.remove(); + }); +<% else %> + $('#message').html('<%= escape_javascript(render(:partial => 'words/message', :locals => {:jour => @jour, :state => false, :user => @user, :feedback_pages => @feedback_pages})) %>'); + $('#new_form_reference_user_id').val(""); +<% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index fd44c577a..de55fe394 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -155,6 +155,7 @@ en: notice_successful_create: Successful creation. notice_successful_update: Successful update. notice_successful_delete: Successful deletion. + notice_failed_delete: Successful failure. notice_successful_connection: Successful connection. notice_file_not_found: The page you were trying to access doesn't exist or has been removed. notice_locking_conflict: Data has been updated by another user. diff --git a/config/locales/zh.yml b/config/locales/zh.yml index d73bb42f2..6d64d30bc 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -164,6 +164,7 @@ zh: notice_successful_create: 创建成功 notice_successful_update: 更新成功 notice_successful_delete: 删除成功 + notice_failed_delete: 删除失败 notice_successful_connection: 连接成功 notice_file_not_found: 您访问的页面不存在或已被删除。 notice_locking_conflict: 数据已被另一位用户更新 diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 65af8714e..3ab51764f 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -592,7 +592,7 @@ function blockEventPropagation(event) { function toggleAndSettingWordsVal(parent_widget, text_widget, value){ text_widget.val(value) - parent_widget.toggle(400) + parent_widget.slideToggle(400) } $(document).ready(setupAjaxIndicator); diff --git a/public/themes/redpenny-master/stylesheets/application.css b/public/themes/redpenny-master/stylesheets/application.css index 1ed6c9207..0dcca361b 100644 --- a/public/themes/redpenny-master/stylesheets/application.css +++ b/public/themes/redpenny-master/stylesheets/application.css @@ -2123,7 +2123,7 @@ ul.messages-for-user-reply li { .respond-form{ display: none; - width: 100%; + width: 87%; margin: auto; clear:both; } From 8a0dc59f3e9c441a0cafc2710acd64a173b1ee0a Mon Sep 17 00:00:00 2001 From: nieguanghui <hust.ud.hui@gmail.com> Date: Thu, 26 Dec 2013 19:57:40 +0800 Subject: [PATCH 5/9] welcome index helper. --- app/helpers/welcome_helper.rb | 10 +++++----- app/views/welcome/index.html.erb | 30 +++++++++++++++--------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index f862ce30f..ff2801a53 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -75,13 +75,13 @@ module WelcomeHelper str = ' '.html_safe case event.event_type when 'news' , 'issue', 'message' , 'bid' , 'wiki-page' , 'document' - str << content_tag("span", "发表了") << content_tag("span", find_all_event_type(event)) << ': '.html_safe << link_to(truncate(event.event_title, length: 30, omission:'...'), event.event_url) + str << content_tag("span", "发表了") << content_tag("span", find_all_event_type(event)) << ': '.html_safe << link_to(truncate(event.event_title, length: 30, omission:'...'), event.event_url, :target => "_blank" ) when 'reply' ,'Reply', 'Memo' - str << content_tag("span", "发表了") << content_tag("span", find_all_event_type(event)) << ': '.html_safe << link_to(truncate(strip_tags(event.event_description), length: 30, omission:'...'), event.event_url) + str << content_tag("span", "发表了") << content_tag("span", find_all_event_type(event)) << ': '.html_safe << link_to(truncate(strip_tags(event.event_description), length: 30, omission:'...'), event.event_url, :target => "_blank" ) when 'attachment' str << content_tag('span', '上传了') << content_tag('span', find_all_event_type(event)) << ': '.html_safe << link_to(truncate(event.event_title, length: 30, omission:'...'), event.event_url) << link_to((' ['.html_safe+l(:label_downloads_list).to_s << ']'), project_files_path(event.container)) else - str << content_tag("span", "更新了") << content_tag("span", find_all_event_type(event)) << ': '.html_safe << link_to(truncate(event.event_title, length: 30, omission:'...'), event.event_url) + str << content_tag("span", "更新了") << content_tag("span", find_all_event_type(event)) << ': '.html_safe << link_to(truncate(event.event_title, length: 30, omission:'...'), event.event_url, :target => "_blank" ) end str rescue Exception => e @@ -92,9 +92,9 @@ module WelcomeHelper str = "回复(" case event.event_type when "issue" - str << link_to(cal_issues_count(event), issue_path(event)) << ")" + str << link_to(cal_issues_count(event), issue_path(event), :target => "_blank" ) << ")" when "Memo" - str << link_to(cal_memos_count(event), forum_memo_path(event.forum_id,event.id)) << ")" + str << link_to(cal_memos_count(event), forum_memo_path(event.forum_id,event.id), :target => "_blank" ) << ")" else str = "" end diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index 32cb43167..2f0279578 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -97,7 +97,7 @@ <div class="forum-topic" style="height: 25px;"> <h3 style="color: rgb(21, 188, 207);margin-left: 8px;"><strong>贴吧动态</strong></h3> - <span style="margin-top: -30px;float: right; display: block;"><%= link_to "更多>>", forums_path %></span> + <span style="margin-top: -30px;float: right; display: block;"><%= link_to "更多>>", forums_path, :target => "_blank" %></span> </div> <div class="welcome-box-list-new"> @@ -105,14 +105,14 @@ <li class="message-brief-intro" style="min-height: 25px;padding-bottom:3px;"> <div style="display: inline-block; width: 100%;"> <span style="color:gray; display: inline-block; margin-bottom:6px; background: url('/images/list-icon.png') no-repeat scroll ;background-position: left center;"> - <%= link_to topic.subject.truncate(30, omission: '...'), topic.event_url, :class => "gray" , :style => "font-size: 10pt !important;"%> + <%= link_to topic.subject.truncate(30, omission: '...'), topic.event_url, :class => "gray" , :style => "font-size: 10pt !important;", :target => "_blank" %> </span> <br> <span style="margin-left: 24px; color: rgb(172, 174, 177); white-space: nowrap; font-size: 9pt !important;;"><%=time_tag_welcome(topic_last_time topic)%>前</span> <span style="margin-left: 8px; margin-bottom: 0px; color: rgb(172, 174, 177) !important; white-space: nowrap;"> - 由 <%= link_to topic.author ? topic.author : 'Anonymous', user_path(topic.author_id), :style => "font-size: 9pt !important; color: rgb(17, 102, 173);"%> 发表 + 由 <%= link_to topic.author ? topic.author : 'Anonymous', user_path(topic.author_id), :style => "font-size: 9pt !important; color: rgb(17, 102, 173);", :target => "_blank" %> 发表 </span> - <span style="float: right; color: rgb(172, 174, 177); white-space: nowrap; font-size: 9pt !important;;">回复(<%= link_to topic.replies_count, topic.event_url %>)</span> + <span style="float: right; color: rgb(172, 174, 177); white-space: nowrap; font-size: 9pt !important;;">回复(<%= link_to topic.replies_count, topic.event_url, :target => "_blank" %>)</span> </div> </li> <% end %> @@ -123,7 +123,7 @@ <div class="right" style="float: right; margin-right: 10px; height: 445px; width: 45%; "> <ul class="user-welcome-message-list" style="width: 94%; margin-top: 0px;"> <h3 style="margin-left: -5px; color: rgb(21, 188, 207)"><strong>用户动态</strong></h3> - <span style="margin-top: -30px;float: right; display: block;"><%= link_to "更多>>", { :controller => 'users', :action => 'index'} %></span> + <span style="margin-top: -30px;float: right; display: block;"><%= link_to "更多>>", { :controller => 'users', :action => 'index'}, :target => "_blank" %></span> <div class="user-message-box-list"> <% find_all_activities.each do |event| %> <li style="display: block;height:60px; padding-bottom: 4px;"> @@ -131,7 +131,7 @@ <%= image_tag url_to_avatar(event.event_author), :class => "avatar-3" %> </div> <div class="inner-right" style="float: right; width:86%; height: 100%; "> - <span style="color: green;"><%= link_to event.event_author, (user_path(event.event_author) if event.event_author), :style => "color:green;" %></span><%= show_user_content event %> + <span style="color: green;"><%= link_to event.event_author, (user_path(event.event_author) if event.event_author), :style => "color:green;", :target => "_blank" %></span><%= show_user_content event %> <p style="margin-top: 4px;"><span style="color: rgb(172, 174, 177)"><%= time_tag_welcome event.event_datetime %>前</span> <span style="float: right; color: rgb(172, 174, 177);"><%= show_event_reply event %></span></p> </div> </li> @@ -143,7 +143,7 @@ <div id="J_Slide" class="d-p-index-box d-p-index-hotproject"> <h3 style="margin-left: 5px; color: #e8770d;"><strong>热门项目</strong></h3> - <span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", { :controller => 'projects', :action => 'index', :project_type => 0} %></span> + <span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", { :controller => 'projects', :action => 'index', :project_type => 0}, :target => "_blank" %></span> <div class="d-p-projectlist-box"> <ul class="d-p-projectlist"> <% find_all_hot_project.map do |project| break if(project == find_all_hot_project[15]) %> @@ -153,7 +153,7 @@ </div> <div style="float: left; margin-left: 10px; width: 360px;"> <p class="layout"> - <span style="display: inline-block; width: 250px;"><%= link_to( project.name, project_path(project.id), :class => "d-g-blue d-p-project-name", :title => "#{project.name}")%></span> + <span style="display: inline-block; width: 250px;"><%= link_to( project.name, project_path(project.id), :class => "d-g-blue d-p-project-name", :title => "#{project.name}", :target => "_blank" )%></span> <%= content_tag "span", show_grade(project), :style => "cursor: pointer; display: inline-block; float: right; color: #ec6300; ", :title => "项目得分,综合考虑了项目的各项活动,反映了该项目的活跃程度", @@ -172,7 +172,7 @@ <div id="J_Slide" class="d-p-index-box d-p-index-hotproject" style="float: right;"> <h3 style="margin-left: 5px; color: #e8770d;"><strong>热门课程</strong></h3> - <span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", {:controller => 'projects', :action => 'course', :project_type => 1, :project_sort_type => 1} %></span> + <span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", {:controller => 'projects', :action => 'course', :project_type => 1, :project_sort_type => 1}, :target => "_blank" %></span> <div class="d-p-projectlist-box"> <ul class="d-p-projectlist"> <% find_all_hot_course.map do |project| break if(project == find_all_hot_course[5]) %> @@ -186,8 +186,8 @@ </div> <div style="float: left; margin-left: 10px; width: 360px;"> <p class="layout"> - <%= link_to( project.name, project_path(project.id), :class => "d-g-blue d-p-project-name",:title => "#{project.name}")%> - <span style="cursor: pointer; display: inline-block; float: right; color: #ec6300; white-space: nowrap;">学生人数:<%= link_to "#{studentCount(project)}", project_member_path(project, :role => 2) ,:course =>'1'%></span> + <%= link_to( project.name, project_path(project.id), :class => "d-g-blue d-p-project-name",:title => "#{project.name}", :target => "_blank" )%> + <span style="cursor: pointer; display: inline-block; float: right; color: #ec6300; white-space: nowrap;">学生人数:<%= link_to "#{studentCount(project)}", project_member_path(project, :role => 2) ,:course =>'1', :target => "_blank" %></span> </p> <p class="layout-1" > <%= content_tag "span", project.description.truncate(50, omission: '...'), :class => "d-p-project-intro" , :title => project.description %> @@ -202,14 +202,14 @@ <div id="J_Slide" class="d-p-index-box d-p-index-hotproject" style="float: right;"> <h3 style="margin-left: 5px; color: color: (51, 119, 51);"><strong>热门竞赛</strong></h3> - <span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", {:controller => 'bids', :action => 'contest', :project_type => 1} %></span> + <span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", {:controller => 'bids', :action => 'contest', :project_type => 1}, :target => "_blank" %></span> <div class="d-p-projectlist-box"> <ul class="d-p-projectlist"> <% find_all_hot_contest.map do |contest| break if(contest == find_all_hot_contest[5]) %> <li style="background-image:none;"> <p class="layout"> <span style = "background: url('/images/007.gif') no-repeat scroll ;background-position: left center;"><%= link_to( contest.name, respond_path(contest.id), :class => "d-g-blue d-p-project-name", :title => "#{contest.name}", - :style => "margin-left: 28px;") %></span> + :style => "margin-left: 28px;", :target => "_blank") %></span> </p> <p class="layout-1" > <%= content_tag "span", contest.description.truncate(50, omission: '...'), :class => "d-p-project-intro" , :title => contest.description %> @@ -222,14 +222,14 @@ <div id="J_Slide" class="d-p-index-box d-p-index-hotproject" style="float: right;"> <h3 style="margin-left: 5px; color: color: (51, 119, 51);"><strong>热门众包</strong></h3> - <span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", {:controller => 'bids', :action => 'index'} %></span> + <span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", {:controller => 'bids', :action => 'index'}, :target => "_blank" %></span> <div class="d-p-projectlist-box"> <ul class="d-p-projectlist"> <% find_all_hot_bid.map do |bid| break if(bid == find_all_hot_bid[5]) %> <li style="background-image:none;"> <p class="layout"> <span style = "background: url('/images/007.gif') no-repeat scroll ;background-position: left center;"><%= link_to( bid.name, respond_path(bid.id), :class => "d-g-blue d-p-project-name", :title => "#{bid.name}", - :style => "margin-left: 28px;")%></span> + :style => "margin-left: 28px;", :target => "_blank") %></span> </p> <p class="layout-1" > <%= content_tag "span", bid.description.truncate(50, omission: '...'), :class => "d-p-project-intro" , :title => bid.description %> From e4ae5e56fc27dc37980b5158a840e6d59aece51e Mon Sep 17 00:00:00 2001 From: nieguanghui <hust.ud.hui@gmail.com> Date: Thu, 26 Dec 2013 20:22:19 +0800 Subject: [PATCH 6/9] delete leave message . --- app/controllers/words_controller.rb | 4 +--- app/views/words/_journal_reply_items.html.erb | 4 ++-- app/views/words/_message.html.erb | 4 ++-- app/views/words/_new_respond.html.erb | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index 193b2b61d..ce4523b2f 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -73,9 +73,7 @@ class WordsController < ApplicationController end def destroy - if User.current.admin? || @user.id == User.current.id || User.current.id == JournalsForMessage.find(params[:object_id]).jour_id - @journal_destroyed = JournalsForMessage.delete_message(params[:object_id]) - end + @journal_destroyed = JournalsForMessage.delete_message(params[:object_id]) @jours = @user.journals_for_messages.where('m_parent_id IS NULL').reverse @limit = 10 @feedback_count = @jours.count diff --git a/app/views/words/_journal_reply_items.html.erb b/app/views/words/_journal_reply_items.html.erb index 5a66b5133..9408722d9 100644 --- a/app/views/words/_journal_reply_items.html.erb +++ b/app/views/words/_journal_reply_items.html.erb @@ -16,9 +16,9 @@ {:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{id}'), $('##{id} textarea'), '#{l(:label_reply_plural)} #{journal.user.show_name}: '); return false;"} %> - <% if @user == User.current %> + <% if @user == User.current || User.current.admin? || reply.user.id == User.current.id %> <%= link_to(l(:label_newfeedback_delete), {:controller => 'words', :action => 'destroy', :object_id => reply, :user_id => reply.user}, - :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "delete", :title => l(:button_delete)) if (User.current.id == reply.user_id) || journal.jour_id == User.current.id %></td> + :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "delete", :title => l(:button_delete)) %> <% end %> </span> </p> diff --git a/app/views/words/_message.html.erb b/app/views/words/_message.html.erb index f5df90ec9..e9e14034d 100644 --- a/app/views/words/_message.html.erb +++ b/app/views/words/_message.html.erb @@ -22,9 +22,9 @@ {:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea'), '#{l(:label_reply_plural)} #{journal.user.show_name}: '); $('##{ids} textarea') ;return false;"} %> - <% if @user == User.current %> + <% if @user == User.current || User.current.admin? || journal.user.id == User.current.id %> <%= link_to(l(:label_newfeedback_delete), {:controller => 'words', :action => 'destroy', :object_id => journal, :user_id => user}, - :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "delete", :title => l(:button_delete)) if remove_allowed || journal.jour_id == User.current.id %></td> + :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "delete", :title => l(:button_delete)) %> <% end %> </span> </span> diff --git a/app/views/words/_new_respond.html.erb b/app/views/words/_new_respond.html.erb index 61953457a..25d4b7fcf 100644 --- a/app/views/words/_new_respond.html.erb +++ b/app/views/words/_new_respond.html.erb @@ -4,6 +4,6 @@ <%= hidden_field_tag 'reference_id', params[:reference_id], :value => journal.id %> <%= hidden_field_tag 'reference_user_id', params[:reference_user_id], :value => journal.user.id %> <%= hidden_field_tag 'reference_message_id', params[:reference_message_id], :value => m_reply_id %> -<%= submit_tag l(:button_projects_feedback_respond), :name => nil , :class => "bid_btn", :style => "margin-top: 1px;"%> +<%= submit_tag l(:button_projects_feedback_respond), :name => nil , :class => "enterprise", :style => "margin-top: 1px;"%> <% end %> \ No newline at end of file From e12922544a613f96e66064beee0026f30cd425a1 Mon Sep 17 00:00:00 2001 From: yanxd <sxty32@hotmaill.com> Date: Fri, 27 Dec 2013 09:00:50 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E9=93=BE=E6=8E=A5bug=EF=BC=8C=E5=8E=BB?= =?UTF-8?q?=E6=8E=89=E5=8A=A8=E6=80=81=E9=87=8C=E7=9A=84=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/welcome_helper.rb | 2 +- app/views/layouts/base_projects.html.erb | 2 +- app/views/projects/show.html.erb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index ff2801a53..cce439d79 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -135,7 +135,7 @@ module WelcomeHelper # } # user_objs = User.find_by_sql("SELECT * FROM users WHERE (users.id IN #{"(" << users.join(',') << ")"} )") activity = Redmine::Activity::Fetcher.new(nil) - activity.scope_select{|t| ['changesets'].include?(t) ? nil : 'You may think you know what the following code does, may be. but why don"t you close this file and go play with something else, Now?' } + activity.scope_select{|t| ['changesets', 'documents'].include?(t) ? nil : 'You may think you know what the following code does, may be. but why don"t you close this file and go play with something else, Now?' } activity.events_welcome(nil, nil, {:limit => limit, :types => 'welcome'}) end diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 6e184fa25..682791923 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -76,7 +76,7 @@ <% end %> <td class="font_index"><%=link_to "#{@project.members.count}", project_member_path(@project) %></td> - <td class="font_index"><%=link_to @project.watcher_users.count, :controller=>"projects", :action=>"watcherlist" %></td> + <td class="font_index"><%=link_to @project.watcher_users.count, :controller=>"projects", :action=>"watcherlist", :id => @project %></td> <td class="font_index"><%=link_to "#{@project.issues.count}", project_issues_path(@project) %></td> <!-- <td class="font_index"><%=link_to files_count, project_files_path(@project) %></td> --> </tr> diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb index 3436d62be..096db3218 100644 --- a/app/views/projects/show.html.erb +++ b/app/views/projects/show.html.erb @@ -21,7 +21,7 @@ <%= link_to_user(e.event_author) if e.respond_to?(:event_author) %> <%= l(:label_new_activity) %> </span> - <%= link_to "#{eventToLanguageCourse(e.event_type, @project)}: "<< format_activity_title(e.event_title), e.event_type.eql?("attachment") ? project_files_path(e.container) : e.event_url %> + <%= link_to "#{eventToLanguageCourse(e.event_type, @project)}: "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Project)) ? project_files_path(e.container) : e.event_url %> </td> </tr> <tr> From fea1cdff53d1331c233ed6909aaaa62abac34cd7 Mon Sep 17 00:00:00 2001 From: yanxd <sxty32@hotmaill.com> Date: Fri, 27 Dec 2013 13:54:57 +0800 Subject: [PATCH 8/9] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=8E=92=E5=BA=8F=EF=BC=8C=E5=8F=AF=E8=83=BD=E4=BC=9A=E5=BC=95?= =?UTF-8?q?=E8=B5=B7=E5=85=B6=E4=BB=96=E8=B0=83=E7=94=A8event=5Fdatetime?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82=E5=BE=85=E8=A7=82=E5=AF=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/messages_controller.rb | 1 + app/helpers/welcome_helper.rb | 13 ++++++++++++- app/models/forum.rb | 2 +- app/models/memo.rb | 3 ++- app/models/message.rb | 1 + 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index afa602d61..1baf5d62c 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -79,6 +79,7 @@ class MessagesController < ApplicationController @reply.board = @board @reply.safe_attributes = params[:reply] @topic.children << @reply + @topic.update_attribute(:updated_on, Time.now) if !@reply.new_record? call_hook(:controller_messages_reply_after_save, { :params => params, :message => @reply}) attachments = Attachment.attach_files(@reply, params[:attachments]) diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index cce439d79..fc19ccaa0 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -102,10 +102,21 @@ module WelcomeHelper end def find_new_forum_topics limit=7 - Memo.where('memos.parent_id IS NULL').reorder('memos.created_at DESC').limit(limit) + # Memo.where('memos.parent_id IS NULL').reorder('memos.created_at DESC').limit(limit) # activity = Redmine::Activity::Fetcher.new(nil) # activity.scope=['memos'] # activity.events_welcome(nil, nil, {:limit => limit}) + + # resultSet = Memo.where('memos.parent_id IS NULL').includes(:last_reply).order('COALESCE (last_replies_memos.created_at, memos.created_at) DESC').limit(limit) + # resultSet += Message.where('messages.parent_id IS NULL').includes(:last_reply).order('COALESCE (last_replies_messages.created_on, messages.created_on) DESC').limit(limit) + resultSet = Memo.where('parent_id IS NULL').order('updated_at DESC').limit(limit) + resultSet += Message.where('parent_id IS NULL').order('updated_on DESC').limit(limit) + # resultSet = resultSet.to_a + resultSet.sort! {|x,y| y.event_datetime <=> x.event_datetime} + # for i in 0..(resultSet.size-1) + # resultSet[i] = resultSet[i].parent if resultSet[i].parent + # end + resultSet.take(limit) end private diff --git a/app/models/forum.rb b/app/models/forum.rb index 3d4c3830d..aa7f16cd3 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -1,6 +1,6 @@ class Forum < ActiveRecord::Base include Redmine::SafeAttributes - has_many :topics, :class_name => 'Memo', :conditions => "#{Memo.table_name}.parent_id IS NULL", :order => "#{Memo.table_name}.created_at DESC" + has_many :topics, :class_name => 'Memo', :conditions => "#{Memo.table_name}.parent_id IS NULL", :order => "#{Memo.table_name}.created_at DESC", :dependent => :destroy has_many :memos, :dependent => :destroy belongs_to :creator, :class_name => "User", :foreign_key => 'creator_id' safe_attributes 'name', diff --git a/app/models/memo.rb b/app/models/memo.rb index 6841cc0fd..9b36cb726 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -17,7 +17,8 @@ class Memo < ActiveRecord::Base # #:project_key => "#{Forum.table_name}.project_id" # :date_column => "#{table_name}.created_at" acts_as_event :title => Proc.new {|o| "#{o.forum.name}: #{o.subject}"}, - :datetime => :created_at, + :datetime => :updated_at, + # :datetime => :created_at, :description => :content, :author => :author, :type => Proc.new {|o| o.parent_id.nil? ? 'Memo' : 'Reply'}, diff --git a/app/models/message.rb b/app/models/message.rb index b9f71b0ab..2421a7d4f 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -33,6 +33,7 @@ class Message < ActiveRecord::Base :date_column => "#{table_name}.created_on" acts_as_event :title => Proc.new {|o| "#{o.board.name}: #{o.subject}"}, :description => :content, + :datetime => :updated_on, # :datetime => "#{Message.table_name}.created_on", :group => :parent, :type => Proc.new {|o| o.parent_id.nil? ? 'message' : 'reply'}, From 8bc5b2ebf5219c86ba036eecd7ff390773aaba05 Mon Sep 17 00:00:00 2001 From: yanxd <sxty32@hotmaill.com> Date: Fri, 27 Dec 2013 15:04:05 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E6=94=B9=E4=BA=86=E8=AE=BA=E5=9D=9B?= =?UTF-8?q?=E5=9B=9E=E5=A4=8D=E4=B8=8D=E4=BC=9A=E8=A7=A6=E5=8F=91=E4=BF=AE?= =?UTF-8?q?=E6=94=B9update=E5=AD=97=E6=AE=B5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/memos_controller.rb | 11 ++++++----- app/models/memo.rb | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb index 30dca1c2a..ab8df148d 100644 --- a/app/controllers/memos_controller.rb +++ b/app/controllers/memos_controller.rb @@ -57,7 +57,7 @@ class MemosController < ApplicationController pre_count = REPLIES_PER_PAGE @memo = @memo.root # 取出楼主,防止输入帖子id让回复作为主贴显示 - @memo.update_attribute(:viewed_count, @memo.viewed_count.to_i + 1) + @memo.update_column(:viewed_count, (@memo.viewed_count.to_i + 1)) page = params[:page] if params[:r] && page.nil? @@ -95,11 +95,12 @@ class MemosController < ApplicationController def update respond_to do |format| - if( @memo.update_attribute(:subject, params[:memo][:subject]) && - @memo.update_attribute(:content, params[:memo][:content]) && - @memo.update_attribute(:sticky, params[:memo][:sticky]) && - @memo.update_attribute(:lock, params[:memo][:lock])) + 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])) @memo.save_attachments(params[:attachments] || (params[:memo] && params[:memo][:uploads])) + # @memo.root.update_attribute(:updated_at, @memo.updated_at) format.html {redirect_to back_memo_url, notice: "#{l :label_memo_create_succ}"} else format.html { render action: "edit" } diff --git a/app/models/memo.rb b/app/models/memo.rb index 9b36cb726..31b412a43 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -65,6 +65,7 @@ class Memo < ActiveRecord::Base def reset_counters! if parent && parent.id Memo.update_all({:last_reply_id => parent.children.maximum(:id)}, {:id => parent.id}) + parent.update_attribute(:updated_at, Time.now) end forum.reset_counters! end