From e80149c6c8b477eed3beb61f8f14b5d0bc68ab84 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Sun, 10 Jan 2016 15:38:45 +0800 Subject: [PATCH 1/6] =?UTF-8?q?@7008=E6=89=BE=E4=B8=8D=E5=88=B0=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index aa048888c..f3367db59 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -409,7 +409,7 @@ class User < Principal def get_at_show_name name = show_name - name = "#{name} #{self.login}" if name != self.login + (name != self.login) ? "#{name} #{self.login}" : name end #added by nie From a3a16b5591afa81cf928180a8f334f9201e6e6f9 Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 11 Jan 2016 10:21:42 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E9=97=AE=E9=A2=98=E8=B7=9F=E8=B8=AA?= =?UTF-8?q?=E3=80=81=E4=BD=9C=E4=B8=9A=E5=88=97=E8=A1=A8=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E2=80=9C=E5=B1=95=E5=BC=80=E6=9B=B4=E5=A4=9A=E2=80=9D=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E2=80=9C=E7=82=B9=E5=87=BB=E5=B1=95=E5=BC=80=E6=9B=B4?= =?UTF-8?q?=E5=A4=9A=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/issues/_list.html.erb | 11 +---------- app/views/users/_user_homework_list.html.erb | 4 ++-- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/app/views/issues/_list.html.erb b/app/views/issues/_list.html.erb index e47967099..2a1ae56d4 100644 --- a/app/views/issues/_list.html.erb +++ b/app/views/issues/_list.html.erb @@ -24,14 +24,5 @@ <%= render :partial => 'users/project_issue', :locals => {:activity => issue, :user_activity_id => issue.id} %> <% end %> <% if issues.count == 10%> -
展开更多<%=link_to "", project_issues_path({:project_id => project.id}.merge(params)),:id => "more_issues_link",:remote => "true",:class => "none" %>
- <%#= link_to "点击展开更多",user_activities_path(@user.id,:type => type,:page => page),:id => "show_more_activities",:remote => "true",:class => "loadMore mt10 f_grey"%> + <%= link_to "点击展开更多",project_issues_path({:project_id => project.id}.merge(params)),:id => "show_more_issues",:remote => "true",:class => "loadMore mt10 f_grey"%> <% end%> - - - - \ No newline at end of file diff --git a/app/views/users/_user_homework_list.html.erb b/app/views/users/_user_homework_list.html.erb index efe9216df..36f823a9a 100644 --- a/app/views/users/_user_homework_list.html.erb +++ b/app/views/users/_user_homework_list.html.erb @@ -42,9 +42,9 @@ <% if homework_commons.count == 10%> <% if is_in_course == 1%> - <%= link_to "加载更多",homework_common_index_path(:course => course_id,:page => page,:is_in_course => is_in_course),:id => "user_show_more_homework",:remote => "true",:class => "loadMore f_grey"%> + <%= link_to "点击展开更多",homework_common_index_path(:course => course_id,:page => page,:is_in_course => is_in_course),:id => "user_show_more_homework",:remote => "true",:class => "loadMore f_grey"%> <% else%> - <%= link_to "加载更多",user_homeworks_user_path(User.current.id,:page => page,:is_in_course => is_in_course),:id => "user_show_more_homework",:remote => "true",:class => "loadMore f_grey"%> + <%= link_to "点击展开更多",user_homeworks_user_path(User.current.id,:page => page,:is_in_course => is_in_course),:id => "user_show_more_homework",:remote => "true",:class => "loadMore f_grey"%> <% end%> <% end%> \ No newline at end of file From a93539da5e44740f9c98d22defd7b0ce3b97d7eb Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 11 Jan 2016 11:07:03 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=AD=A6=E6=9C=9F?= =?UTF-8?q?=E5=BE=80=E5=89=8D=E6=8E=A8=E4=B8=80=E4=B8=AA=E5=AD=A6=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/courses_helper.rb | 4 +++- public/stylesheets/public.css | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index a1b119cb5..097a3c1a4 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -507,8 +507,10 @@ module CoursesHelper #课程实践年份下拉框 def course_time_option year type = [] + month = Time.now.month now_year = year.nil? ? Time.now.year : (Time.now.year <= year ? Time.now.year : year) - for i in (now_year..now_year + 10) + year = month < 3 ? now_year - 1 : now_year + for i in (year..year + 10) option = [] option << i option << i diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index d39e2600d..23550c623 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -397,7 +397,7 @@ li.menuArrow:hover {background:url(../images/item.png) -20px -70px no-repeat;} a.topnav_login_box:hover {color:#a1ebff;} .navRow1 {margin:0; padding:0;} .navRow2 {margin:0; padding:0;} -.topnav_login_list{ border:1px solid #269ac9; background:#fff; padding-left:10px; padding-bottom:10px; padding-top:8px; width:60px; left:-7px; position:absolute; z-index:9999; line-height:2;} +.topnav_login_list{ border:1px solid #eaeaea; background:#fff; padding-left:10px; padding-bottom:10px; padding-top:8px; width:60px; left:-7px; position:absolute; z-index:9999; line-height:2;} .topnav_login_list a{color:#15bccf;} .topnav_login_list li{ } From e5f8c4c4a8332323ae1a217afa09cfc382f6988f Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 11 Jan 2016 17:00:29 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E7=9A=84=E5=AF=B9=E9=BD=90=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/stylesheets/public.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index 23550c623..b90758914 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -158,7 +158,7 @@ h4{ font-size:14px; color:#3b3b3b;} .w583{ width:583px;} .w350{ width:350px;} .w610{ width:610px;} -.w60{ width:600px !important;} +.w600{ width:600px !important;} .w606{ width:606px } .h20{height: 20px;} .h22{ height:22px;} From b48a2848b03780520af1bdf711c88d6f5285c57a Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 12 Jan 2016 15:53:15 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E3=80=81=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E3=80=81=E9=A1=B9=E7=9B=AE=E3=80=81=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E5=A2=9E=E5=8A=A0=E6=9B=B4=E6=96=B0=E6=97=B6?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/comments_controller.rb | 13 ++---- app/controllers/issues_controller.rb | 12 +++--- app/controllers/messages_controller.rb | 25 +++-------- app/controllers/student_work_controller.rb | 14 ++----- app/controllers/words_controller.rb | 33 ++++----------- app/helpers/application_helper.rb | 41 +++++++++++++++++++ app/models/course.rb | 8 +++- app/models/homework_common.rb | 8 +++- app/models/issue.rb | 10 ++++- app/models/journals_for_message.rb | 9 ++++ app/models/message.rb | 11 ++++- app/models/news.rb | 10 ++++- app/models/org_document_comment.rb | 10 +++++ app/models/poll.rb | 9 +++- app/views/files/_course_list.html.erb | 2 +- app/views/files/_project_list.html.erb | 2 +- .../organizations/_org_course_create.html.erb | 6 ++- .../_org_course_message.html.erb | 6 ++- .../organizations/_org_course_news.html.erb | 6 ++- .../organizations/_org_course_poll.html.erb | 6 ++- .../organizations/_org_project_issue.html.erb | 8 +++- .../_org_subfield_message.html.erb | 8 +++- .../organizations/_project_create.html.erb | 6 ++- .../organizations/_project_message.html.erb | 8 +++- .../organizations/_show_org_document.html.erb | 9 +++- app/views/projects/_project_news.html.erb | 6 ++- app/views/users/_course_create.html.erb | 6 ++- .../users/_course_journalsformessage.html.erb | 6 ++- app/views/users/_course_message.html.erb | 6 ++- app/views/users/_course_news.html.erb | 6 ++- app/views/users/_course_poll.html.erb | 8 +++- app/views/users/_project_create.html.erb | 6 ++- app/views/users/_project_issue.html.erb | 8 +++- app/views/users/_project_message.html.erb | 8 +++- .../users/_user_journalsformessage.html.erb | 6 ++- 35 files changed, 240 insertions(+), 106 deletions(-) diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 11a788590..c8dcf0b8e 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -54,16 +54,9 @@ class CommentsController < ApplicationController # end # # ������ض�̬�ļ�¼add end #flash[:notice] = l(:label_comment_added) - course_activity = CourseActivity.where("course_act_type='News' and course_act_id =#{@news.id}").first - if course_activity - course_activity.updated_at = Time.now - course_activity.save - end - user_activity = UserActivity.where("act_type='News' and act_id =#{@news.id}").first - if user_activity - user_activity.updated_at = Time.now - user_activity.save - end + update_course_activity(@news.class,@news.id) + update_user_activity(@news.class,@news.id) + update_org_activity(@news.class,@news.id) end if params[:user_activity_id] diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 4aa959e81..8fc13c83c 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -405,9 +405,9 @@ class IssuesController < ApplicationController jour.journalized = @issue jour.save_attachments(params[:attachments]) jour.save - user_activity = UserActivity.where("act_type='Issue' and act_id =#{@issue.id}").first - user_activity.updated_at = jour.created_on - user_activity.save + update_user_activity(@issue.class,@issue.id) + update_forge_activity(@issue.class,@issue.id) + @user_activity_id = params[:user_activity_id] if params[:issue_id] @issue_id = params[:issue_id] @@ -455,9 +455,9 @@ class IssuesController < ApplicationController @issue = Issue.find params[:id] jour.journalized = @issue jour.save - user_activity = UserActivity.where("act_type='Issue' and act_id =#{@issue.id}").first - user_activity.updated_at = jour.created_on - user_activity.save + update_user_activity(@issue.class,@issue.id) + update_forge_activity(@issue.class,@issue.id) + respond_to do |format| format.js end diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 72bffa06c..17111b3f3 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -176,26 +176,11 @@ class MessagesController < ApplicationController @reply.subject = "RE: #{@topic.subject}" unless params[:reply][:subject] # @reply.reply_id = params[:id] @topic.children << @reply - course_activity = CourseActivity.where("course_act_type='Message' and course_act_id =#{@topic.id}").first - if course_activity - course_activity.updated_at = Time.now - course_activity.save - end - forge_activity = ForgeActivity.where("forge_act_type='Message' and forge_act_id=#{@topic.id}").first - if forge_activity - forge_activity.updated_at = Time.now - forge_activity.save - end - user_activity = UserActivity.where("act_type='Message' and act_id =#{@topic.id}").first - if user_activity - user_activity.updated_at = Time.now - user_activity.save - end - org_activity = OrgActivity.where("org_act_type='Message' and org_act_id =#{@topic.id}").first - if org_activity - org_activity.updated_at = Time.now - org_activity.save - end + update_course_activity(@topic.class,@topic.id) + update_user_activity(@topic.class,@topic.id) + update_forge_activity(@topic.class,@topic.id) + update_org_activity(@topic.class,@topic.id) + #@topic.update_attribute(:updated_on, Time.now) if !@reply.new_record? if params[:asset_id] diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 9319c4db2..2f6c4ecc7 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -259,16 +259,10 @@ class StudentWorkController < ApplicationController stu_project.save end end - course_activity = CourseActivity.where("course_act_type='HomeworkCommon' and course_act_id =#{@homework.id}").first - if course_activity - course_activity.updated_at = Time.now - course_activity.save - end - user_activity = UserActivity.where("act_type='HomeworkCommon' and act_id =#{@homework.id}").first - if user_activity - user_activity.updated_at = Time.now - user_activity.save - end + update_course_activity(@homework.class,@homework.id) + update_user_activity(@homework.class,@homework.id) + update_org_activity(@homework.class,@homework.id) + course_message = CourseMessage.new(:user_id =>User.current.id,:content=>"new",:course_message_id=>student_work.id,:course_id => @course.id,:course_message_type=>"StudentWork", :status => 9) #作品提交记录 course_message.save diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index 79981ec4d..ebd46caa7 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -57,21 +57,11 @@ class WordsController < ApplicationController @jfm = add_reply_adapter options @save_succ = true if @jfm.errors.empty? if @save_succ - course_activity = CourseActivity.where("course_act_type='JournalsForMessage' and course_act_id =#{parent_id}").first - if course_activity - course_activity.updated_at = Time.now - course_activity.save - end - principal_activity = PrincipalActivity.where("principal_act_type='JournalsForMessage' and principal_act_id =#{parent_id}").first - if principal_activity - principal_activity.updated_at = Time.now - principal_activity.save - end - user_activity = UserActivity.where("act_type='JournalsForMessage' and act_id =#{parent_id}").first - if user_activity - user_activity.updated_at = Time.now - user_activity.save - end + update_course_activity('JournalsForMessage',parent_id) + update_user_activity('JournalsForMessage',parent_id) + update_forge_activity('JournalsForMessage',parent_id) + update_org_activity('JournalsForMessage',parent_id) + update_principal_activity('JournalsForMessage',parent_id) end respond_to do |format| # format.html { @@ -278,16 +268,9 @@ class WordsController < ApplicationController update_kindeditor_assets_owner ids,feedback[:id],OwnerTypeHelper::JOURNALSFORMESSAGE end - course_activity = CourseActivity.where("course_act_type='HomeworkCommon' and course_act_id =#{@homework_common.id}").first - if course_activity - course_activity.updated_at = Time.now - course_activity.save - end - user_activity = UserActivity.where("act_type='HomeworkCommon' and act_id =#{@homework_common.id}").first - if user_activity - user_activity.updated_at = Time.now - user_activity.save - end + update_course_activity(@homework_common.class,@homework_common.id) + update_user_activity(@homework_common.class,@homework_common.id) + update_org_activity(@homework_common.class,@homework_common.id) respond_to do |format| format.js{ @user_activity_id = params[:user_activity_id] diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9b7888bf2..5b7cca7fe 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2788,4 +2788,45 @@ int main(int argc, char** argv){ # # commits_total_count(project.gpid) # project.changesets.count end + + #课程动态的更新 + def update_course_activity type, id + course_activity = CourseActivity.where("course_act_type=? and course_act_id =?", type.to_s, id).first + if course_activity + course_activity.updated_at = Time.now + course_activity.save + end + end + #首页动态更新 + def update_user_activity type, id + user_activity = UserActivity.where("act_type=? and act_id =?", type.to_s, id).first + if user_activity + user_activity.updated_at = Time.now + user_activity.save + end + end + #项目动态更新 + def update_forge_activity type, id + forge_activity = ForgeActivity.where("forge_act_type=? and forge_act_id=?", type.to_s, id).first + if forge_activity + forge_activity.updated_at = Time.now + forge_activity.save + end + end + #组织动态更新 + def update_org_activity type , id + org_activity = OrgActivity.where("org_act_type=? and org_act_id =?", type.to_s, id).first + if org_activity + org_activity.updated_at = Time.now + org_activity.save + end + end + #个人动态更新 + def update_principal_activity type, id + principal_activity = PrincipalActivity.where("principal_act_type=? and principal_act_id =?", type.to_s, id).first + if principal_activity + principal_activity.updated_at = Time.now + principal_activity.save + end + end end diff --git a/app/models/course.rb b/app/models/course.rb index 0194a2a9d..4e3b4fff0 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -70,7 +70,7 @@ class Course < ActiveRecord::Base validates_length_of :description, :maximum => 10000 before_save :self_validate # 公开课程变成私有课程,所有资源都变成私有 - after_update :update_files_public,:update_course_ealasticsearch_index + after_update :update_files_public,:update_course_ealasticsearch_index,:update_activity after_create :create_board_sync, :act_as_course_activity, :act_as_course_message,:create_course_ealasticsearch_index before_destroy :delete_all_members,:delete_course_ealasticsearch_index @@ -428,6 +428,12 @@ class Course < ActiveRecord::Base end end end +#动态的更新 +def update_activity + update_course_activity(self.class, self.id) + update_user_activity(self.class, self.id) + update_org_activity(self.class, self.id) +end # Delete the previous articles index in Elasticsearch # Course.__elasticsearch__.client.indices.delete index: Course.index_name rescue nil diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index 0ad667bd1..f8e222b0f 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -26,6 +26,7 @@ class HomeworkCommon < ActiveRecord::Base :author => :author, :url => Proc.new {|o| {:controller => 'student_work', :action => 'index', :homework => o.id}} after_create :act_as_activity, :send_mail, :act_as_course_message + after_update :update_activity after_save :act_as_course_activity after_destroy :delete_kindeditor_assets @@ -60,7 +61,12 @@ class HomeworkCommon < ActiveRecord::Base end end end - + #动态的更新 + def update_activity + update_course_activity(self.class, self.id) + update_user_activity(self.class, self.id) + update_org_activity(self.class, self.id) + end #删除对应的图片 def delete_kindeditor_assets delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::HOMEWORKCOMMON diff --git a/app/models/issue.rb b/app/models/issue.rb index 5ecb3e36f..4dfa643fa 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -84,7 +84,7 @@ class Issue < ActiveRecord::Base # fq after_create :act_as_activity,:be_user_score_new_issue,:act_as_forge_activity, :act_as_forge_message, :act_as_at_message - after_update :be_user_score + after_update :be_user_score,:update_activity after_destroy :down_user_score # after_create :be_user_score # end @@ -126,7 +126,13 @@ class Issue < ActiveRecord::Base after_save :after_create_from_copy after_destroy :update_parent_attributes - + #动态的更新 + def update_activity + update_user_activity(self.class, self.id) + update_forge_activity(self.class, self.id) + update_org_activity(self.class, self.id) + end + # fq def act_as_activity self.acts << Activity.new(:user_id => self.author_id) diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index d3e76addc..9e0ce2dd2 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -70,12 +70,21 @@ class JournalsForMessage < ActiveRecord::Base validates :notes, presence: true, if: :is_homework_jour? after_create :act_as_activity, :act_as_course_activity, :act_as_course_message, :act_as_at_message, :act_as_user_feedback_message, :act_as_principal_activity, :act_as_student_score after_create :reset_counters! + after_update :update_ativity after_destroy :reset_counters! after_save :be_user_score after_destroy :down_user_score # default_scope { where('m_parent_id IS NULL') } + #动态的更新 + def update_activity + update_course_activity(self.class, self.id) + update_user_activity(self.class, self.id) + update_forge_activity(self.class, self.id) + update_org_activity(self.class, self.id) + update_principal_activity(self.class, self.id) + end def self.create_by_user? user if user.anonymous? return false diff --git a/app/models/message.rb b/app/models/message.rb index 3bb08f481..b11b2cc1d 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -36,6 +36,8 @@ class Message < ActiveRecord::Base has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy # 课程动态 has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy + has_many :user_acts, :class_name => 'UserActivity',:as =>:user_act ,:dependent => :destroy + # end # 课程/项目 消息 has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy @@ -75,7 +77,7 @@ class Message < ActiveRecord::Base validate :cannot_reply_to_locked_topic, :on => :create after_create :add_author_as_watcher, :reset_counters! - after_update :update_messages_board + after_update :update_messages_board, :update_activity after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets after_create :act_as_activity,:act_as_course_activity,:be_user_score,:act_as_forge_activity, :act_as_system_message, :send_mail, :act_as_student_score, :act_as_at_message @@ -180,6 +182,13 @@ class Message < ActiveRecord::Base def get_notify_is_read() return @notify_is_read end + #动态的更新 + def update_activity + update_course_activity(self.class, self.id) + update_user_activity(self.class, self.id) + update_forge_activity(self.class, self.id) + update_org_activity(self.class, self.id) + end private diff --git a/app/models/news.rb b/app/models/news.rb index a7407c91f..e00437fd8 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -56,7 +56,7 @@ class News < ActiveRecord::Base acts_as_watchable after_create :act_as_activity,:act_as_forge_activity, :act_as_course_activity,:act_as_system_message, :add_author_as_watcher, :send_mail - + after_update :update_activity after_destroy :delete_kindeditor_assets scope :visible, lambda {|*args| @@ -68,6 +68,14 @@ class News < ActiveRecord::Base } safe_attributes 'title', 'summary', 'description', 'sticky' + #动态的更新 + def update_activity + update_course_activity(self.class, self.id) + update_user_activity(self.class, self.id) + update_org_activity(self.class, self.id) + update_forge_activity(self.class, self.id) + end + def visible?(user=User.current) !user.nil? && user.allowed_to?(:view_news, project) end diff --git a/app/models/org_document_comment.rb b/app/models/org_document_comment.rb index c1619fc6e..75db910c3 100644 --- a/app/models/org_document_comment.rb +++ b/app/models/org_document_comment.rb @@ -8,6 +8,16 @@ class OrgDocumentComment < ActiveRecord::Base acts_as_attachable has_many :org_acts, :class_name => 'OrgActivity',:as =>:org_act ,:dependent => :destroy after_create :document_save_as_org_activity + after_update :update_activity + + #动态的更新 + def update_activity + org_activity = OrgActivity.where("org_act_type='OrgDocumentComment' and org_act_id =?", id).first + if org_activity + org_activity.updated_at = Time.now + org_activity.save + end + end def document_save_as_org_activity if(self.parent().nil?) diff --git a/app/models/poll.rb b/app/models/poll.rb index 67bb9f5a8..41bfe8a72 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -14,7 +14,7 @@ class Poll < ActiveRecord::Base # 课程消息 has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy after_save :act_as_course_message, :act_as_activity, :act_as_course_activity - + after_update :update_activity acts_as_event :title => Proc.new {|o| "#{l(:label_course_poll)}: #{o.polls_name}" }, :description => :polls_description, :datetime => :published_at, @@ -32,6 +32,13 @@ class Poll < ActiveRecord::Base self.acts << Activity.new(:user_id => self.user_id) end + #动态的更新 + def update_activity + update_course_activity(self.class, self.id) + update_user_activity(self.class, self.id) + update_org_activity(self.class, self.id) + end + #课程动态公共表记录 def act_as_course_activity if self.polls_type == "Course" diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb index 9c3c1efe2..f1d96d22c 100644 --- a/app/views/files/_course_list.html.erb +++ b/app/views/files/_course_list.html.erb @@ -20,7 +20,7 @@
- 上传时间:<%= format_date(file.created_on)%> + 上传时间:<%= format_time(file.created_on)%> <% if file.tag_list.length > 0%> 上传类型:<%= file.tag_list[0] %> <% end %> diff --git a/app/views/files/_project_list.html.erb b/app/views/files/_project_list.html.erb index 0d4b0f35e..391430126 100644 --- a/app/views/files/_project_list.html.erb +++ b/app/views/files/_project_list.html.erb @@ -19,7 +19,7 @@
- 上传时间:<%= format_date(file.created_on)%> + 上传时间:<%= format_time(file.created_on)%> <% if file.tag_list.length > 0%> 上传类型:<%= file.tag_list[0] %> <% end %> diff --git a/app/views/organizations/_org_course_create.html.erb b/app/views/organizations/_org_course_create.html.erb index dc1e0ee81..a5544ab07 100644 --- a/app/views/organizations/_org_course_create.html.erb +++ b/app/views/organizations/_org_course_create.html.erb @@ -17,9 +17,13 @@
<%= link_to activity.name, course_path(activity.id,:host=>Setting.host_course), :class => "postGrey" %>
-
+
创建时间:<%= format_time(activity.created_at) %>
+
+ 更新时间:<%= format_time(CourseActivity.where("course_act_type='#{activity.class}' and course_act_id =#{activity.id}").first.updated_at) %> +
+