diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb
index 30dca1c2..ab8df148 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/controllers/messages_controller.rb b/app/controllers/messages_controller.rb
index afa602d6..1baf5d62 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/controllers/words_controller.rb b/app/controllers/words_controller.rb
index 7c05c5af..ce4523b2 100644
--- a/app/controllers/words_controller.rb
+++ b/app/controllers/words_controller.rb
@@ -73,10 +73,8 @@ class WordsController < ApplicationController
end
def destroy
- if User.current.admin? || User.current.id == @user.id
- JournalsForMessage.delete_message(params[:object_id])
- end
- @jours = @user.journals_for_messages.reverse
+ @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
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb
index f862ce30..fc19ccaa 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
@@ -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
@@ -135,7 +146,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/models/forum.rb b/app/models/forum.rb
index 3d4c3830..aa7f16cd 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/journals_for_message.rb b/app/models/journals_for_message.rb
index e00564f1..e83018be 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/models/memo.rb b/app/models/memo.rb
index 6841cc0f..31b412a4 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'},
@@ -64,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
diff --git a/app/models/message.rb b/app/models/message.rb
index b9f71b0a..2421a7d4 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'},
diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erb
index 8388b6ae..47662f25 100644
--- a/app/views/forums/show.html.erb
+++ b/app/views/forums/show.html.erb
@@ -2,7 +2,7 @@
<%=l(:label_memo_new)%>
<% 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? %>
<%= pluralize(@memo.errors.count, "error") %> prohibited this memo from being saved:
diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb
index 6e184fa2..68279192 100644
--- a/app/views/layouts/base_projects.html.erb
+++ b/app/views/layouts/base_projects.html.erb
@@ -76,7 +76,7 @@
<% end %>
<%=link_to "#{@project.members.count}", project_member_path(@project) %> |
-
<%=link_to @project.watcher_users.count, :controller=>"projects", :action=>"watcherlist" %> |
+
<%=link_to @project.watcher_users.count, :controller=>"projects", :action=>"watcherlist", :id => @project %> |
<%=link_to "#{@project.issues.count}", project_issues_path(@project) %> |
diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb
index 3436d62b..096db321 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) %>
- <%= 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 %>
diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb
index 32cb4316..2f027957 100644
--- a/app/views/welcome/index.html.erb
+++ b/app/views/welcome/index.html.erb
@@ -97,7 +97,7 @@
贴吧动态
- <%= link_to "更多>>", forums_path %>
+ <%= link_to "更多>>", forums_path, :target => "_blank" %>
@@ -105,14 +105,14 @@
- <%= 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" %>
<%=time_tag_welcome(topic_last_time topic)%>前
- 由 <%= 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" %> 发表
- 回复(<%= link_to topic.replies_count, topic.event_url %>)
+ 回复(<%= link_to topic.replies_count, topic.event_url, :target => "_blank" %>)
<% end %>
@@ -123,7 +123,7 @@
用户动态
- <%= link_to "更多>>", { :controller => 'users', :action => 'index'} %>
+ <%= link_to "更多>>", { :controller => 'users', :action => 'index'}, :target => "_blank" %>
<% find_all_activities.each do |event| %>
-
@@ -131,7 +131,7 @@
<%= image_tag url_to_avatar(event.event_author), :class => "avatar-3" %>
-
<%= link_to event.event_author, (user_path(event.event_author) if event.event_author), :style => "color:green;" %><%= show_user_content event %>
+
<%= link_to event.event_author, (user_path(event.event_author) if event.event_author), :style => "color:green;", :target => "_blank" %><%= show_user_content event %>
<%= time_tag_welcome event.event_datetime %>前 <%= show_event_reply event %>
@@ -143,7 +143,7 @@
热门项目
-
<%= link_to "更多>>", { :controller => 'projects', :action => 'index', :project_type => 0} %>
+
<%= link_to "更多>>", { :controller => 'projects', :action => 'index', :project_type => 0}, :target => "_blank" %>
<% find_all_hot_project.map do |project| break if(project == find_all_hot_project[15]) %>
@@ -153,7 +153,7 @@
- <%= link_to( project.name, project_path(project.id), :class => "d-g-blue d-p-project-name", :title => "#{project.name}")%>
+ <%= link_to( project.name, project_path(project.id), :class => "d-g-blue d-p-project-name", :title => "#{project.name}", :target => "_blank" )%>
<%= content_tag "span", show_grade(project),
:style => "cursor: pointer; display: inline-block; float: right; color: #ec6300; ",
:title => "项目得分,综合考虑了项目的各项活动,反映了该项目的活跃程度",
@@ -172,7 +172,7 @@
热门课程
-
<%= link_to "更多>>", {:controller => 'projects', :action => 'course', :project_type => 1, :project_sort_type => 1} %>
+
<%= link_to "更多>>", {:controller => 'projects', :action => 'course', :project_type => 1, :project_sort_type => 1}, :target => "_blank" %>
<% find_all_hot_course.map do |project| break if(project == find_all_hot_course[5]) %>
@@ -186,8 +186,8 @@
- <%= link_to( project.name, project_path(project.id), :class => "d-g-blue d-p-project-name",:title => "#{project.name}")%>
- 学生人数:<%= link_to "#{studentCount(project)}", project_member_path(project, :role => 2) ,:course =>'1'%>
+ <%= link_to( project.name, project_path(project.id), :class => "d-g-blue d-p-project-name",:title => "#{project.name}", :target => "_blank" )%>
+ 学生人数:<%= link_to "#{studentCount(project)}", project_member_path(project, :role => 2) ,:course =>'1', :target => "_blank" %>
<%= content_tag "span", project.description.truncate(50, omission: '...'), :class => "d-p-project-intro" , :title => project.description %>
@@ -202,14 +202,14 @@
热门竞赛
-
<%= link_to "更多>>", {:controller => 'bids', :action => 'contest', :project_type => 1} %>
+
<%= link_to "更多>>", {:controller => 'bids', :action => 'contest', :project_type => 1}, :target => "_blank" %>
<% find_all_hot_contest.map do |contest| break if(contest == find_all_hot_contest[5]) %>
-
<%= link_to( contest.name, respond_path(contest.id), :class => "d-g-blue d-p-project-name", :title => "#{contest.name}",
- :style => "margin-left: 28px;") %>
+ :style => "margin-left: 28px;", :target => "_blank") %>
<%= content_tag "span", contest.description.truncate(50, omission: '...'), :class => "d-p-project-intro" , :title => contest.description %>
@@ -222,14 +222,14 @@
热门众包
-
<%= link_to "更多>>", {:controller => 'bids', :action => 'index'} %>
+
<%= link_to "更多>>", {:controller => 'bids', :action => 'index'}, :target => "_blank" %>
<% find_all_hot_bid.map do |bid| break if(bid == find_all_hot_bid[5]) %>
-
<%= link_to( bid.name, respond_path(bid.id), :class => "d-g-blue d-p-project-name", :title => "#{bid.name}",
- :style => "margin-left: 28px;")%>
+ :style => "margin-left: 28px;", :target => "_blank") %>
<%= content_tag "span", bid.description.truncate(50, omission: '...'), :class => "d-p-project-intro" , :title => bid.description %>
diff --git a/app/views/words/_journal_reply.html.erb b/app/views/words/_journal_reply.html.erb
index a909362d..1249c9cb 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%>
-
+
\ No newline at end of file
diff --git a/app/views/words/_message.html.erb b/app/views/words/_message.html.erb
index b756141b..e9e14034 100644
--- a/app/views/words/_message.html.erb
+++ b/app/views/words/_message.html.erb
@@ -3,34 +3,39 @@
<% remove_allowed = (User.current.id == jour.first.user_id) %>
<% end %>
diff --git a/app/views/words/_new_respond.html.erb b/app/views/words/_new_respond.html.erb
index 61953457..25d4b7fc 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
diff --git a/app/views/words/create_reply.js.erb b/app/views/words/create_reply.js.erb
index 20964d9b..6d625bdc 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 53dc614b..6b582f80 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 fd44c577..de55fe39 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 204a67b5..e7885787 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 65af8714..3ab51764 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 437720c5..0dcca361 100644
--- a/public/themes/redpenny-master/stylesheets/application.css
+++ b/public/themes/redpenny-master/stylesheets/application.css
@@ -2118,11 +2118,26 @@ span.body{
ul.messages-for-user-reply li {
padding-bottom: 4px;
+ font-size: 9pt;
}
.respond-form{
display: none;
- width: 100%;
+ width: 87%;
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