From 6517f23f03e727599ee39aeacc3e64df182b0ba1 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 19 May 2016 15:26:23 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E4=B8=8D=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=9A=84=E5=88=9B=E5=BB=BA=E5=8A=A8=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/activities.rb | 2 +- app/api/mobile/entities/activity.rb | 6 +++--- app/controllers/organizations_controller.rb | 2 +- app/controllers/users_controller.rb | 2 +- app/controllers/wechats_controller.rb | 2 +- app/models/course_activity.rb | 3 +-- app/models/forge_activity.rb | 2 +- app/views/organizations/_org_activities.html.erb | 2 +- app/views/organizations/_org_project_activities.html.erb | 2 +- app/views/users/_user_activities.html.erb | 4 ++-- db/migrate/20160519070718_change_user_activities_data.rb | 9 +++++++++ db/schema.rb | 3 ++- 12 files changed, 24 insertions(+), 15 deletions(-) create mode 100644 db/migrate/20160519070718_change_user_activities_data.rb diff --git a/app/api/mobile/apis/activities.rb b/app/api/mobile/apis/activities.rb index ae60d548a..cbd43bb79 100644 --- a/app/api/mobile/apis/activities.rb +++ b/app/api/mobile/apis/activities.rb @@ -36,7 +36,7 @@ module Mobile user_project_ids = (user.projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (user.projects.map{|project| project.id}-shield_project_ids).join(",") + ")" user_course_ids = (user.courses.visible.where("is_delete = 0").map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (user.courses.map{|course| course.id}-shield_course_ids).join(",") + ")" course_types = "('Message','News','HomeworkCommon','Poll','Course')" - project_types = "('Message','Issue','ProjectCreateInfo')" + project_types = "('Message','Issue','Project')" principal_types = "JournalsForMessage" watched_user_ids = User.watched_by(user.id).count == 0 ? " " : ("," + User.watched_by(user.id).map{|u| u.id.to_s }.join(',')) user_ids = "(" + user.id.to_s + watched_user_ids + ")" diff --git a/app/api/mobile/entities/activity.rb b/app/api/mobile/entities/activity.rb index 20876bf69..3eab332a7 100644 --- a/app/api/mobile/entities/activity.rb +++ b/app/api/mobile/entities/activity.rb @@ -14,7 +14,7 @@ module Mobile else case f when :user_act - if ac.act_type == "ProjectCreateInfo" + if ac.act_type == "Project" ac unless ac.nil? else ac.act unless ac.nil? || ac.act.nil? @@ -87,7 +87,7 @@ module Mobile "项目缺陷" when "Message" "项目讨论区" - when "ProjectCreateInfo" + when "Project" "项目" end end @@ -101,7 +101,7 @@ module Mobile expose :container_type #课程/项目/博客/个人 expose :author, using: Mobile::Entities::User do |a, opt| #用户信息 if a.is_a? ::UserActivity - if a.act_type == "ProjectCreateInfo" + if a.act_type == "Project" get_user(get_project(a.act_id).user_id) elsif !a.act.nil? if a.act_type == 'Issue' || a.act_type == 'News' || a.act_type == 'Message' || a.act_type == 'BlogComment' diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index c94f734e1..1946378ef 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -127,7 +127,7 @@ class OrganizationsController < ApplicationController case params[:type] when nil @org_activities = OrgActivity.where("(container_id =? and container_type =?) " + - "or (container_type ='Project' and org_act_type in ('Issue','Message','ProjectCreateInfo') and container_id in (#{project_ids.join(',')})) "+ + "or (container_type ='Project' and org_act_type in ('Issue','Message','Project') and container_id in (#{project_ids.join(',')})) "+ "or (container_type ='Course' and org_act_type in #{course_types} and container_id in (#{course_ids.join(',')}))", @organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10) when 'project_issue' diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 373801963..6f3aa6b18 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1373,7 +1373,7 @@ class UsersController < ApplicationController user_project_ids = (@user.projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (@user.projects.visible.map{|project| project.id}-shield_project_ids).join(",") + ")" user_course_ids = (@user.courses.visible.where("is_delete = 0").map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (@user.courses.visible.where("is_delete = 0").map{|course| course.id}-shield_course_ids).join(",") + ")" course_types = "('Message','News','HomeworkCommon','Poll','Course','JournalsForMessage')" - project_types = "('Message','Issue','ProjectCreateInfo')" + project_types = "('Message','Issue','Project')" principal_types = "JournalsForMessage" if params[:type].present? case params[:type] diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 0d75636f7..a9e4771e8 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -211,7 +211,7 @@ class WechatsController < ActionController::Base user_project_ids = (@user.projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (@user.projects.visible.map{|project| project.id}-shield_project_ids).join(",") + ")" user_course_ids = (@user.courses.visible.map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (@user.courses.visible.map{|course| course.id}-shield_course_ids).join(",") + ")" course_types = "('Message','News','HomeworkCommon','Poll','Course')" - project_types = "('Message','Issue','ProjectCreateInfo')" + project_types = "('Message','Issue','Project')" principal_types = "JournalsForMessage" blog_ids = "("+@user.blog.id.to_s+","+((User.watched_by(@user.id).count == 0 )? '0' :User.watched_by(@user.id).map{|u| u.blog.id}.join(','))+")" diff --git a/app/models/course_activity.rb b/app/models/course_activity.rb index 96ec6e355..2aae45d0a 100644 --- a/app/models/course_activity.rb +++ b/app/models/course_activity.rb @@ -5,8 +5,7 @@ class CourseActivity < ActiveRecord::Base belongs_to :course belongs_to :user has_many :user_acts, :class_name => 'UserAcivity',:as =>:act - after_save :add_user_activity, :add_org_activity - after_create :add_course_lead + after_create :add_course_lead,:add_user_activity, :add_org_activity before_destroy :destroy_user_activity, :destroy_org_activity #在个人动态里面增加当前动态 diff --git a/app/models/forge_activity.rb b/app/models/forge_activity.rb index c044392a0..44b13b315 100644 --- a/app/models/forge_activity.rb +++ b/app/models/forge_activity.rb @@ -20,7 +20,7 @@ class ForgeActivity < ActiveRecord::Base validates :forge_act_id,presence: true validates :forge_act_type, presence: true has_many :user_acts, :class_name => 'UserAcivity',:as =>:act - after_save :add_user_activity, :add_org_activity + after_create :add_user_activity, :add_org_activity before_destroy :destroy_user_activity, :destroy_org_activity #在个人动态里面增加当前动态 diff --git a/app/views/organizations/_org_activities.html.erb b/app/views/organizations/_org_activities.html.erb index a3e62fd16..c00cc6161 100644 --- a/app/views/organizations/_org_activities.html.erb +++ b/app/views/organizations/_org_activities.html.erb @@ -56,7 +56,7 @@ <%= render :partial => 'organizations/org_project_issue', :locals => {:activity => Issue.find(act.org_act_id),:user_activity_id =>act.id} %> <% when 'Message' %> <%= render :partial => 'organizations/project_message', :locals => {:activity => Message.find(act.org_act_id),:user_activity_id =>act.id} %> - <% when 'ProjectCreateInfo'%> + <% when 'Project'%> <%= render :partial => 'organizations/project_create', :locals => {:activity => act,:user_activity_id =>act.id} %> <% end %> <% end %> diff --git a/app/views/organizations/_org_project_activities.html.erb b/app/views/organizations/_org_project_activities.html.erb index b46996661..d27e690c6 100644 --- a/app/views/organizations/_org_project_activities.html.erb +++ b/app/views/organizations/_org_project_activities.html.erb @@ -6,7 +6,7 @@ <%= render :partial => 'organizations/org_project_issue', :locals => {:activity => act.forge_act,:user_activity_id =>act.id} %> <% when 'Message' %> <%= render :partial => 'organizations/project_message', :locals => {:activity => act.forge_act,:user_activity_id =>act.id} %> - <% when 'ProjectCreateInfo'%> + <% when 'Project'%> <%= render :partial => 'organizations/project_create', :locals => {:activity => act,:user_activity_id =>act.id} %> <% end %> <% end %> diff --git a/app/views/users/_user_activities.html.erb b/app/views/users/_user_activities.html.erb index b7df824a4..2fe7315d5 100644 --- a/app/views/users/_user_activities.html.erb +++ b/app/views/users/_user_activities.html.erb @@ -54,7 +54,7 @@ sd_create_editor_from_data(<%= user_activity.id %>, null, "100%", "<%= user_activity.class.to_s %>"); }); - <% if user_activity.act_type == "ProjectCreateInfo" %> + <% if user_activity.act_type == "Project" %> <%= render :partial => 'project_create', :locals => {:activity => user_activity,:user_activity_id =>user_activity.id} %> <% else %> <% act= user_activity.act %> @@ -94,7 +94,7 @@ <%# end %> <% when 'Message' %> <%= render :partial => 'project_message', :locals => {:activity => act,:user_activity_id =>user_activity.id,:is_course=>0,:is_board=>0} %> - <% when 'ProjectCreateInfo'%> + <% when 'Project'%> <%# cache (act) do %> <%= render :partial => 'project_create', :locals => {:activity => act,:user_activity_id =>user_activity.id} %> <%# end %> diff --git a/db/migrate/20160519070718_change_user_activities_data.rb b/db/migrate/20160519070718_change_user_activities_data.rb new file mode 100644 index 000000000..1a1bfb827 --- /dev/null +++ b/db/migrate/20160519070718_change_user_activities_data.rb @@ -0,0 +1,9 @@ +class ChangeUserActivitiesData < ActiveRecord::Migration + def up + execute("update user_activities set act_type = 'Project' where act_type = 'ProjectCreateInfo'") + execute("update org_activities set org_act_type = 'Project' where org_act_type = 'ProjectCreateInfo'") + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 43153fb76..9c4b4b333 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,8 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20160511055221) do +ActiveRecord::Schema.define(:version => 20160519070718) do + create_table "activities", :force => true do |t| t.integer "act_id", :null => false t.string "act_type", :null => false